public static void SolvePnP(
IEnumerable<Point3f> objectPoints,
IEnumerable<Point2f> imagePoints,
double[,] cameraMatrix,
IEnumerable<double> distCoeffs,
out double[] rvec, out double[] tvec,
bool useExtrinsicGuess = false,
SolvePnPFlags flags = SolvePnPFlags.Iterative)
{
if (objectPoints == null)
throw new ArgumentNullException(nameof(objectPoints));
if (imagePoints == null)
throw new ArgumentNullException(nameof(imagePoints));
if (cameraMatrix == null)
throw new ArgumentNullException(nameof(cameraMatrix));
if (cameraMatrix.GetLength(0) != 3 || cameraMatrix.GetLength(1) != 3)
throw new ArgumentException("");
Point3f[] objectPointsArray = EnumerableEx.ToArray(objectPoints);
Point2f[] imagePointsArray = EnumerableEx.ToArray(imagePoints);
double[] distCoeffsArray = EnumerableEx.ToArray(distCoeffs);
int distCoeffsLength = (distCoeffs == null) ? 0 : distCoeffsArray.Length;
rvec = new double[3];
tvec = new double[3];
NativeMethods.calib3d_solvePnP_vector(
objectPointsArray, objectPointsArray.Length,
imagePointsArray, imagePointsArray.Length,
cameraMatrix, distCoeffsArray, distCoeffsLength,
rvec, tvec, useExtrinsicGuess ? 1 : 0, (int)flags);
}
#endregion