Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
thewoz committed May 29, 2024
1 parent 11f9e59 commit c7d8e1d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 22 deletions.
27 changes: 14 additions & 13 deletions modules/calib3d/src/calibinit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -508,18 +508,19 @@ bool findChessboardCorners(InputArray image_, Size pattern_size,

Mat thresh_img_new = img.clone();

if(!is_plain) {
if(flags & CALIB_CB_ADAPTIVE_THRESH)
{
// Assume that the checkerboard occupies 5% of the image
int min_size = cvRound((img.cols * img.rows * 0.05) / ((pattern_size.width+1) * (pattern_size.height+1)));
if(min_size%2==0) min_size += 1;
adaptiveThreshold(img, thresh_img_new, 255, ADAPTIVE_THRESH_MEAN_C, THRESH_BINARY, min_size, 0);
}
else
{
icvBinarizationHistogramBased(thresh_img_new); // process image in-place
}
if (!is_plain)
{
if (flags & CALIB_CB_ADAPTIVE_THRESH)
{
// Assume that the checkerboard occupies 5% of the image
int min_size = cvRound((img.cols * img.rows * 0.05) / ((pattern_size.width+1) * (pattern_size.height+1)));
if(min_size%2==0) min_size += 1;
adaptiveThreshold(img, thresh_img_new, 255, ADAPTIVE_THRESH_MEAN_C, THRESH_BINARY, min_size, 0);
}
else
{
icvBinarizationHistogramBased(thresh_img_new); // process image in-place
}
}

SHOW("New binarization", thresh_img_new);
Expand Down Expand Up @@ -1409,7 +1410,7 @@ int ChessBoardDetector::checkQuadGroup(const std::vector<ChessBoardQuad*>& quad_
}

if (corner_count != pattern_size.width*pattern_size.height)
goto finalize;
goto finalize;

{
ChessBoardCorner* first = NULL, *first2 = NULL;
Expand Down
9 changes: 0 additions & 9 deletions modules/calib3d/test/test_cameracalibration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1401,15 +1401,6 @@ void CV_StereoCalibrationTest::run( int )
bool found1 = findChessboardCorners(left, patternSize, imgpt1[i]);
bool found2 = findChessboardCorners(right, patternSize, imgpt2[i]);

Mat leftGrey = left;
if(left.channels() != 1) cv::cvtColor(left, leftGrey, cv::COLOR_BGR2GRAY);

Mat rightGrey = right;
if(right.channels() != 1) cv::cvtColor(right, rightGrey, cv::COLOR_BGR2GRAY);

cv::cornerSubPix(leftGrey, imgpt1[i], cv::Size(6,6), cv::Size(-1,-1), cv::TermCriteria(cv::TermCriteria::EPS + cv::TermCriteria::COUNT, 15, 0.1));
cv::cornerSubPix(rightGrey, imgpt2[i], cv::Size(6,6), cv::Size(-1,-1), cv::TermCriteria(cv::TermCriteria::EPS + cv::TermCriteria::COUNT, 15, 0.1));

if(!found1 || !found2)
{
ts->printf( cvtest::TS::LOG, "The function could not detect boards (%d x %d) on the images %s and %s, testcase %d\n",
Expand Down

0 comments on commit c7d8e1d

Please sign in to comment.