Skip to content

Check Checkerboard Corners#24546

Merged
asmorkalov merged 18 commits intoopencv:4.xfrom
thewoz:checkerboard
Dec 20, 2023
Merged

Check Checkerboard Corners#24546
asmorkalov merged 18 commits intoopencv:4.xfrom
thewoz:checkerboard

Conversation

@thewoz
Copy link
Copy Markdown
Contributor

@thewoz thewoz commented Nov 15, 2023

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.

Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

  • I agree to contribute to the project under Apache 2 License.
  • 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
  • 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

@asmorkalov asmorkalov added feature category: calib3d pr: needs test New functionality requires minimal tests set labels Nov 16, 2023
@asmorkalov
Copy link
Copy Markdown
Contributor

Some test is required for the new function.

@thewoz
Copy link
Copy Markdown
Contributor Author

thewoz commented Nov 16, 2023

sure what kind of test do you think would be good? But do you mean a permanent test to put in the opencv tests or a test just to check that it works?

@asmorkalov
Copy link
Copy Markdown
Contributor

I mean regular unit test. You can re-use some images from findChessboardCorners tests. Also checkChessboardCorners sounds misleading. I propose something like findChessboardCornersSimple, because, it's not chessboard validation.

@thewoz
Copy link
Copy Markdown
Contributor Author

thewoz commented Nov 16, 2023

ok sound good for me.

@thewoz
Copy link
Copy Markdown
Contributor Author

thewoz commented Nov 16, 2023

sorry but I'm not able to find the images used in the findChessboardCornes test

@AleksandrPanov
Copy link
Copy Markdown
Contributor

may relate to "cv2.findChessboardCorners() running endlessly on certain images #23558" issue

@thewoz
Copy link
Copy Markdown
Contributor Author

thewoz commented Nov 17, 2023

Hi, I may as well test on image #23558 but the result will depend on how I binarize the image before calling the proposed function.
Aren't there already some checkerboard images I can use as a test? If I can add some.

@thewoz
Copy link
Copy Markdown
Contributor Author

thewoz commented Nov 20, 2023

@asmorkalov sorry where I can find the findChessboardCorners test images?

@asmorkalov
Copy link
Copy Markdown
Contributor

@thewoz
Copy link
Copy Markdown
Contributor Author

thewoz commented Nov 20, 2023

Hi,
I have test the pull request against the images:
BoardStereoL1-6.png BoardStereoR1-6.png and chess1-6.png

in

https://github.com/opencv/opencv_extra/tree/4.x/testdata/cv/cameracalibration

and the chessboard was found in each of them.

@asmorkalov
Copy link
Copy Markdown
Contributor

Hello @thewoz . Thanks a lot for the contribution! The PR and API change was discussed on OpenCV Core team meeting. Team members propose to not introduce the new function, but add flag to findChessboardCorners and presume single entry point. As alternative, it could be a combination of existing flags and some new one. For example, if you introduce some new flag to force max_dilations=0 and disable CALIB_CB_FAST_CHECK, CALIB_CB_NORMALIZE_IMAGE, CALIB_CB_ADAPTIVE_THRESH you get almost the same you what.

@thewoz
Copy link
Copy Markdown
Contributor Author

thewoz commented Nov 21, 2023

Hi @asmorkalov thanks to you and to all the team.
I understand your point and have proceeded to add a new flag.
I have named it CALIB_CB_PLAIN. What it actually does is to ignore the other flags and set max_dilations to zero as suggested.

@thewoz
Copy link
Copy Markdown
Contributor Author

thewoz commented Dec 1, 2023

Hi there is anything else I can do ?

Copy link
Copy Markdown
Contributor

@asmorkalov asmorkalov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@asmorkalov
Copy link
Copy Markdown
Contributor

@vpisarev @mshabunin Please take a look too.

@asmorkalov asmorkalov added this to the 4.9.0 milestone Dec 1, 2023
Copy link
Copy Markdown
Contributor

@mshabunin mshabunin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need a test for this new flag, something simple - load one of the test images with QR code, manually do threshold, dilate and other preparations, call function and expect detection result. Also a test for exception for BGR image input.

SHOW("New binarization", thresh_img_new);

if (flags & CALIB_CB_FAST_CHECK)
if (flags & CALIB_CB_FAST_CHECK && !(flags & CALIB_CB_PLAIN))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (flags & CALIB_CB_FAST_CHECK && !(flags & CALIB_CB_PLAIN))
if (flags & CALIB_CB_FAST_CHECK && !is_plain)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW, wouldn't it be useful to have both PLAIN and FAST_CHECK flags enabled?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi mshabunin I'm not so sure about the idea of having both CALIB_CB_PLAIN and CALIB_CB_FAST_CHECK active at the same time.
The basic idea with CALIB_CB_PLAIN is to have a function that in fact does "nothing" in the sense that all image processing (binarization) is done externally

@thewoz
Copy link
Copy Markdown
Contributor Author

thewoz commented Dec 1, 2023

I think we need a test for this new flag, something simple - load one of the test images with QR code, manually do threshold, dilate and other preparations, call function and expect detection result. Also a test for exception for BGR image input.

Where do you think is the best place to put these tests?

@mshabunin
Copy link
Copy Markdown
Contributor

Perhaps here: https://github.com/opencv/opencv/blob/4.x/modules/calib3d/test/test_chesscorners.cpp or in one of neighbour files.

@thewoz
Copy link
Copy Markdown
Contributor Author

thewoz commented Dec 4, 2023

I added the first test.
I relied on an existing one.
I did not run all the tests because for each one you would have to do a different binarization.
I think anyway they can be enough

@thewoz
Copy link
Copy Markdown
Contributor Author

thewoz commented Dec 14, 2023

is there anything else i can do?

@asmorkalov asmorkalov removed the pr: needs test New functionality requires minimal tests set label Dec 20, 2023
@asmorkalov
Copy link
Copy Markdown
Contributor

@vpisarev @mshabunin May I merge the patch?

@asmorkalov asmorkalov merged commit e64c5dc into opencv:4.x Dec 20, 2023
@asmorkalov asmorkalov mentioned this pull request Jan 19, 2024
thewoz added a commit to thewoz/opencv that referenced this pull request May 29, 2024
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
thewoz added a commit to thewoz/opencv that referenced this pull request May 30, 2024
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants