You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Problem: Original used float mc[i].y/x directly in at<char>(mc[i].y, mc[i].x), causing truncation to int but potential OOB if float >= rows/cols due to FP precision (e.g., 479.999f -> 479 on 479-row mat, failing unsigned(row) < rows assertion).
265
-
// Fix: Floor to int explicitly; add strict bounds check (row/col >0 && < dims) to skip invalid accesses safely. Using unsigned cast mirrors OpenCV's internal check for robustness.
266
-
// Note: row/col >0 skips edge=0, but moments rarely hit exactly 0; adjust to >=0 if edge cases arise.
if (finder_point_range.at<char>(mc[i].y, mc[i].x) != 0) {
277
257
FinderPoint finder;
278
-
279
-
// --- START OF EDIT ---
280
-
// Problem (subtle): Original used float mc[i].x/y for finder.x/y, but downstream calcs (e.g., dist, angle) assume precision; however, for consistency with checked access, use int row/col here to avoid FP drift.
281
-
// Fix: Assign int row/col to finder.x/y; preserves subpixel accuracy minimally while ensuring validity.
0 commit comments