Added test for checking that solvePnPRansac accepts vector<Point3f> and Nx3 1-channel or 1xN/Nx1 3-channel matrices as input.

pull/5949/head
Alexander Karsakov 9 years ago
parent 7a62a8213b
commit 0c9c7d5f3b
  1. 2
      modules/calib3d/src/solvepnp.cpp
  2. 37
      modules/calib3d/test/test_solvepnp_ransac.cpp

@ -270,6 +270,8 @@ bool solvePnPRansac(InputArray _opoints, InputArray _ipoints,
{
vector<Point3d> opoints_inliers;
vector<Point2d> ipoints_inliers;
opoints = opoints.reshape(3);
ipoints = ipoints.reshape(2);
opoints.convertTo(opoints_inliers, CV_64F);
ipoints.convertTo(ipoints_inliers, CV_64F);

@ -314,6 +314,43 @@ TEST(Calib3d_SolvePnPRansac, concurrency)
EXPECT_LT(tnorm, 1e-6);
}
TEST(Calib3d_SolvePnPRansac, input_type)
{
const int numPoints = 10;
Matx33d intrinsics(5.4794130238156129e+002, 0., 2.9835545700043139e+002, 0.,
5.4817724002728005e+002, 2.3062194051986233e+002, 0., 0., 1.);
std::vector<cv::Point3f> points3d;
std::vector<cv::Point2f> points2d;
for (int i = 0; i < numPoints; i++)
{
points3d.push_back(cv::Point3i(i, 0, 0));
points2d.push_back(cv::Point2i(i, 0));
}
Mat R1, t1, R2, t2, R3, t3, R4, t4;
ASSERT_TRUE(solvePnPRansac(points3d, points2d, intrinsics, cv::Mat(), R1, t1));
Mat points3dMat(points3d);
Mat points2dMat(points2d);
ASSERT_TRUE(solvePnPRansac(points3dMat, points2dMat, intrinsics, cv::Mat(), R2, t2));
points3dMat = points3dMat.reshape(3, 1);
points2dMat = points2dMat.reshape(2, 1);
ASSERT_TRUE(solvePnPRansac(points3dMat, points2dMat, intrinsics, cv::Mat(), R3, t3));
points3dMat = points3dMat.reshape(1, numPoints);
points2dMat = points2dMat.reshape(1, numPoints);
ASSERT_TRUE(solvePnPRansac(points3dMat, points2dMat, intrinsics, cv::Mat(), R4, t4));
ASSERT_LE(norm(R1, R2, NORM_INF), 1e-6);
ASSERT_LE(norm(t1, t2, NORM_INF), 1e-6);
ASSERT_LE(norm(R1, R3, NORM_INF), 1e-6);
ASSERT_LE(norm(t1, t3, NORM_INF), 1e-6);
ASSERT_LE(norm(R1, R4, NORM_INF), 1e-6);
ASSERT_LE(norm(t1, t4, NORM_INF), 1e-6);
}
TEST(Calib3d_SolvePnP, double_support)
{
Matx33d intrinsics(5.4794130238156129e+002, 0., 2.9835545700043139e+002, 0.,

Loading…
Cancel
Save