mirror of
https://github.com/opencv/opencv.git
synced 2025-06-21 10:30:51 +08:00
![]() Add image dimension check to avoid StereoSGBM non-determinism #27305 Addresses #25828 Users noticed that StereoSGBM would occasionally give non-deterministic results for `.compute(imgL, imgR)`. I and others traced the cause to out-of-bounds access that was not being caught when the input images were not wide enough for the input block size and number of disparities to StereoSGBM. The specific math and logic can be found in the above issue's discussion. This PR adds a CV_Check to make sure images are wider than 1/2 of the block size + the max disparity the algorithm will search. The check was only added to the regular `compute` method for StereoSGBM and not to the other modes, as I did not observe the non-deterministic behavior with the other compute modes like HH. In addition, this PR adds a test case to Calib3d to make sure the check is being thrown in the problem case and that the results are deterministic in the good case. ### Pull Request Readiness Checklist 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. - [ ] The feature is well documented and sample code can be built with the project CMake |
||
---|---|---|
.. | ||
doc | ||
include/opencv2 | ||
misc | ||
perf | ||
src | ||
test | ||
CMakeLists.txt |