]> git.sesse.net Git - nageru/commitdiff
Make the eval tool capable of taking the average over a series of flow files.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Sun, 22 Jul 2018 21:52:37 +0000 (23:52 +0200)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Sun, 22 Jul 2018 21:52:37 +0000 (23:52 +0200)
eval.cpp

index e19ce1f541a3fa1d14dd3ebc0ff0a18b74587d58..ef47a6899877e8a10a65c666cf36e00770f8e988 100644 (file)
--- a/eval.cpp
+++ b/eval.cpp
 
 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);
 }