change binarization in findChessboardCorners()#24564
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, |
AleksandrPanov
left a comment
There was a problem hiding this comment.
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.
| 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 | ||
| } | ||
| } |
| goto finalize; | ||
| goto finalize; |
There was a problem hiding this comment.
does not apply to this PR
|
|
||
| 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.
Delete these changes and make a rebase from 4.x (cornerSubPix has already been added to 4.x)
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" |
This reverts commit c9aafdd.
Add AVIF support through libavif. opencv#23596 This is to fix opencv#19271 Extra: opencv/opencv_extra#1069 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 - [x] There is a reference to the original bug report and related work - [x] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [x] The feature is well documented and sample code can be built with the project CMake
Check Checkerboard Corners opencv#24546 What I did was get you to pull out of findChessboardCorners cornres the whole part that "checks" and sorts the corners of the checkerboard if present. The main reason for this is that findChessboardCorners is often very slow to find the corners and this depends in that the size the contrast etc of the checkerboards can be very different from each other and writing a function that works on all kinds of images is complicated. So I find it very useful to have the ability to write your own code to process the image and then have a function that controls or orders the corners. 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
549ec68 to
774efd1
Compare
|
Hi @AleksandrPanov, |
ec45804 to
95d21c7
Compare
…encv into adaptive-findChessboardCorners
|
Hi I just wanted to know if there was anything I could do. |
|
There are a lot of not relevant changes in the PR. |

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.