1 #include <gtest/gtest.h>     7 #include <mrpt/config.h>     8 #if MRPT_HAS_OPENCV && MRPT_OPENCV_VERSION_NUM<0x240     9 #       undef MRPT_HAS_OPENCV    10 #       define MRPT_HAS_OPENCV 0    16 class CPnPTest: public::testing::Test
    21         Eigen::MatrixXd obj_pts, img_pts, pose_est;
    22         Eigen::Matrix3d 
R, I3, R_est;
    23         Eigen::Vector3d 
t, t_est;
    30             obj_pts = Eigen::MatrixXd::Zero(3,
n);
    31             img_pts = Eigen::MatrixXd::Zero(3,
n);
    32             obj_pts << 0, 20,  10, 15, 14, 16,
    33                         0, 0, -10, -5, -2, -5,
    36             R << -0.3536, 0.3536, -0.8660,
    37                   0.9330, 0.0670, -0.3536,
    38                  -0.0670, -0.9330, -0.3536;
    42             for (
int i = 0; i < 
n; i++)
    44                 img_pts.col(i) = (
R * obj_pts.col(i) + 
t);
    45                 img_pts.col(i) /= img_pts(2,i);
    48             I3 = Eigen::MatrixXd::Identity(3, 3);
    50             pose_est = Eigen::MatrixXd::Zero(6,1);
    53         virtual void TearDown()
    64     cpnp.p3p(obj_pts, img_pts, 
n, I3, pose_est);
    66     t_est<<pose_est(0), pose_est(1), pose_est(2);
    68     double err_t = (
t-t_est).
norm();
    73 TEST_F(CPnPTest, rpnp_TEST)
    75     cpnp.rpnp(obj_pts, img_pts, 
n, I3, pose_est);
    77     t_est<<pose_est(0), pose_est(1), pose_est(2);
    79     double err_t = (
t-t_est).
norm();
    84 TEST_F(CPnPTest, ppnp_TEST)
    86     cpnp.ppnp(obj_pts, img_pts, 
n, I3, pose_est);
    88     t_est<<pose_est(0), pose_est(1), pose_est(2);
    90     double err_t = (
t-t_est).
norm();
    95 TEST_F(CPnPTest, posit_TEST)
    97     cpnp.posit(obj_pts, img_pts, 
n, I3, pose_est);
    99     t_est<<pose_est(0), pose_est(1), pose_est(2);
   101     double err_t = (
t-t_est).
norm();
   106 TEST_F(CPnPTest, lhm_TEST)
   108     cpnp.lhm(obj_pts, img_pts, 
n, I3, pose_est);
   110     t_est<<pose_est(0), pose_est(1), pose_est(2);
   112     double err_t = (
t-t_est).
norm();
   117 TEST_F(CPnPTest, dls_TEST)
   119     cpnp.dls(obj_pts, img_pts, 
n, I3, pose_est);
   121     t_est<<pose_est(0), pose_est(1), pose_est(2);
   123     double err_t = (
t-t_est).
norm();
   128 TEST_F(CPnPTest, epnp_TEST)
   130     cpnp.epnp(obj_pts, img_pts, 
n, I3, pose_est);
   132     t_est<<pose_est(0), pose_est(1), pose_est(2);
   134     double err_t = (
t-t_est).
norm();
   139 TEST_F(CPnPTest, DISABLED_upnp_TEST)
   141     cpnp.upnp(obj_pts, img_pts, 
n, I3, pose_est);
   143     t_est<<pose_est(0), pose_est(1), pose_est(2);
   145     double err_t = (
t-t_est).
norm();
 This class is used for Pose estimation from a known landmark using a monocular camera. 
 
PnP Algorithms toolkit for MRPT. 
 
TEST_F(QuaternionTests, crossProduct)
 
CONTAINER::Scalar norm(const CONTAINER &v)