Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix homography assert #325

Merged

Conversation

christian-rauch
Copy link
Collaborator

When the "Find best row to swap with." section in homography_compute2 would not find a value greater than 0 in a row, max_val_idx would stay -1 and maybe be used later to index a matrix. We protected against the negative indexing (in debug mode) by checking for a positive index in 3a0a155.

But this causes issues for false-positive quad detections (#321). In this particular case, ignoreing the negative index would lead to return NULL; via max_val < epsilon, so we can also just return NULL; here and ignore that quad instead of stopping the process.

Fixes #321 .

@mkrogius As far as I understand c[4][4] contains the 4 correspondences from the 2D pixel coordinates in the image to the 2D coordinates of the unit square with +/-1 edge coordinates. But I don't fully understand why homography_compute2 does not deal with this special case of axis-aligned quads. Do you see a better way to handle this case?

@mkrogius
Copy link
Contributor

Sorry for the delayed response (and also for my lack of activity on this repo for a long time). My intention was that the following if statement, the if (max_val < epsilon) { check, would handle any degenerate cases

@mkrogius
Copy link
Contributor

mkrogius commented Apr 26, 2024

As for the axis-aligned quads, I don't yet see why those would cause failure, since there should still be only one valid homography solution. I'll look a bit more next week

@@ -445,7 +445,9 @@ static matd_t* homography_compute2(double c[4][4]) {
}
}

assert(max_val_idx >= 0);
if (max_val_idx < 0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Optional: This condition could be combined with the max_val < epsilon check below

@christian-rauch christian-rauch merged commit 59cae91 into AprilRobotics:master May 6, 2024
19 checks passed
@christian-rauch christian-rauch deleted the fix_homography_assert branch May 6, 2024 18:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

What's the meaning of 'apriltag.c:448: homography_compute2: Assertion `max_val_idx >= 0' failed.'?
4 participants