MRPT  1.9.9
posit.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 #include <mrpt/math/types_math.h> // Eigen must be included first via MRPT to enable the plugin system
11 #include <Eigen/Dense>
12 #include <Eigen/SVD>
13 
14 #include <iostream>
15 
16 #define LOOP_MAX_COUNT 30
17 
18 namespace mrpt::vision::pnp
19 {
20 /** \addtogroup pnp Perspective-n-Point pose estimation
21  * \ingroup mrpt_vision_grp
22  * @{
23  */
24 
25 /**
26  * @class POSIT
27  * @author Chandra Mangipudi
28  * @date 10/08/16
29  * @file posit.h
30  * @brief Pose from Orthogonality and Scaling (POSIT) - Eigen Implementation
31  */
32 class posit
33 {
34  Eigen::MatrixXd obj_pts; //! Object Points in Camera Co-ordinate system
35  Eigen::MatrixXd img_pts; //! Image Points in pixels
36  Eigen::MatrixXd cam_intrinsic; //! Camera Intrinsic matrix
37  Eigen::MatrixXd obj_matrix; //! Pseudo-Inverse of Object Points matrix
38 
39  double f; //! Focal Length from camera intrinsic matrix
40  Eigen::VectorXd epsilons; //! Co-efficients used for scaling
41  int n; //! Number of 2d/3d correspondences
42 
43  Eigen::MatrixXd R; //! Rotation Matrix
44  Eigen::VectorXd t; //! Translation Vector
45 
46  Eigen::MatrixXd obj_vecs; //! Object Points relative to 1st object point
47  Eigen::MatrixXd img_vecs; //! Image Points relative to 1st image point
48  Eigen::MatrixXd
49  img_vecs_old; //! Used to store img_vecs from previous iteration
50 
51  public:
52  //! Constructor for P-PnP class
53  posit(
54  Eigen::MatrixXd obj_pts_, Eigen::MatrixXd img_pts_,
55  Eigen::MatrixXd camera_intrinsic_, int n);
56 
57  /**
58  * @brief Function used to compute pose from orthogonality
59  */
60  void POS();
61 
62  /**
63  * @brief Computes pose using iterative computation of @func POS()
64  * @param[out] R_
65  * @param[out] t_
66  * @return true on success
67  */
68  bool compute_pose(
69  Eigen::Ref<Eigen::Matrix3d> R_, Eigen::Ref<Eigen::Vector3d> t_);
70 
71  /**
72  * @brief Function to check for convergence
73  * @return Representative value of error
74  */
75  long get_img_diff();
76 };
77 
78 /** @} */ // end of grouping
79 }
80 
Eigen::MatrixXd obj_pts
Definition: posit.h:34
bool compute_pose(Eigen::Ref< Eigen::Matrix3d > R_, Eigen::Ref< Eigen::Vector3d > t_)
Computes pose using iterative computation of POS()
Definition: posit.cpp:84
Perspective n Point (PnP) Algorithms toolkit for MRPT mrpt_vision_grp.
Definition: pnp_algos.h:23
GLenum GLsizei n
Definition: glext.h:5074
Eigen::VectorXd epsilons
Focal Length from camera intrinsic matrix.
Definition: posit.h:40
Eigen::MatrixXd obj_vecs
Translation Vector.
Definition: posit.h:46
Eigen::MatrixXd R
Number of 2d/3d correspondences.
Definition: posit.h:43
int n
Co-efficients used for scaling.
Definition: posit.h:41
Eigen::VectorXd t
Rotation Matrix.
Definition: posit.h:44
posit(Eigen::MatrixXd obj_pts_, Eigen::MatrixXd img_pts_, Eigen::MatrixXd camera_intrinsic_, int n)
Used to store img_vecs from previous iteration.
Definition: posit.cpp:18
Eigen::MatrixXd img_pts
Object Points in Camera Co-ordinate system.
Definition: posit.h:35
long get_img_diff()
Function to check for convergence.
Definition: posit.cpp:139
Eigen::MatrixXd img_vecs
Object Points relative to 1st object point.
Definition: posit.h:47
double f
Pseudo-Inverse of Object Points matrix.
Definition: posit.h:39
Eigen::MatrixXd obj_matrix
Camera Intrinsic matrix.
Definition: posit.h:37
Eigen::MatrixXd cam_intrinsic
Image Points in pixels.
Definition: posit.h:36
Eigen::MatrixXd img_vecs_old
Image Points relative to 1st image point.
Definition: posit.h:49
void POS()
Function used to compute pose from orthogonality.
Definition: posit.cpp:45



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