Method SolvePnPRansac
- Namespace
- OpenCvSharp
- Assembly
- OpenCvSharp.dll
SolvePnPRansac(InputArray, InputArray, InputArray, InputArray, OutputArray, OutputArray, bool, int, float, double, OutputArray, SolvePnPMethod)
computes the camera pose from a few 3D points and the corresponding projections. The outliers are possible.
public static void SolvePnPRansac(InputArray objectPoints, InputArray imagePoints, InputArray cameraMatrix, InputArray distCoeffs, OutputArray rvec, OutputArray tvec, bool useExtrinsicGuess = false, int iterationsCount = 100, float reprojectionError = 8, double confidence = 0.99, OutputArray inliers = default, SolvePnPMethod flags = SolvePnPMethod.Iterative)
Parameters
objectPointsInputArrayArray of object points in the object coordinate space, 3xN/Nx3 1-channel or 1xN/Nx1 3-channel, where N is the number of points. List<Point3f> can be also passed here.
imagePointsInputArrayArray of corresponding image points, 2xN/Nx2 1-channel or 1xN/Nx1 2-channel, where N is the number of points. List<Point2f> can be also passed here.
cameraMatrixInputArrayInput 3x3 camera matrix
distCoeffsInputArrayInput vector of distortion coefficients (k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6]]) of 4, 5, or 8 elements. If the vector is null, the zero distortion coefficients are assumed.
rvecOutputArrayOutput rotation vector that, together with tvec , brings points from the model coordinate system to the camera coordinate system.
tvecOutputArrayOutput translation vector.
useExtrinsicGuessboolIf true, the function uses the provided rvec and tvec values as initial approximations of the rotation and translation vectors, respectively, and further optimizes them.
iterationsCountintNumber of iterations.
reprojectionErrorfloatInlier threshold value used by the RANSAC procedure. The parameter value is the maximum allowed distance between the observed and computed point projections to consider it an inlier.
confidencedoubleThe probability that the algorithm produces a useful result.
inliersOutputArrayOutput vector that contains indices of inliers in objectPoints and imagePoints .
flagsSolvePnPMethodMethod for solving a PnP problem
SolvePnPRansac(IEnumerable<Point3f>, IEnumerable<Point2f>, double[,], IEnumerable<double>, out double[], out double[])
computes the camera pose from a few 3D points and the corresponding projections. The outliers are possible.
public static void SolvePnPRansac(IEnumerable<Point3f> objectPoints, IEnumerable<Point2f> imagePoints, double[,] cameraMatrix, IEnumerable<double> distCoeffs, out double[] rvec, out double[] tvec)
Parameters
objectPointsIEnumerable<Point3f>Array of object points in the object coordinate space, 3xN/Nx3 1-channel or 1xN/Nx1 3-channel, where N is the number of points. List<Point3f> can be also passed here.
imagePointsIEnumerable<Point2f>Array of corresponding image points, 2xN/Nx2 1-channel or 1xN/Nx1 2-channel, where N is the number of points. List<Point2f> can be also passed here.
cameraMatrixdouble[,]Input 3x3 camera matrix
distCoeffsIEnumerable<double>Input vector of distortion coefficients (k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6]]) of 4, 5, or 8 elements. If the vector is null, the zero distortion coefficients are assumed.
rvecdouble[]Output rotation vector that, together with tvec , brings points from the model coordinate system to the camera coordinate system.
tvecdouble[]Output translation vector.
SolvePnPRansac(IEnumerable<Point3f>, IEnumerable<Point2f>, double[,], IEnumerable<double>?, out double[], out double[], out int[], bool, int, float, double, SolvePnPMethod)
computes the camera pose from a few 3D points and the corresponding projections. The outliers are possible.
[SuppressMessage("Maintainability", "CA1508: Avoid dead conditional code")]
public static void SolvePnPRansac(IEnumerable<Point3f> objectPoints, IEnumerable<Point2f> imagePoints, double[,] cameraMatrix, IEnumerable<double>? distCoeffs, out double[] rvec, out double[] tvec, out int[] inliers, bool useExtrinsicGuess = false, int iterationsCount = 100, float reprojectionError = 8, double confidence = 0.99, SolvePnPMethod flags = SolvePnPMethod.Iterative)
Parameters
objectPointsIEnumerable<Point3f>Array of object points in the object coordinate space, 3xN/Nx3 1-channel or 1xN/Nx1 3-channel, where N is the number of points. List<Point3f> can be also passed here.
imagePointsIEnumerable<Point2f>Array of corresponding image points, 2xN/Nx2 1-channel or 1xN/Nx1 2-channel, where N is the number of points. List<Point2f> can be also passed here.
cameraMatrixdouble[,]Input 3x3 camera matrix
distCoeffsIEnumerable<double>Input vector of distortion coefficients (k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6]]) of 4, 5, or 8 elements. If the vector is null, the zero distortion coefficients are assumed.
rvecdouble[]Output rotation vector that, together with tvec , brings points from the model coordinate system to the camera coordinate system.
tvecdouble[]Output translation vector.
inliersint[]Output vector that contains indices of inliers in objectPoints and imagePoints .
useExtrinsicGuessboolIf true, the function uses the provided rvec and tvec values as initial approximations of the rotation and translation vectors, respectively, and further optimizes them.
iterationsCountintNumber of iterations.
reprojectionErrorfloatInlier threshold value used by the RANSAC procedure. The parameter value is the maximum allowed distance between the observed and computed point projections to consider it an inlier.
confidencedoubleThe probability that the algorithm produces a useful result.
flagsSolvePnPMethodMethod for solving a PnP problem