From 97e1ac89f82e1c06605f0088ea7439fff510a5b9 Mon Sep 17 00:00:00 2001 From: Alex Liberzon Date: Sat, 6 May 2023 17:48:12 +0300 Subject: [PATCH] found a bug in check_epi.c in test_find_candidates --- liboptv/src/epi.c | 5 +++++ liboptv/tests/check_epi.c | 18 +++++++++++------- py_bind/test/test_corresp.py | 6 +++--- 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/liboptv/src/epi.c b/liboptv/src/epi.c index dce5c2f9..f14ceef6 100644 --- a/liboptv/src/epi.c +++ b/liboptv/src/epi.c @@ -201,6 +201,11 @@ int find_candidate (coord_2d *crd, target *pix, int num, continue; p2 = crd[j].pnr; + + if (p2 >= num) { + printf("pnr out of range: %d\n", p2); + return -1; + } /* quality of each parameter is a ratio of the values of the size n, nx, ny and sum of grey values sumg */ diff --git a/liboptv/tests/check_epi.c b/liboptv/tests/check_epi.c index 5848456e..a550127a 100644 --- a/liboptv/tests/check_epi.c +++ b/liboptv/tests/check_epi.c @@ -203,7 +203,7 @@ START_TEST(test_find_candidate) {3, 0.2, 0.8, 10, 3, 3, 30, -999}, {4, 0.4, -1.1, 10, 3, 3, 40, -999}, {1, 0.7, -0.1, 10, 3, 3, 50, -999}, - {7, 1.2, 0.3, 10, 3, 3, 60, -999}, + {2, 1.2, 0.3, 10, 3, 3, 60, -999}, {5, 10.4, 0.1, 10, 3, 3, 70, -999} }; @@ -211,12 +211,12 @@ START_TEST(test_find_candidate) /* coord_2d is int pnr, double x,y */ coord_2d test_crd[] = { - {0, 0.0, 0.0}, {6, 0.1, 0.1}, /* best candidate, right on the diagonal */ {3, 0.2, 0.8}, {4, 0.4, -1.1}, {1, 0.7, -0.1}, - {7, 1.2, 0.3}, + {2, 1.2, 0.3}, + {0, 0.0, 0.0}, {5, 10.4, 0.1} }; @@ -290,9 +290,13 @@ START_TEST(test_find_candidate) n, nx, ny, sumg, test_cand, &test_vpar, test_cpar, &test_cal); free_control_par(test_cpar); + + for (i=0; i