Skip to content

Commit

Permalink
found a bug in check_epi.c in test_find_candidates
Browse files Browse the repository at this point in the history
  • Loading branch information
alexlib committed May 6, 2023
1 parent 0ab6dbd commit 97e1ac8
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
5 changes: 5 additions & 0 deletions liboptv/src/epi.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
18 changes: 11 additions & 7 deletions liboptv/tests/check_epi.c
Original file line number Diff line number Diff line change
Expand Up @@ -203,20 +203,20 @@ 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}
};

int num_pix = 7; /* length of the test_pix */

/* 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}
};

Expand Down Expand Up @@ -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<count; i++) {
printf("candidate %d: pnr %d, corr %f, tol %f\n", i, test_cand[i].pnr, test_cand[i].corr, test_cand[i].tol);
}

/* expected results: */
fail_unless(test_cand[0].pnr = 1);
fail_unless(test_cand[0].pnr == 0);
fail_unless(test_cand[0].tol < EPS);

/* regression guard */
Expand All @@ -301,9 +305,9 @@ START_TEST(test_find_candidate)
sum_corr += test_cand[i].corr;
}

ck_assert_msg( fabs(sum_corr - 2625.) < EPS &&
(count == 4) &&
fabs(test_cand[3].tol - 0.565685) < EPS,
ck_assert_msg( fabs(sum_corr -3301.0) < EPS &&
(count == 5) &&
fabs(test_cand[3].tol - 0.636396) < EPS,
"\n Expected ... \n \
but found %f %d %9.6f \n", sum_corr, count, test_cand[3].tol);
}
Expand Down
6 changes: 3 additions & 3 deletions py_bind/test/test_corresp.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,9 @@ def test_single_cam_corresp(self):
targ.set_pixel_counts(25, 5, 5)
targ.set_sum_grey_value(10)

img_pts.append(targs)
mc = MatchedCoords(targs, cpar, cal)
corrected.append(mc)
img_pts.append(targs)
mc = MatchedCoords(targs, cpar, cal)
corrected.append(mc)

_, _, num_targs = correspondences(
img_pts, corrected, cals, vpar, cpar)
Expand Down

1 comment on commit 97e1ac8

@alexlib
Copy link
Contributor Author

@alexlib alexlib commented on 97e1ac8 May 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reviewed.

Please sign in to comment.