Sim3Solver.h
Go to the documentation of this file.
1 
22 #ifndef SIM3SOLVER_H
23 #define SIM3SOLVER_H
24 
25 #include <opencv2/opencv.hpp>
26 #include <opencv2/core/core_c.h>
27 #include <vector>
28 
29 #include "KeyFrame.h"
30 
31 
32 
33 namespace ORB_SLAM2
34 {
35 
37 {
38 public:
39 
40  Sim3Solver(KeyFrame* pKF1, KeyFrame* pKF2, const std::vector<MapPoint*> &vpMatched12, const bool bFixScale = true);
41 
42  void SetRansacParameters(double probability = 0.99, int minInliers = 6 , int maxIterations = 300);
43 
44  cv::Mat find(std::vector<bool> &vbInliers12, int &nInliers);
45 
46  cv::Mat iterate(int nIterations, bool &bNoMore, std::vector<bool> &vbInliers, int &nInliers);
47 
48  cv::Mat GetEstimatedRotation();
49  cv::Mat GetEstimatedTranslation();
50  float GetEstimatedScale();
51 
52 
53 protected:
54 
55  void ComputeCentroid(cv::Mat &P, cv::Mat &Pr, cv::Mat &C);
56 
57  void ComputeSim3(cv::Mat &P1, cv::Mat &P2);
58 
59  void CheckInliers();
60 
61  void Project(const std::vector<cv::Mat> &vP3Dw, std::vector<cv::Mat> &vP2D, cv::Mat Tcw, cv::Mat K);
62  void FromCameraToImage(const std::vector<cv::Mat> &vP3Dc, std::vector<cv::Mat> &vP2D, cv::Mat K);
63 
64 
65 protected:
66 
67  // KeyFrames and matches
70 
71  std::vector<cv::Mat> mvX3Dc1;
72  std::vector<cv::Mat> mvX3Dc2;
73  std::vector<MapPoint*> mvpMapPoints1;
74  std::vector<MapPoint*> mvpMapPoints2;
75  std::vector<MapPoint*> mvpMatches12;
76  std::vector<size_t> mvnIndices1;
77  std::vector<size_t> mvSigmaSquare1;
78  std::vector<size_t> mvSigmaSquare2;
79  std::vector<size_t> mvnMaxError1;
80  std::vector<size_t> mvnMaxError2;
81 
82  int N;
83  int mN1;
84 
85  // Current Estimation
86  cv::Mat mR12i;
87  cv::Mat mt12i;
88  float ms12i;
89  cv::Mat mT12i;
90  cv::Mat mT21i;
91  std::vector<bool> mvbInliersi;
93 
94  // Current Ransac State
96  std::vector<bool> mvbBestInliers;
98  cv::Mat mBestT12;
99  cv::Mat mBestRotation;
101  float mBestScale;
102 
103  // Scale is fixed to 1 in the stereo/RGBD case
105 
106  // Indices for random selection
107  std::vector<size_t> mvAllIndices;
108 
109  // Projections
110  std::vector<cv::Mat> mvP1im1;
111  std::vector<cv::Mat> mvP2im2;
112 
113  // RANSAC probability
114  double mRansacProb;
115 
116  // RANSAC min inliers
118 
119  // RANSAC max iterations
121 
122  // Threshold inlier/outlier. e = dist(Pi,T_ij*Pj)^2 < 5.991*mSigma2
123  float mTh;
124  float mSigma2;
125 
126  // Calibration
127  cv::Mat mK1;
128  cv::Mat mK2;
129 
130 };
131 
132 } //namespace ORB_SLAM
133 
134 #endif // SIM3SOLVER_H
std::vector< size_t > mvnMaxError2
Definition: Sim3Solver.h:80
std::vector< cv::Mat > mvP2im2
Definition: Sim3Solver.h:111
cv::Mat find(std::vector< bool > &vbInliers12, int &nInliers)
Definition: Sim3Solver.cc:209
std::vector< cv::Mat > mvX3Dc1
Definition: Sim3Solver.h:71
cv::Mat iterate(int nIterations, bool &bNoMore, std::vector< bool > &vbInliers, int &nInliers)
Definition: Sim3Solver.cc:140
std::vector< size_t > mvSigmaSquare1
Definition: Sim3Solver.h:77
void Project(const std::vector< cv::Mat > &vP3Dw, std::vector< cv::Mat > &vP2D, cv::Mat Tcw, cv::Mat K)
Definition: Sim3Solver.cc:382
std::vector< size_t > mvnMaxError1
Definition: Sim3Solver.h:79
void ComputeSim3(cv::Mat &P1, cv::Mat &P2)
Definition: Sim3Solver.cc:226
std::vector< MapPoint * > mvpMatches12
Definition: Sim3Solver.h:75
std::vector< size_t > mvSigmaSquare2
Definition: Sim3Solver.h:78
std::vector< cv::Mat > mvP1im1
Definition: Sim3Solver.h:110
cv::Mat GetEstimatedRotation()
Definition: Sim3Solver.cc:367
Sim3Solver(KeyFrame *pKF1, KeyFrame *pKF2, const std::vector< MapPoint * > &vpMatched12, const bool bFixScale=true)
Definition: Sim3Solver.cc:37
std::vector< bool > mvbInliersi
Definition: Sim3Solver.h:91
void FromCameraToImage(const std::vector< cv::Mat > &vP3Dc, std::vector< cv::Mat > &vP2D, cv::Mat K)
Definition: Sim3Solver.cc:405
std::vector< MapPoint * > mvpMapPoints2
Definition: Sim3Solver.h:74
void ComputeCentroid(cv::Mat &P, cv::Mat &Pr, cv::Mat &C)
Definition: Sim3Solver.cc:215
void SetRansacParameters(double probability=0.99, int minInliers=6, int maxIterations=300)
Definition: Sim3Solver.cc:114
std::vector< MapPoint * > mvpMapPoints1
Definition: Sim3Solver.h:73
std::vector< cv::Mat > mvX3Dc2
Definition: Sim3Solver.h:72
std::vector< size_t > mvnIndices1
Definition: Sim3Solver.h:76
std::vector< size_t > mvAllIndices
Definition: Sim3Solver.h:107
std::vector< bool > mvbBestInliers
Definition: Sim3Solver.h:96
cv::Mat GetEstimatedTranslation()
Definition: Sim3Solver.cc:372


orb_slam2_ros
Author(s):
autogenerated on Wed Apr 21 2021 02:53:05