* calib3d: fix USAC getLambda out-of-bounds on single support vectors
Fixes#27487
In usac::getLambda(), the median calculation had an inverted odd/even
parity check and accessed supports[size/2 + 1] when size % 2 was
non-zero. When evaluating a single model (supports.size() == 1),
supports[1] was accessed out of bounds, which triggered a debug
assertion (vector subscript out of range) in debug builds and caused
undefined reads in release builds.
This patch:
- Inlines getLambda in usac.hpp without CV_EXPORTS to avoid altering
the 4.x shared library ABI.
- Corrects the median calculation to use supports[size/2] for odd sizes
and (supports[size/2 - 1] + supports[size/2]) * 0.5 for even sizes.
- Guards empty support vectors and clamps denominators to avoid
divisions by zero.
* calib3d: add deterministic test coverage for getLambda
Add direct regression tests in test_usac.cpp:
- Empty support vector returns 1.0 and sets min_non_random_inliers to 1.
- Single-element vector (supports.size() == 1) validates fix against out-of-bounds read and crash.
- Even-sized vector (supports.size() == 4) validates two-middle-element median.
- Odd-sized vector (supports.size() == 3) validates middle-element median.
- Validates denominator handling and min_non_random_inliers when is_independent is true.
Update USAC #23078
### Pull Request Readiness Checklist
- [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
Add `estimateSE2(...)`, `estimateSE3(...)`, `estimateSIM2(...)`, `estimateSIM3(...)` for estimating an geometric transformation with rotation and translation (with scaling for SIM) using USAC: as alternative for `estimateAffinePartial2D` and `estimateAffine3D`.
Modified test module.
Remove unused variables.
Remove initializer of unused variable.
Add interfaces to accept UsacParams() and corresponding test codes.
Revise test code.
PartialNd removed
Umeyama rewritten for code quality & speed
comments & minors
rise number of points
fix, and +30% faster!
only one number should be that big
remove USAC code, leave fix only
big number
calib3d(usac): do not crash on empty models
* calib3d(test): regression test for issue 19639
* calib3d(usac): do not crash in setModelParameters()
* calib3d(usac): handle empty models in isModelGood()