Cv2SolvePnPRansac Method (IEnumerablePoint3f, IEnumerablePoint2f, Double, IEnumerableDouble, Double, Double, Int32, Boolean, Int32, Single, Int32, SolvePnPFlag) OpenCvSharp Class Library
computes the camera pose from a few 3D points and the corresponding projections. The outliers are possible.

Namespace:  OpenCvSharp.CPlusPlus
Assembly:  OpenCvSharp.CPlusPlus (in OpenCvSharp.CPlusPlus.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax

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 = 8f,
	int minInliersCount = 100,
	SolvePnPFlag flags = SolvePnPFlag.Iterative
)

Parameters

objectPoints
Type: System.Collections.GenericIEnumerablePoint3f
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.
imagePoints
Type: System.Collections.GenericIEnumerablePoint2f
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.
cameraMatrix
Type: SystemDouble
Input 3x3 camera matrix
distCoeffs
Type: System.Collections.GenericIEnumerableDouble
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.
rvec
Type: SystemDouble
Output rotation vector that, together with tvec , brings points from the model coordinate system to the camera coordinate system.
tvec
Type: SystemDouble
Output translation vector.
inliers
Type: SystemInt32
Output vector that contains indices of inliers in objectPoints and imagePoints .
useExtrinsicGuess (Optional)
Type: SystemBoolean
If true, the function uses the provided rvec and tvec values as initial approximations of the rotation and translation vectors, respectively, and further optimizes them.
iterationsCount (Optional)
Type: SystemInt32
Number of iterations.
reprojectionError (Optional)
Type: SystemSingle
Inlier 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.
minInliersCount (Optional)
Type: SystemInt32
Number of inliers. If the algorithm at some stage finds more inliers than minInliersCount , it finishes.
flags (Optional)
Type: OpenCvSharp.CPlusPlusSolvePnPFlag
Method for solving a PnP problem
See Also

Reference