Skip to content

usac findEssentialMat always uses maxiters=1000 even when specified otherwise #22696

@Parskatt

Description

@Parskatt

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:

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;

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)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions