From 11f30d373f0dce553cf6ecfb780a3bbd88da8b25 Mon Sep 17 00:00:00 2001 From: Martin Pecka Date: Tue, 21 May 2024 14:16:17 +0200 Subject: [PATCH] apriltag_quad_thresh: Prevent using decimate for scale smaller than 1 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 --- apriltag_quad_thresh.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apriltag_quad_thresh.c b/apriltag_quad_thresh.c index a70c5df7..2b577740 100644 --- a/apriltag_quad_thresh.c +++ b/apriltag_quad_thresh.c @@ -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; }