Merge pull request #19847 from gasparitiago:expose-max-iters

This commit is contained in:
Alexander Alekhin 2021-04-08 10:31:36 +00:00
commit be17fce657
2 changed files with 36 additions and 4 deletions

View File

@ -2241,6 +2241,7 @@ final fundamental matrix. It can be set to something like 1-3, depending on the
point localization, image resolution, and the image noise. point localization, image resolution, and the image noise.
@param mask Output array of N elements, every element of which is set to 0 for outliers and to 1 @param mask Output array of N elements, every element of which is set to 0 for outliers and to 1
for the other points. The array is computed only in the RANSAC and LMedS methods. for the other points. The array is computed only in the RANSAC and LMedS methods.
@param maxIters The maximum number of robust method iterations.
This function estimates essential matrix based on the five-point algorithm solver in @cite Nister03 . This function estimates essential matrix based on the five-point algorithm solver in @cite Nister03 .
@cite SteweniusCFS is also a related. The epipolar geometry is described by the following equation: @cite SteweniusCFS is also a related. The epipolar geometry is described by the following equation:
@ -2251,6 +2252,12 @@ where \f$E\f$ is an essential matrix, \f$p_1\f$ and \f$p_2\f$ are corresponding
second images, respectively. The result of this function may be passed further to second images, respectively. The result of this function may be passed further to
decomposeEssentialMat or recoverPose to recover the relative pose between cameras. decomposeEssentialMat or recoverPose to recover the relative pose between cameras.
*/ */
CV_EXPORTS_W Mat findEssentialMat( InputArray points1, InputArray points2,
InputArray cameraMatrix, int method,
double prob, double threshold,
int maxIters, OutputArray mask = noArray() );
/** @overload */
CV_EXPORTS_W Mat findEssentialMat( InputArray points1, InputArray points2, CV_EXPORTS_W Mat findEssentialMat( InputArray points1, InputArray points2,
InputArray cameraMatrix, int method = RANSAC, InputArray cameraMatrix, int method = RANSAC,
double prob = 0.999, double threshold = 1.0, double prob = 0.999, double threshold = 1.0,
@ -2274,6 +2281,7 @@ point localization, image resolution, and the image noise.
confidence (probability) that the estimated matrix is correct. confidence (probability) that the estimated matrix is correct.
@param mask Output array of N elements, every element of which is set to 0 for outliers and to 1 @param mask Output array of N elements, every element of which is set to 0 for outliers and to 1
for the other points. The array is computed only in the RANSAC and LMedS methods. for the other points. The array is computed only in the RANSAC and LMedS methods.
@param maxIters The maximum number of robust method iterations.
This function differs from the one above that it computes camera intrinsic matrix from focal length and This function differs from the one above that it computes camera intrinsic matrix from focal length and
principal point: principal point:
@ -2285,6 +2293,13 @@ f & 0 & x_{pp} \\
0 & 0 & 1 0 & 0 & 1
\end{bmatrix}\f] \end{bmatrix}\f]
*/ */
CV_EXPORTS_W Mat findEssentialMat( InputArray points1, InputArray points2,
double focal, Point2d pp,
int method, double prob,
double threshold, int maxIters,
OutputArray mask = noArray() );
/** @overload */
CV_EXPORTS_W Mat findEssentialMat( InputArray points1, InputArray points2, CV_EXPORTS_W Mat findEssentialMat( InputArray points1, InputArray points2,
double focal = 1.0, Point2d pp = Point2d(0, 0), double focal = 1.0, Point2d pp = Point2d(0, 0),
int method = RANSAC, double prob = 0.999, int method = RANSAC, double prob = 0.999,

View File

@ -403,7 +403,8 @@ protected:
// Input should be a vector of n 2D points or a Nx2 matrix // Input should be a vector of n 2D points or a Nx2 matrix
cv::Mat cv::findEssentialMat( InputArray _points1, InputArray _points2, InputArray _cameraMatrix, cv::Mat cv::findEssentialMat( InputArray _points1, InputArray _points2, InputArray _cameraMatrix,
int method, double prob, double threshold, OutputArray _mask) int method, double prob, double threshold,
int maxIters, OutputArray _mask)
{ {
CV_INSTRUMENT_REGION(); CV_INSTRUMENT_REGION();
@ -442,20 +443,36 @@ cv::Mat cv::findEssentialMat( InputArray _points1, InputArray _points2, InputArr
Mat E; Mat E;
if( method == RANSAC ) if( method == RANSAC )
createRANSACPointSetRegistrator(makePtr<EMEstimatorCallback>(), 5, threshold, prob)->run(points1, points2, E, _mask); createRANSACPointSetRegistrator(makePtr<EMEstimatorCallback>(), 5, threshold, prob, maxIters)->run(points1, points2, E, _mask);
else else
createLMeDSPointSetRegistrator(makePtr<EMEstimatorCallback>(), 5, prob)->run(points1, points2, E, _mask); createLMeDSPointSetRegistrator(makePtr<EMEstimatorCallback>(), 5, prob, maxIters)->run(points1, points2, E, _mask);
return E; return E;
} }
cv::Mat cv::findEssentialMat( InputArray _points1, InputArray _points2, InputArray _cameraMatrix,
int method, double prob, double threshold,
OutputArray _mask)
{
return cv::findEssentialMat(_points1, _points2, _cameraMatrix, method, prob, threshold, 1000, _mask);
}
cv::Mat cv::findEssentialMat( InputArray _points1, InputArray _points2, double focal, Point2d pp,
int method, double prob, double threshold, int maxIters, OutputArray _mask)
{
CV_INSTRUMENT_REGION();
Mat cameraMatrix = (Mat_<double>(3,3) << focal, 0, pp.x, 0, focal, pp.y, 0, 0, 1);
return cv::findEssentialMat(_points1, _points2, cameraMatrix, method, prob, threshold, maxIters, _mask);
}
cv::Mat cv::findEssentialMat( InputArray _points1, InputArray _points2, double focal, Point2d pp, cv::Mat cv::findEssentialMat( InputArray _points1, InputArray _points2, double focal, Point2d pp,
int method, double prob, double threshold, OutputArray _mask) int method, double prob, double threshold, OutputArray _mask)
{ {
CV_INSTRUMENT_REGION(); CV_INSTRUMENT_REGION();
Mat cameraMatrix = (Mat_<double>(3,3) << focal, 0, pp.x, 0, focal, pp.y, 0, 0, 1); Mat cameraMatrix = (Mat_<double>(3,3) << focal, 0, pp.x, 0, focal, pp.y, 0, 0, 1);
return cv::findEssentialMat(_points1, _points2, cameraMatrix, method, prob, threshold, _mask); return cv::findEssentialMat(_points1, _points2, cameraMatrix, method, prob, threshold, 1000, _mask);
} }
int cv::recoverPose( InputArray E, InputArray _points1, InputArray _points2, int cv::recoverPose( InputArray E, InputArray _points1, InputArray _points2,