Skip to content
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

Use initial quads corners in ChessBoardDetector::findQuadNeighbors #25195

Conversation

MaximSmolskiy
Copy link
Contributor

@MaximSmolskiy MaximSmolskiy commented Mar 10, 2024

Pull Request Readiness Checklist

Idea is to make quad neighbors finding more simple (for understanding and debugging) and deterministic
And for that use initial quads corners, now they can be updated in
https://github.com/opencv/opencv/blob/4.x/modules/calib3d/src/calibinit.cpp#L1740
and then affect following finding, e.g. in
https://github.com/opencv/opencv/blob/4.x/modules/calib3d/src/calibinit.cpp#L1698

Before #24605 we also could use updated corners in nearest neighbors, but now we use k-d tree for it with copy of initial corners and what we use updated corners in following part of algorithm can be considered as something like logic divergence

I tested this PR with benchmark

python3 objdetect_benchmark.py --configuration=generate_run --board_x=7 --path=res_chessboard --synthetic_object=chessboard

There are no any changes in detected chessboards number:

cell_img_size = 100 (default)

before
                                 category  detected chessboard  total detected chessboard  total chessboard  average detected error chessboard
                                      all             0.904167                      13020             14400                           0.600512
Total detected time:  109.607109 sec

after
                                 category  detected chessboard  total detected chessboard  total chessboard  average detected error chessboard
                                      all             0.904167                      13020             14400                           0.600512
Total detected time:  108.14007100000008 sec

----------------------------------------------------------------------------------------------------------------------------------------------

cell_img_size = 10

before
                                 category  detected chessboard  total detected chessboard  total chessboard  average detected error chessboard
                                      all             0.539792                       7773             14400                           4.209964
Total detected time:  3.1171079999999995 sec

after
                                 category  detected chessboard  total detected chessboard  total chessboard  average detected error chessboard
                                      all             0.539792                       7773             14400                           4.209964
Total detected time:  2.982243999999999 sec

----------------------------------------------------------------------------------------------------------------------------------------------

cell_img_size = 9

before
                                 category  detected chessboard  total detected chessboard  total chessboard  average detected error chessboard
                                      all             0.516458                       7437             14400                           3.378223
Total detected time:  2.8566790000000015 sec

after
                                 category  detected chessboard  total detected chessboard  total chessboard  average detected error chessboard
                                      all             0.516458                       7437             14400                           3.378223
Total detected time:  3.1788580000000017 sec

----------------------------------------------------------------------------------------------------------------------------------------------

cell_img_size = 8

before
                                 category  detected chessboard  total detected chessboard  total chessboard  average detected error chessboard
                                      all             0.474444                       6832             14400                           3.229681
Total detected time:  2.648073000000003 sec

after
                                 category  detected chessboard  total detected chessboard  total chessboard  average detected error chessboard
                                      all             0.474444                       6832             14400                           3.229681
Total detected time:  2.5567910000000005 sec

----------------------------------------------------------------------------------------------------------------------------------------------

cell_img_size = 7

before
                                 category  detected chessboard  total detected chessboard  total chessboard  average detected error chessboard
                                      all             0.400972                       5774             14400                           3.422815
Total detected time:  2.461659 sec

after
                                      all             0.400972                       5774             14400                           3.422815
Total detected time:  2.3133559999999997 sec

----------------------------------------------------------------------------------------------------------------------------------------------

cell_img_size = 6

before
                                 category  detected chessboard  total detected chessboard  total chessboard  average detected error chessboard
                                      all             0.272708                       3927             14400                           3.236853
Total detected time:  1.9906030000000003 sec

after
                                 category  detected chessboard  total detected chessboard  total chessboard  average detected error chessboard
                                      all             0.272708                       3927             14400                           3.236853
Total detected time:  2.080433999999999 sec

----------------------------------------------------------------------------------------------------------------------------------------------

cell_img_size = 5

before
                                 category  detected chessboard  total detected chessboard  total chessboard  average detected error chessboard
                                      all             0.137500                       1980             14400                           3.030068
Total detected time:  1.8522970000000019 sec

after
                                 category  detected chessboard  total detected chessboard  total chessboard  average detected error chessboard
                                      all             0.137500                       1980             14400                           3.030068
Total detected time:  1.7436250000000018 sec

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

Copy link
Contributor

@AleksandrPanov AleksandrPanov left a comment

Choose a reason for hiding this comment

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

👍

@asmorkalov asmorkalov added this to the 4.10.0 milestone Apr 2, 2024
@asmorkalov asmorkalov merged commit 99cacaa into opencv:4.x Apr 2, 2024
27 checks passed
@MaximSmolskiy MaximSmolskiy deleted the use-initial-quads-corners-in-ChessBoardDetector-findQuadNeighbors branch April 2, 2024 10:42
@asmorkalov asmorkalov mentioned this pull request Apr 10, 2024
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.

None yet

3 participants