MRPT  1.9.9
lhm.h
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2018, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 
10 #ifndef LHM_
11 
12 #define LHM_
13 
14 #include <iostream>
15 
16 #include <mrpt/math/types_math.h> // Eigen must be included first via MRPT to enable the plugin system
17 #include <Eigen/Dense>
18 #include <Eigen/SVD>
19 #include <Eigen/StdVector>
20 
21 #define TOL_LHM 0.00001
22 #define EPSILON_LHM 0.00000001
23 
24 namespace mrpt::vision::pnp
25 {
26 /** \addtogroup pnp Perspective-n-Point pose estimation
27  * \ingroup mrpt_vision_grp
28  * @{
29  */
30 
31 /**
32  * @class lhm
33  * @author Chandra Mangipudi
34  * @date 10/08/16
35  * @file lhm.h
36  * @brief Lu Hage Mjolsness - Iterative PnP Algorithm (Eigen Implementation
37  */
38 class lhm
39 {
40  Eigen::MatrixXd obj_pts; //! Object points in Camera Co-ordinate system
41  Eigen::MatrixXd img_pts; //! Image points in pixel co-ordinates
42  Eigen::MatrixXd cam_intrinsic; //! Camera intrinsic matrix
43  Eigen::MatrixXd P; //! Trnaspose of Object points @obj_pts
44  Eigen::MatrixXd Q; //! Transpose of Image points @img_pts
45 
46  Eigen::Matrix3d R; //! Matrix for internal computations
47  Eigen::Matrix3d G; //! Rotation Matrix
48  Eigen::Vector3d t; //! Translation Vector
49 
50  std::vector<Eigen::Matrix3d> F; //! Storage matrix for each point
51  double err; //! Error variable for convergence selection
52  double err2; //! Error variable for convergence selection
53 
54  int n; //! Number of 2d/3d correspondences
55 
56  public:
57  //! Constructor for the LHM class
58  lhm(Eigen::MatrixXd obj_pts_, Eigen::MatrixXd img_pts_,
59  Eigen::MatrixXd cam_, int n0);
60  //~lhm();
61 
62  /**
63  * @brief Function to compute pose using LHM PnP algorithm
64  * @param R_ Rotation matrix
65  * @param t_ Trnaslation Vector
66  * @return Success flag
67  */
68  bool compute_pose(
69  Eigen::Ref<Eigen::Matrix3d> R_, Eigen::Ref<Eigen::Vector3d> t_);
70 
71  /**
72  * @brief Function to compute pose during an iteration
73  */
74  void absKernel();
75 
76  /**
77  * @brief Function to estimate translation given an estimated rotation
78  * matrix
79  */
80  void estimate_t();
81 
82  /**
83  * @brief Transform object points in Body frame (Landmark Frame) to
84  * estimated Camera Frame
85  */
86  void xform();
87 
88  /**
89  * @brief Iternal Function of quaternion
90  * @param q Quaternion
91  * @return
92  */
93  Eigen::Matrix4d qMatQ(Eigen::VectorXd q);
94 
95  /**
96  * @brief Iternal Function of quaternion
97  * @param q Quaternion
98  * @return
99  */
100  Eigen::Matrix4d qMatW(Eigen::VectorXd q);
101 };
102 
103 /** @} */ // end of grouping
104 }
105 #endif
106 
107 
Eigen::MatrixXd img_pts
Object points in Camera Co-ordinate system.
Definition: lhm.h:41
void xform()
Transform object points in Body frame (Landmark Frame) to estimated Camera Frame. ...
Definition: lhm.cpp:56
Eigen::MatrixXd P
Camera intrinsic matrix.
Definition: lhm.h:43
double err2
Error variable for convergence selection.
Definition: lhm.h:52
Eigen::MatrixXd obj_pts
Definition: lhm.h:40
void estimate_t()
Function to estimate translation given an estimated rotation matrix.
Definition: lhm.cpp:48
Eigen::Matrix4d qMatW(Eigen::VectorXd q)
Iternal Function of quaternion.
Definition: lhm.cpp:71
Eigen::Matrix3d G
Matrix for internal computations.
Definition: lhm.h:47
Perspective n Point (PnP) Algorithms toolkit for MRPT mrpt_vision_grp.
Definition: pnp_algos.h:23
GLdouble GLdouble GLdouble GLdouble q
Definition: glext.h:3721
int n
Error variable for convergence selection.
Definition: lhm.h:54
void absKernel()
Function to compute pose during an iteration.
Definition: lhm.cpp:81
double err
Storage matrix for each point.
Definition: lhm.h:51
Eigen::MatrixXd Q
Trnaspose of Object points .
Definition: lhm.h:44
std::vector< Eigen::Matrix3d > F
Translation Vector.
Definition: lhm.h:50
lhm(Eigen::MatrixXd obj_pts_, Eigen::MatrixXd img_pts_, Eigen::MatrixXd cam_, int n0)
Number of 2d/3d correspondences.
Definition: lhm.cpp:29
Eigen::Matrix3d R
Transpose of Image points .
Definition: lhm.h:46
Eigen::Vector3d t
Rotation Matrix.
Definition: lhm.h:48
Eigen::MatrixXd cam_intrinsic
Image points in pixel co-ordinates.
Definition: lhm.h:42
bool compute_pose(Eigen::Ref< Eigen::Matrix3d > R_, Eigen::Ref< Eigen::Vector3d > t_)
Function to compute pose using LHM PnP algorithm.
Definition: lhm.cpp:194
Eigen::Matrix4d qMatQ(Eigen::VectorXd q)
Iternal Function of quaternion.
Definition: lhm.cpp:61



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 7d5e6d718 Fri Aug 24 01:51:28 2018 +0200 at lun nov 2 08:35:50 CET 2020