Commit 5d2cf95a authored by Alexander Alekhin's avatar Alexander Alekhin

Merge pull request #2473 from akashsharma02:3.4

parents b928dfb3 e5b99bd9
...@@ -445,8 +445,13 @@ bool CustomPattern::findRtRANSAC(InputArray objectPoints, InputArray imagePoints ...@@ -445,8 +445,13 @@ bool CustomPattern::findRtRANSAC(InputArray objectPoints, InputArray imagePoints
OutputArray rvec, OutputArray tvec, bool useExtrinsicGuess, int iterationsCount, OutputArray rvec, OutputArray tvec, bool useExtrinsicGuess, int iterationsCount,
float reprojectionError, int minInliersCount, OutputArray inliers, int flags) 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, 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 return true; // for consistency with the other methods
} }
...@@ -459,8 +464,12 @@ bool CustomPattern::findRtRANSAC(InputArray image, InputArray cameraMatrix, Inpu ...@@ -459,8 +464,12 @@ bool CustomPattern::findRtRANSAC(InputArray image, InputArray cameraMatrix, Inpu
if (!findPattern(image, imagePoints, objectPoints)) if (!findPattern(image, imagePoints, objectPoints))
return false; 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, solvePnPRansac(objectPoints, imagePoints, cameraMatrix, distCoeffs, rvec, tvec, useExtrinsicGuess,
iterationsCount, reprojectionError, minInliersCount, inliers, flags); iterationsCount, reprojectionError, confidence, inliers, flags);
return true; return true;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment