1 // Evaluate a .flo file against ground truth,
2 // outputting the average end-point error.
13 double eval_flow(const char *filename1, const char *filename2);
15 int main(int argc, char **argv)
19 for (int i = 1; i < argc; i += 2) {
20 sum_epe += eval_flow(argv[i], argv[i + 1]);
23 printf("Average EPE: %.2f pixels\n", sum_epe / num_flows);
26 double eval_flow(const char *filename1, const char *filename2)
28 Flow flow = read_flow(filename1);
29 Flow gt = read_flow(filename2);
32 for (unsigned y = 0; y < unsigned(flow.height); ++y) {
33 for (unsigned x = 0; x < unsigned(flow.width); ++x) {
34 float du = flow.flow[y * flow.width + x].du;
35 float dv = flow.flow[y * flow.width + x].dv;
36 float gt_du = gt.flow[y * flow.width + x].du;
37 float gt_dv = gt.flow[y * flow.width + x].dv;
38 sum += hypot(du - gt_du, dv - gt_dv);
41 return sum / (flow.width * flow.height);