opencv/modules
Maxim Smolskiy cc6f85e1ba
Merge pull request #25427 from MaximSmolskiy:make-finding-corner-neighbor-symmetrical-in-ChessBoardDetector-findQuadNeighbors
Make finding corner neighbor symmetrical in ChessBoardDetector::findQuadNeighbors #25427

### Pull Request Readiness Checklist

The basic idea of finding pair of corners neighbors is to find best candidate for first corner and check if first corner quite good candidate for its best candidate. And we test first corner for its best candidate less than best candidate for first corner.

Idea of changes is to make finding corner neighbor symmetrical - find best candidate for first corner, find best candidate for second corner and match them as pair iff they are both best candidates for each other.

Additional advantage - it simplifies code and removes some code duplication.

I tested this PR with benchmark
```
python3 objdetect_benchmark.py --configuration=generate_run --board_x=7 --path=res_chessboard --synthetic_object=chessboard
```

There are minor changes in results
```
cell_img_size = 100 (default)

before

                                 category  detected chessboard  total detected chessboard  total chessboard  average detected error chessboard
                          _none_none_blur             1.000000                        360               360                           0.630345
                    _none_none_gaussNoise             0.833333                        300               360                           0.623405
                          _none_none_none             1.000000                        360               360                           0.631517
                    _none_none_strongBlur             1.000000                        360               360                           0.630316
                   _none_undistorted_blur             1.000000                        360               360                           0.671232
             _none_undistorted_gaussNoise             1.000000                        360               360                           0.672619
                   _none_undistorted_none             1.000000                        360               360                           0.673669
             _none_undistorted_strongBlur             1.000000                        360               360                           0.671257
                   _perspective_none_blur             1.000000                       1080              1080                           0.588694
             _perspective_none_gaussNoise             0.805556                        870              1080                           0.599312
                   _perspective_none_none             1.000000                       1080              1080                           0.591063
             _perspective_none_strongBlur             1.000000                       1080              1080                           0.588604
            _perspective_undistorted_blur             1.000000                       1080              1080                           0.622081
      _perspective_undistorted_gaussNoise             1.000000                       1080              1080                           0.625704
            _perspective_undistorted_none             1.000000                       1080              1080                           0.624191
      _perspective_undistorted_strongBlur             1.000000                       1080              1080                           0.621618
             _strongPerspective_none_blur             1.000000                        360               360                           0.482934
       _strongPerspective_none_gaussNoise             0.166667                         60               360                           0.391551
             _strongPerspective_none_none             1.000000                        360               360                           0.480290
       _strongPerspective_none_strongBlur             0.333333                        120               360                           0.469080
      _strongPerspective_undistorted_blur             1.000000                        360               360                           0.503458
_strongPerspective_undistorted_gaussNoise             0.250000                         90               360                           0.448713
      _strongPerspective_undistorted_none             1.000000                        360               360                           0.504412
_strongPerspective_undistorted_strongBlur             0.166667                         60               360                           0.473791
                                      all             0.904167                      13020             14400                           0.600512
Total detected time:  139.65614900000008 sec

after

                                 category  detected chessboard  total detected chessboard  total chessboard  average detected error chessboard
                          _none_none_blur             1.000000                        360               360                           0.630345
                    _none_none_gaussNoise             0.750000                        270               360                           0.636279
                          _none_none_none             1.000000                        360               360                           0.631517
                    _none_none_strongBlur             1.000000                        360               360                           0.630316
                   _none_undistorted_blur             1.000000                        360               360                           0.671232
             _none_undistorted_gaussNoise             1.000000                        360               360                           0.672619
                   _none_undistorted_none             1.000000                        360               360                           0.673669
             _none_undistorted_strongBlur             1.000000                        360               360                           0.671257
                   _perspective_none_blur             1.000000                       1080              1080                           0.588694
             _perspective_none_gaussNoise             0.888889                        960              1080                           0.594106
                   _perspective_none_none             1.000000                       1080              1080                           0.591064
             _perspective_none_strongBlur             1.000000                       1080              1080                           0.588604
            _perspective_undistorted_blur             1.000000                       1080              1080                           0.622081
      _perspective_undistorted_gaussNoise             1.000000                       1080              1080                           0.625703
            _perspective_undistorted_none             1.000000                       1080              1080                           0.624191
      _perspective_undistorted_strongBlur             1.000000                       1080              1080                           0.621618
             _strongPerspective_none_blur             1.000000                        360               360                           0.482934
       _strongPerspective_none_gaussNoise             0.166667                         60               360                           0.391551
             _strongPerspective_none_none             1.000000                        360               360                           0.480290
       _strongPerspective_none_strongBlur             0.333333                        120               360                           0.469080
      _strongPerspective_undistorted_blur             1.000000                        360               360                           0.503458
_strongPerspective_undistorted_gaussNoise             0.333333                        120               360                           0.422259
      _strongPerspective_undistorted_none             1.000000                        360               360                           0.504412
_strongPerspective_undistorted_strongBlur             0.166667                         60               360                           0.473791
                                      all             0.910417                      13110             14400                           0.599746
Total detected time:  142.40333700000005 sec

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

cell_img_size = 10

before

                                 category  detected chessboard  total detected chessboard  total chessboard  average detected error chessboard
                          _none_none_blur             0.991667                        357               360                           4.905091
                    _none_none_gaussNoise             0.750000                        270               360                           5.215633
                          _none_none_none             1.000000                        360               360                           4.943304
                    _none_none_strongBlur             0.916667                        330               360                           3.806217
                   _none_undistorted_blur             0.994444                        358               360                           5.220915
             _none_undistorted_gaussNoise             0.997222                        359               360                           4.542443
                   _none_undistorted_none             0.997222                        359               360                           4.340208
             _none_undistorted_strongBlur             0.161111                         58               360                           5.024331
                   _perspective_none_blur             0.629630                        680              1080                           4.825401
             _perspective_none_gaussNoise             0.966667                       1044              1080                           3.895425
                   _perspective_none_none             0.971296                       1049              1080                           3.920378
             _perspective_none_strongBlur             0.000000                          0              1080                                NaN
            _perspective_undistorted_blur             0.583333                        630              1080                           4.594335
      _perspective_undistorted_gaussNoise             0.999074                       1079              1080                           3.553195
            _perspective_undistorted_none             0.750000                        810              1080                           3.604110
      _perspective_undistorted_strongBlur             0.000000                          0              1080                                NaN
             _strongPerspective_none_blur             0.000000                          0               360                                NaN
       _strongPerspective_none_gaussNoise             0.000000                          0               360                                NaN
             _strongPerspective_none_none             0.083333                         30               360                           2.382460
       _strongPerspective_none_strongBlur             0.000000                          0               360                                NaN
      _strongPerspective_undistorted_blur             0.000000                          0               360                                NaN
_strongPerspective_undistorted_gaussNoise             0.000000                          0               360                                NaN
      _strongPerspective_undistorted_none             0.000000                          0               360                                NaN
_strongPerspective_undistorted_strongBlur             0.000000                          0               360                                NaN
                                      all             0.539792                       7773             14400                           4.209964
Total detected time:  2.6968930000000015 sec

after

                                 category  detected chessboard  total detected chessboard  total chessboard  average detected error chessboard
                          _none_none_blur             0.991667                        357               360                           4.905091
                    _none_none_gaussNoise             0.750000                        270               360                           5.215633
                          _none_none_none             1.000000                        360               360                           4.943304
                    _none_none_strongBlur             0.916667                        330               360                           3.806217
                   _none_undistorted_blur             0.994444                        358               360                           5.220915
             _none_undistorted_gaussNoise             0.997222                        359               360                           4.542443
                   _none_undistorted_none             0.997222                        359               360                           4.340208
             _none_undistorted_strongBlur             0.161111                         58               360                           5.024331
                   _perspective_none_blur             0.629630                        680              1080                           4.825401
             _perspective_none_gaussNoise             0.966667                       1044              1080                           3.895425
                   _perspective_none_none             0.999074                       1079              1080                           3.865684
             _perspective_none_strongBlur             0.000000                          0              1080                                NaN
            _perspective_undistorted_blur             0.583333                        630              1080                           4.594335
      _perspective_undistorted_gaussNoise             0.999074                       1079              1080                           3.553195
            _perspective_undistorted_none             0.750000                        810              1080                           3.604110
      _perspective_undistorted_strongBlur             0.000000                          0              1080                                NaN
             _strongPerspective_none_blur             0.000000                          0               360                                NaN
       _strongPerspective_none_gaussNoise             0.000000                          0               360                                NaN
             _strongPerspective_none_none             0.000000                          0               360                                NaN
       _strongPerspective_none_strongBlur             0.000000                          0               360                                NaN
      _strongPerspective_undistorted_blur             0.000000                          0               360                                NaN
_strongPerspective_undistorted_gaussNoise             0.000000                          0               360                                NaN
      _strongPerspective_undistorted_none             0.000000                          0               360                                NaN
_strongPerspective_undistorted_strongBlur             0.000000                          0               360                                NaN
                                      all             0.539792                       7773             14400                           4.208308
Total detected time:  2.7706419999999983 sec
```

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
2024-06-10 09:42:56 +03:00
..
calib3d Merge pull request #25427 from MaximSmolskiy:make-finding-corner-neighbor-symmetrical-in-ChessBoardDetector-findQuadNeighbors 2024-06-10 09:42:56 +03:00
core test: use cv::theRNG instead of own generator 2024-06-07 13:36:11 +03:00
dnn Merge pull request #25709 from dkurt:wrap_addLayer 2024-06-07 20:39:44 +03:00
features2d Merge pull request #25424 from mshabunin:fix-features2d-test 2024-04-17 14:19:05 +03:00
flann Prevent signed integer overflow in LshTable 2024-05-24 23:47:36 +02:00
gapi Disable more G-API streaming test due to unstability. 2024-06-04 11:07:22 +03:00
highgui Merge pull request #25525 from sturkmen72:png-spng-test 2024-05-17 11:37:12 +03:00
imgcodecs imgproc: fixed imread with output image argument, minor refactoring, fixes in HDR 2024-06-04 19:52:22 +03:00
imgproc Merge pull request #25680 from mshabunin:fix-approx-2 2024-05-31 19:28:03 +03:00
java doc: fix formulas in JavaDoc broken after Doxygen upgrade 2024-03-11 23:47:23 +03:00
js Delete option --memory-init-file of em++ 2024-05-23 10:59:09 +02:00
ml Partially back-port #25075 to 4.x 2024-03-05 12:15:39 +03:00
objc Merge pull request #24136 from komakai:visionos_support 2023-12-20 15:35:10 +03:00
objdetect Merge pull request #25722 from AleksandrPanov:update_testSeveralBoardsWithCustomIds 2024-06-06 20:01:33 +03:00
photo Merge pull request #25402 from Linaname:4.x 2024-04-17 11:26:56 +03:00
python Merge pull request #25709 from dkurt:wrap_addLayer 2024-06-07 20:39:44 +03:00
stitching Partially back-port #25075 to 4.x 2024-03-05 12:15:39 +03:00
ts test: use cv::theRNG instead of own generator 2024-06-07 13:36:11 +03:00
video Merge pull request #25092 from klatism:libjpeg-upgrade 2024-03-28 17:03:05 +03:00
videoio Added potential fix for Android H264 Encoding Bug 2024-06-05 19:17:49 +03:00
world cmake: use /INCREMENTAL:NO with MSVS 2015 2023-12-07 19:46:27 +00:00