Merge pull request #2473 from akashsharma02:3.4

pull/2482/head^2 3.4.10
Alexander Alekhin 5 years ago
commit 5d2cf95afc
  1. 13
      modules/ccalib/src/ccalib.cpp

@ -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
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;
} }

Loading…
Cancel
Save