Commit e5b99bd9 authored by akashsharma02's avatar akashsharma02

Minor fix for solvePnPRansac params mismatch #2064

Use checkVector over "2-point trick"

Fix warnings on MSVC compiler
parent 4d57438c
...@@ -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