mirror of
https://github.com/opencv/opencv.git
synced 2026-12-02 21:22:43 -06:00
851cc5baa57391ea5a9571f95eec234dca9ff558
* geometry: reject degenerate minimal samples in estimateAffine2D/estimateAffinePartial2D RANSACPointSetRegistrator::run() has a fast path used whenever exactly the minimum number of points is supplied (3 for affine, 2 for similarity). That path skips checkSubset() and trusts the kernel's return value, but Affine2DEstimatorCallback::runKernel() and AffinePartial2DEstimatorCallback::runKernel() always returned success, even when dividing by a zero or near-zero denominator (collinear or duplicate points). The result was a matrix full of inf/nan with every point reported as an inlier, instead of a clean failure. Both kernels now check the denominator against a threshold scaled by the square of the point coordinates (matching how far float32 input can drift from true collinearity/coincidence) and return 0 when it is degenerate. The existing "<= 0" checks in the fast path and the general RANSAC loop already handle this correctly. The general RANSAC loop (more than the minimum points) is unaffected, since a NaN/Inf model already fails computeError's inlier count. Add test3CollinearPoints and test2DuplicatePoints, matching the existing test file style. * geometry: make the degeneracy tolerance independent of coordinate offset The tolerance used absolute coordinates, so valid points far from the origin were rejected. estimateAffine2D now measures it against the triangle edges, and estimateAffinePartial2D only rejects coincident points. Add large-offset regression tests. * geometry: tidy the comment in the similarity kernel * geometry: test points that are collinear only up to float rounding
OpenCV: Open Source Computer Vision Library
Resources
- Homepage: https://opencv.org
- Courses: https://opencv.org/courses
- Docs: https://docs.opencv.org/5.x/
- Q&A forum: https://forum.opencv.org
- previous forum (read only): http://answers.opencv.org
- Issue tracking: https://github.com/opencv/opencv/issues
- Additional OpenCV functionality: https://github.com/opencv/opencv_contrib
- Donate to OpenCV: https://opencv.org/support/
Contributing
Please read the contribution guidelines before starting work on a pull request.
Summary of the guidelines:
- One pull request per issue;
- Choose the right base branch;
- Include tests and documentation;
- Clean up "oops" commits before submitting;
- Follow the coding style guide.
Additional Resources
- Submit your OpenCV-based project for inclusion in Community Friday on opencv.org
- Subscribe to the OpenCV YouTube Channel featuring OpenCV Live, an hour-long streaming show
- Follow OpenCV on LinkedIn for daily posts showing the state-of-the-art in computer vision & AI
- Apply to be an OpenCV Volunteer to help organize events and online campaigns as well as amplify them
- Follow OpenCV on Mastodon in the Fediverse
- Follow OpenCV on X
- OpenCV.ai: Computer Vision and AI development services from the OpenCV team.
Description
Languages
C++
87.7%
C
3.1%
Python
2.9%
CMake
2%
Java
1.5%
Other
2.6%