-
-
Notifications
You must be signed in to change notification settings - Fork 56.5k
usac findEssentialMat always uses maxiters=1000 even when specified otherwise #22696
Description
System Information
OpenCV version: Latest on GitHub
Operating System: All
Compiler & compiler version: Non-applicable
Detailed description
Expected behaviour
When specifying maxIters to findessentialmat I would expect this to always be the maximal number of iterations. This is already the case for findFundamentalMat (for all methods) and findEssentialMat (when not using usac methods).
Actual behaviour
When using usac, maxIters is always set to 1000. This is clear from the following lines:
opencv/modules/calib3d/src/five-point.cpp
Lines 430 to 440 in acd8d3a
| cv::Mat cv::findEssentialMat( InputArray _points1, InputArray _points2, InputArray _cameraMatrix, | |
| int method, double prob, double threshold, | |
| int maxIters, OutputArray _mask) | |
| { | |
| CV_INSTRUMENT_REGION(); | |
| if (method >= 32 && method <= 38) | |
| return usac::findEssentialMat(_points1, _points2, _cameraMatrix, | |
| method, prob, threshold, _mask); | |
| Mat points1, points2, cameraMatrix; |
opencv/modules/calib3d/src/usac.hpp
Lines 801 to 804 in acd8d3a
| Mat findEssentialMat( InputArray points1, InputArray points2, | |
| InputArray cameraMatrix1, | |
| int method, double prob, | |
| double threshold, OutputArray mask); |
Steps to reproduce
The following code snippet will return the exact same results, which is unreasonable.
In Python:
cv2.findEssentialMat(
kpts0, kpts1, np.eye(3), threshold=norm_thresh, prob=conf, method=cv2.USAC_MAGSAC, maxIters = 1
)
cv2.findEssentialMat(
kpts0, kpts1, np.eye(3), threshold=norm_thresh, prob=conf, method=cv2.USAC_MAGSAC, maxIters = 5000
)While
cv2.findEssentialMat(
kpts0, kpts1, np.eye(3), threshold=norm_thresh, prob=conf, method=cv2.RANSAC, maxIters = 1
)
cv2.findEssentialMat(
kpts0, kpts1, np.eye(3), threshold=norm_thresh, prob=conf, method=cv2.RANSAC, maxIters = 5000
)Produces different results, which is reasonable.
Issue submission checklist
- I report the issue, it's not a question
- I checked the problem with documentation, FAQ, open issues, forum.opencv.org, Stack Overflow, etc and have not found any solution
- I updated to the latest OpenCV version and the issue is still there
- There is reproducer code and related data files (videos, images, onnx, etc)