Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/OpenCvSharpExtern/calib3d.h
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ CVAPI(ExceptionStatus) calib3d_solvePnP_vector(cv::Point3f *objectPoints, int ob
distCoeffsMat = cv::Mat(distCoeffsLength, 1, CV_64FC1, distCoeffs);

const cv::Matx<double, 3, 3> cameraMatrixMat(cameraMatrix);
cv::Matx<double, 3, 1> rvecMat, tvecMat;
cv::Matx<double, 3, 1> rvecMat(rvec), tvecMat(tvec);
cv::solvePnP(objectPointsMat, imagePointsMat, cameraMatrixMat, distCoeffsMat, rvecMat, tvecMat, useExtrinsicGuess != 0, flags);
memcpy(rvec, rvecMat.val, sizeof(double) * 3);
memcpy(tvec, tvecMat.val, sizeof(double) * 3);
Expand Down
12 changes: 7 additions & 5 deletions test/OpenCvSharp.Tests/calib3d/Calib3dTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -280,11 +280,13 @@ public void FishEyeProjectPoints()
Cv2.FishEye.ProjectPoints(objectPoints, imagePoints, rVec, tVec, intrisicMat, distCoeffs, 0, jacobian);
}

[Fact]
public void SolvePnPTestByArray()
[Theory]
[InlineData(false)]
[InlineData(true)]
public void SolvePnPTestByArray(bool useExtrinsicGuess)
{
var rvec = new double[] { 0, 0, 0 };
var tvec = new double[] { 0, 0, 0 };
var rvec = new double[] { 3, 0, 0 };
var tvec = new double[] { 0, 0, -10 };
var cameraMatrix = new double[,]
{
{ 1, 0, 0 },
Expand All @@ -305,7 +307,7 @@ public void SolvePnPTestByArray()

Cv2.ProjectPoints(objPts, rvec, tvec, cameraMatrix, dist, out var imgPts, out var jacobian);

Cv2.SolvePnP(objPts, imgPts, cameraMatrix, dist, ref rvec, ref tvec);
Cv2.SolvePnP(objPts, imgPts, cameraMatrix, dist, ref rvec, ref tvec, useExtrinsicGuess: useExtrinsicGuess);
}

[Fact]
Expand Down