From: Steinar H. Gunderson Date: Sun, 22 Jul 2018 21:52:37 +0000 (+0200) Subject: Make the eval tool capable of taking the average over a series of flow files. X-Git-Tag: 1.8.0~76^2~198 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=08c3e56a759e091d55e77cfbe3d72866b82b744a;p=nageru Make the eval tool capable of taking the average over a series of flow files. --- diff --git a/eval.cpp b/eval.cpp index e19ce1f..ef47a68 100644 --- a/eval.cpp +++ b/eval.cpp @@ -10,10 +10,23 @@ using namespace std; +double eval_flow(const char *filename1, const char *filename2); + int main(int argc, char **argv) { - Flow flow = read_flow(argv[1]); - Flow gt = read_flow(argv[2]); + double sum_epe = 0.0; + int num_flows = 0; + for (int i = 1; i < argc; i += 2) { + sum_epe += eval_flow(argv[i], argv[i + 1]); + ++num_flows; + } + fprintf(stderr, "Average EPE: %.2f pixels\n", sum_epe / num_flows); +} + +double eval_flow(const char *filename1, const char *filename2) +{ + Flow flow = read_flow(filename1); + Flow gt = read_flow(filename2); double sum = 0.0; for (unsigned y = 0; y < unsigned(flow.height); ++y) { @@ -25,5 +38,5 @@ int main(int argc, char **argv) sum += hypot(du - gt_du, dv - gt_dv); } } - fprintf(stderr, "Average EPE: %.2f pixels\n", sum / (flow.width * flow.height)); + return sum / (flow.width * flow.height); }