Skip to content

Commit

Permalink
apriltag_quad_thresh: Prevent using decimate for scale smaller than 1
Browse files Browse the repository at this point in the history
The rest of the codebase treats all values equal to 1 or smaller as disablers of the decimation. This function was the only one behaving differently. After this commit, the behavior will be consistent.

Especially, value 0.0 led to division by zero and then conversion of NaN, to int, which is undefined behavior.

Signed-off-by: Martin Pecka<[email protected]>
  • Loading branch information
peci1 committed May 26, 2024
1 parent 21be60d commit 11f30d3
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion apriltag_quad_thresh.c
Original file line number Diff line number Diff line change
Expand Up @@ -1810,7 +1810,8 @@ zarray_t* fit_quads(apriltag_detector_t *td, int w, int h, zarray_t* clusters, i
normal_border |= !family->reversed_border;
reversed_border |= family->reversed_border;
}
min_tag_width /= td->quad_decimate;
if (td->quad_decimate > 1)
min_tag_width /= td->quad_decimate;
if (min_tag_width < 3) {
min_tag_width = 3;
}
Expand Down

0 comments on commit 11f30d3

Please sign in to comment.