15 #include <Eigen/Dense>    17 #include <Eigen/StdVector>    23     Eigen::MatrixXd obj_pts_, Eigen::MatrixXd img_pts_, Eigen::MatrixXd cam_,
    34     Q = Eigen::MatrixXd::Ones(3, 
n);
    45     for (
int i = 0; i < 
n; i++) sum_ += 
F[i] * 
R * 
P.col(i);
    51     for (
int i = 0; i < 
n; i++) 
Q.col(i) = 
R * 
P.col(i) + 
t;
    56     Eigen::Matrix4d Q_(4, 4);
    58     Q_ << q(0), -q(1), -q(2), -q(3), q(1), q(0), -q(3), q(2), q(2), q(3), q(0),
    59         -q(1), q(3), -q(2), q(1), q(0);
    66     Eigen::Matrix4d Q_(4, 4);
    68     Q_ << q(0), -q(1), -q(2), -q(3), q(1), q(0), q(3), -q(2), q(2), -q(3), q(0),
    69         q(1), q(3), q(2), -q(1), q(0);
    76     for (
int i = 0; i < 
n; i++) 
Q.col(i) = 
F[i] * 
Q.col(i);
    78     Eigen::Vector3d P_bar, Q_bar;
    79     P_bar = 
P.rowwise().mean();
    80     Q_bar = 
Q.rowwise().mean();
    82     for (
int i = 0; i < 
n; i++)
    84         P.col(i) = 
P.col(i) - P_bar;
    85         Q.col(i) = 
Q.col(i) - Q_bar;
   143     for (
int i = 0; i < 
n; i++)
   145         Eigen::Vector4d q1, q2;
   151     Eigen::EigenSolver<Eigen::Matrix4d> es(
A);
   153     const Eigen::Matrix4d Ae = es.pseudoEigenvalueMatrix();
   156     for (
int i = 0; i < 4; i++) D[i] = Ae(i, i);
   158     Eigen::Matrix4d V_mat = es.pseudoEigenvectors();
   160     Eigen::Vector4d::Index max_index;
   162     D.maxCoeff(&max_index);
   166     V = V_mat.col(max_index);
   168     Eigen::Quaterniond q(V(0), V(1), V(2), V(3));
   170     R = q.toRotationMatrix();
   178     Eigen::Matrix3d I3 = Eigen::MatrixXd::Identity(3, 3);
   180     for (
int i = 0; i < 
n; i++)
   182         vec = (I3 - 
F[i]) * 
Q.col(i);
   183         err2 += vec.squaredNorm();
   188     Eigen::Ref<Eigen::Matrix3d> R_, Eigen::Ref<Eigen::Vector3d> t_)
   192     Eigen::VectorXd p_bar;
   193     Eigen::Matrix3d sum_F, I3;
   194     I3 = Eigen::MatrixXd::Identity(3, 3);
   197     p_bar = 
P.rowwise().mean();
   199     for (i = 0; i < 
n; i++)
   202         F[i] = 
Q.col(i) * 
Q.col(i).transpose() / 
Q.col(i).squaredNorm();
   203         sum_F = sum_F + 
F[i];
   206     G = (I3 - sum_F / 
n).inverse() / 
n;
 Eigen::MatrixXd img_pts
Object points in Camera Co-ordinate system. 
 
void xform()
Transform object points in Body frame (Landmark Frame) to estimated Camera Frame. ...
 
Eigen::MatrixXd P
Camera intrinsic matrix. 
 
double err2
Error variable for convergence selection. 
 
void estimate_t()
Function to estimate translation given an estimated rotation matrix. 
 
Eigen::Matrix4d qMatW(Eigen::VectorXd q)
Iternal Function of quaternion. 
 
Eigen::Matrix3d G
Matrix for internal computations. 
 
Perspective n Point (PnP) Algorithms toolkit for MRPT mrpt_vision_grp. 
 
int n
Error variable for convergence selection. 
 
void absKernel()
Function to compute pose during an iteration. 
 
double err
Storage matrix for each point. 
 
Eigen::MatrixXd Q
Trnaspose of Object points . 
 
Lu Hage Mjolsness - Iterative PnP Algorithm (Eigen Implementation. 
 
std::vector< Eigen::Matrix3d > F
Translation Vector. 
 
lhm(Eigen::MatrixXd obj_pts_, Eigen::MatrixXd img_pts_, Eigen::MatrixXd cam_, int n0)
Number of 2d/3d correspondences. 
 
Eigen::Matrix3d R
Transpose of Image points . 
 
Eigen::Vector3d t
Rotation Matrix. 
 
Eigen::MatrixXd cam_intrinsic
Image points in pixel co-ordinates. 
 
bool compute_pose(Eigen::Ref< Eigen::Matrix3d > R_, Eigen::Ref< Eigen::Vector3d > t_)
Function to compute pose using LHM PnP algorithm. 
 
Eigen::Matrix4d qMatQ(Eigen::VectorXd q)
Iternal Function of quaternion.