9 #include <gtest/gtest.h>    11 #include <Eigen/Dense>    16 #include <mrpt/config.h>    17 #if MRPT_HAS_OPENCV && MRPT_OPENCV_VERSION_NUM < 0x240    18 #undef MRPT_HAS_OPENCV    19 #define MRPT_HAS_OPENCV 0    24 class CPnPTest : 
public ::testing::Test
    29     Eigen::MatrixXd obj_pts, img_pts, pose_est;
    30     Eigen::Matrix3d 
R, I3, R_est;
    31     Eigen::Vector3d t, t_est;
    38         obj_pts = Eigen::MatrixXd::Zero(3, n);
    39         img_pts = Eigen::MatrixXd::Zero(3, n);
    40         obj_pts << 0, 20, 10, 15, 14, 16, 0, 0, -10, -5, -2, -5, 0, 40, 0, 24,
    43         R << -0.3536, 0.3536, -0.8660, 0.9330, 0.0670, -0.3536, -0.0670,
    48         for (
int i = 0; i < n; i++)
    50             img_pts.col(i) = (
R * obj_pts.col(i) + t);
    51             img_pts.col(i) /= img_pts(2, i);
    54         I3 = Eigen::MatrixXd::Identity(3, 3);
    56         pose_est = Eigen::MatrixXd::Zero(6, 1);
    58     void TearDown()
 override {}
    63     cpnp.p3p(obj_pts, img_pts, n, I3, pose_est);
    65     t_est << pose_est(0), pose_est(1), pose_est(2);
    67     double err_t = (t - t_est).
norm();
    72 TEST_F(CPnPTest, rpnp_TEST)
    74     cpnp.rpnp(obj_pts, img_pts, n, I3, pose_est);
    76     t_est << pose_est(0), pose_est(1), pose_est(2);
    78     double err_t = (t - t_est).
norm();
    83 TEST_F(CPnPTest, ppnp_TEST)
    85     cpnp.ppnp(obj_pts, img_pts, n, I3, pose_est);
    87     t_est << pose_est(0), pose_est(1), pose_est(2);
    89     double err_t = (t - t_est).
norm();
    94 TEST_F(CPnPTest, posit_TEST)
    96     cpnp.posit(obj_pts, img_pts, n, I3, pose_est);
    98     t_est << pose_est(0), pose_est(1), pose_est(2);
   100     double err_t = (t - t_est).
norm();
   105 TEST_F(CPnPTest, lhm_TEST)
   107     cpnp.lhm(obj_pts, img_pts, n, I3, pose_est);
   109     t_est << pose_est(0), pose_est(1), pose_est(2);
   111     double err_t = (t - t_est).
norm();
   116 TEST_F(CPnPTest, dls_TEST)
   118     cpnp.dls(obj_pts, img_pts, n, I3, pose_est);
   120     t_est << pose_est(0), pose_est(1), pose_est(2);
   122     double err_t = (t - t_est).
norm();
   127 TEST_F(CPnPTest, epnp_TEST)
   129     cpnp.epnp(obj_pts, img_pts, n, I3, pose_est);
   131     t_est << pose_est(0), pose_est(1), pose_est(2);
   133     double err_t = (t - t_est).
norm();
   138 TEST_F(CPnPTest, DISABLED_upnp_TEST)
   140     cpnp.upnp(obj_pts, img_pts, n, I3, pose_est);
   142     t_est << pose_est(0), pose_est(1), pose_est(2);
   144     double err_t = (t - t_est).
norm();
 This class is used for Pose estimation from a known landmark using a monocular camera. 
 
TEST_F(Pose3DTests, DefaultValues)
 
PnP Algorithms toolkit for MRPT. 
 
CONTAINER::Scalar norm(const CONTAINER &v)