-
-
Notifications
You must be signed in to change notification settings - Fork 55.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
change binarization in findChessboardCorners() #24564
base: 4.x
Are you sure you want to change the base?
Conversation
Maybe:
|
perhaps it might make sense to tie it to the CALIB_CB_ADAPTIVE_THRESH parameter. |
Yes, using a flag looks good to me. |
Hi, in https://github.com/opencv/opencv_extra/tree/4.x/testdata/cv/cameracalibration and the chessboard was found in each of them. |
@thewoz, you have regressions in accuracy. |
Hi I have been trying to figure out what is wrong. Investigating you more what comes out is that the problem comes from how findChessboardCorners() found the corners. In fact by calling cornerSubPix() externally from findChessboardCorners(), with a mask slightly larger than 6 pixels, as also suggested by the documentation of findChessboardCorners(), the problem is solved. |
hello sorry to bother you all the time. |
now should work! |
Hi @asmorkalov, I should have resolved the conflict. |
hi, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested with benchmark --configuration=generate_run --board_x=7 --board_y=6 --path=res_chessboard --synthetic_object=chessboard
:
There are more improvements than regressions, but additional testing needs to be done.
modules/calib3d/src/calibinit.cpp
Outdated
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 | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fix the tabs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
modules/calib3d/src/calibinit.cpp
Outdated
goto finalize; | ||
goto finalize; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does not apply to this PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
|
||
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)); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Delete these changes and make a rebase from 4.x (cornerSubPix
has already been added to 4.x)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
c7d8e1d
to
314208f
Compare
@thewoz, rebase needs to be fixed, you have 622 commits now) |
hi @AleksandrPanov, |
@thewoz, update your local repo to main opencv repo and make rebase
|
hi @AleksandrPanov
|
Did you make your commits in your local 4.x? It is better to make changes to your branch and not to "main/master" |
549ec68
to
774efd1
Compare
Hi @AleksandrPanov, |
ec45804
to
95d21c7
Compare
In testing to solve problem #23558 I noticed that on certain images CALIB_CB_FAST_CHECK fails.
The problem arises in the binarization of the pictures which is done by a "classic" method.
This causes images like the following to be binarized badly and the check fails.
What I did was to eliminate icvBinarizationHistogramBased() and instead use adaptiveThreshold()
After the change I tried the function on other nine different checkerboard images and had no problems.
Pull Request Readiness Checklist
See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request
Patch to opencv_extra has the same branch name.