1
0
mirror of https://github.com/opencv/opencv_contrib.git synced 2025-10-18 17:24:28 +08:00

Merge pull request #2473 from akashsharma02:3.4

This commit is contained in:
Alexander Alekhin
2020-03-26 08:03:58 +00:00

View File

@@ -445,8 +445,13 @@ bool CustomPattern::findRtRANSAC(InputArray objectPoints, InputArray imagePoints
OutputArray rvec, OutputArray tvec, bool useExtrinsicGuess, int iterationsCount,
float reprojectionError, int minInliersCount, OutputArray inliers, int flags)
{
int npoints = imagePoints.getMat().checkVector(2);
CV_Assert(npoints > 0);
double confidence_factor = (double)minInliersCount / (double)npoints;
double confidence = confidence_factor < 0.001 ? 0.001 : confidence_factor > 0.999 ? 0.999 : confidence_factor;
solvePnPRansac(objectPoints, imagePoints, cameraMatrix, distCoeffs, rvec, tvec, useExtrinsicGuess,
iterationsCount, reprojectionError, minInliersCount, inliers, flags);
iterationsCount, reprojectionError, confidence, inliers, flags);
return true; // for consistency with the other methods
}
@@ -459,8 +464,12 @@ bool CustomPattern::findRtRANSAC(InputArray image, InputArray cameraMatrix, Inpu
if (!findPattern(image, imagePoints, objectPoints))
return false;
double confidence_factor = (double)minInliersCount / (double)imagePoints.size();
double confidence = confidence_factor < 0.001 ? 0.001 : confidence_factor > 0.999 ? 0.999 : confidence_factor;
solvePnPRansac(objectPoints, imagePoints, cameraMatrix, distCoeffs, rvec, tvec, useExtrinsicGuess,
iterationsCount, reprojectionError, minInliersCount, inliers, flags);
iterationsCount, reprojectionError, confidence, inliers, flags);
return true;
}