]> git.sesse.net Git - nageru/blob - eval.cpp
Add some utility functions for working with .flo files.
[nageru] / eval.cpp
1 // Evaluate a .flo file against ground truth,
2 // outputting the average end-point error.
3
4 #include <assert.h>
5 #include <stdio.h>
6
7 #include <memory>
8
9 #include "util.h"
10
11 using namespace std;
12
13 int main(int argc, char **argv)
14 {
15         Flow flow = read_flow(argv[1]);
16         Flow gt = read_flow(argv[2]);
17
18         double sum = 0.0;
19         for (unsigned y = 0; y < unsigned(flow.height); ++y) {
20                 for (unsigned x = 0; x < unsigned(flow.width); ++x) {
21                         float du = flow.flow[y * flow.width + x].du;
22                         float dv = flow.flow[y * flow.width + x].dv;
23                         float gt_du = gt.flow[y * flow.width + x].du;
24                         float gt_dv = gt.flow[y * flow.width + x].dv;
25                         sum += hypot(du - gt_du, dv - gt_dv);
26                 }
27         }
28         fprintf(stderr, "Average EPE: %.2f pixels\n", sum / (flow.width * flow.height));
29 }