From 34c406ea3a49cef03b0f22357ca10cb96e2736ab Mon Sep 17 00:00:00 2001 From: Maxim Smolskiy Date: Wed, 29 Nov 2023 12:28:57 +0300 Subject: [PATCH] Merge pull request #24595 from MaximSmolskiy:fix-typo-inChessBoardDetector-generateQuads Fix typo in ChessBoardDetector::generateQuads #24595 ### Pull Request Readiness Checklist See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [x] I agree to contribute to the project under Apache 2 License. - [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV - [x] The PR is proposed to the proper branch - [ ] There is a reference to the original bug report and related work - [ ] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [ ] The feature is well documented and sample code can be built with the project CMake --- modules/calib3d/src/calibinit.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/calib3d/src/calibinit.cpp b/modules/calib3d/src/calibinit.cpp index a4aa622bbe..c979f0bb62 100644 --- a/modules/calib3d/src/calibinit.cpp +++ b/modules/calib3d/src/calibinit.cpp @@ -1730,8 +1730,8 @@ void ChessBoardDetector::generateQuads(const cv::Mat& image_, int flags) all_quads.deallocate(); all_corners.deallocate(); - // empiric bound for minimal allowed perimeter for squares - int min_size = 25; //cvRound( image->cols * image->rows * .03 * 0.01 * 0.92 ); + // empiric bound for minimal allowed area for squares + const int min_area = 25; //cvRound( image->cols * image->rows * .03 * 0.01 * 0.92 ); bool filterQuads = (flags & CALIB_CB_FILTER_QUADS) != 0; @@ -1759,7 +1759,7 @@ void ChessBoardDetector::generateQuads(const cv::Mat& image_, int flags) const std::vector& contour = contours[idx]; Rect contour_rect = boundingRect(contour); - if (contour_rect.area() < min_size) + if (contour_rect.area() < min_area) continue; std::vector approx_contour; @@ -1803,7 +1803,7 @@ void ChessBoardDetector::generateQuads(const cv::Mat& image_, int flags) // than rectangular and which are big enough double d3 = sqrt(normL2Sqr(pt[0] - pt[1])); double d4 = sqrt(normL2Sqr(pt[1] - pt[2])); - if (!(d3*4 > d4 && d4*4 > d3 && d3*d4 < area*1.5 && area > min_size && + if (!(d3*4 > d4 && d4*4 > d3 && d3*d4 < area*1.5 && area > min_area && d1 >= 0.15 * p && d2 >= 0.15 * p)) continue; }