NDEVR
API Documentation
Sim3Solver.h
1
18
19
20#ifndef SIM3SOLVER_H
21#define SIM3SOLVER_H
22
23#include <opencv2/opencv.hpp>
24#include "Base/Headers/Buffer.hpp"
25
26#include "OrbSLAM/Headers/KeyFrame.h"
27
28
29
30namespace NDEVR
31{
32
39{
40public:
41 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
49 Sim3Solver(KeyFrame* pKF1, KeyFrame* pKF2, const Buffer<MapPoint*> &vpMatched12, const bool bFixScale = true,
50 const Buffer<KeyFrame*> vpKeyFrameMatchedMP = Buffer<KeyFrame*>());
51
57 void setRansacParameters(fltp04 probability = 0.99f, uint04 minInliers = 6 , uint04 maxIterations = 300);
58
64 Eigen::Matrix4f find(Buffer<bool> &vbInliers12, uint04& nInliers);
65
73 Eigen::Matrix4f iterate(uint04 nIterations, bool &bNoMore, Buffer<bool> &vbInliers, uint04& nInliers);
82 Eigen::Matrix4f iterate(uint04 nIterations, bool &bNoMore, Buffer<bool> &vbInliers, uint04& nInliers, bool &bConverge);
83
87 Eigen::Matrix4f GetEstimatedTransformation();
91 Eigen::Matrix3f GetEstimatedRotation();
95 Eigen::Vector3f GetEstimatedTranslation();
100
101protected:
102
103 void ComputeCentroid(Eigen::Matrix3f &P, Eigen::Matrix3f &Pr, Eigen::Vector3f &C);
104
105 void ComputeSim3(Eigen::Matrix3f &P1, Eigen::Matrix3f &P2);
106
107 void CheckInliers();
108
109 void Project(const Buffer<Eigen::Vector3f> &vP3Dw, Buffer<Eigen::Vector2f> &vP2D, Eigen::Matrix4f Tcw, GeometricCamera* pCamera);
110 void FromCameraToImage(const Buffer<Eigen::Vector3f> &vP3Dc, Buffer<Eigen::Vector2f> &vP2D, GeometricCamera* pCamera);
111
112
113protected:
114
115 // KeyFrames and matches
116 KeyFrame* mpKF1 = nullptr;
117 KeyFrame* mpKF2 = nullptr;
118
121 Buffer<MapPoint*> mvpMapPoints1;
122 Buffer<MapPoint*> mvpMapPoints2;
123 Buffer<MapPoint*> mvpMatches12;
124 Buffer<uint04> mvnIndices1;
125 Buffer<uint04> mvSigmaSquare1;
126 Buffer<uint04> mvSigmaSquare2;
127 Buffer<fltp04> mvnMaxError1;
128 Buffer<fltp04> mvnMaxError2;
129
130 uint04 N = 0;
131 uint04 mN1 = 0;
132
133 // Current Estimation
134 Eigen::Matrix3f mR12i;
135 Eigen::Vector3f mt12i;
136 float ms12i = 0.0f;
137 Eigen::Matrix4f mT12i;
138 Eigen::Matrix4f mT21i;
139 Buffer<bool> mvbInliersi;
140 uint04 mnInliersi = 0;
141
142 // Current Ransac State
143 uint04 mnIterations = 0;
144 Buffer<bool> mvbBestInliers;
145 uint04 mnBestInliers = 0;
146 Eigen::Matrix4f mBestT12;
147 Eigen::Matrix3f mBestRotation;
148 Eigen::Vector3f mBestTranslation;
149 float mBestScale = 0.0f;
150
151 // Scale is fixed to 1 in the stereo/RGBD case
152 bool mbFixScale = false;
153
154 // Indices for random selection
155 Buffer<uint04> mvAllIndices;
156
157 // Projections
160
161 // RANSAC probability
162 fltp04 mRansacProb = 0.0f;
163
164 // RANSAC min inliers
165 uint04 mRansacMinInliers = 0;
166
167 // RANSAC max iterations
168 uint04 mRansacMaxIts = 0;
169
170 // Threshold inlier/outlier. e = dist(Pi,T_ij*Pj)^2 < 5.991*mSigma2
171 float mTh = 0.0f;
172 float mSigma2 = 0.0f;
173
174 // Calibration
175 //cv::Mat mK1;
176 //cv::Mat mK2;
177
178 GeometricCamera* pCamera1 = nullptr;
179 GeometricCamera* pCamera2 = nullptr;
180
181};
182
183} //namespace ORB_SLAM
184
185#endif // SIM3SOLVER_H
The equivelent of std::vector but with a bit more control.
Definition Buffer.hpp:58
Abstract interface for geometric camera models (pinhole, fisheye, etc.).
A keyframe in the SLAM map, derived from Frame.
Definition KeyFrame.h:31
Eigen::Matrix4f iterate(uint04 nIterations, bool &bNoMore, Buffer< bool > &vbInliers, uint04 &nInliers, bool &bConverge)
Runs a fixed number of RANSAC iterations with convergence check.
EIGEN_MAKE_ALIGNED_OPERATOR_NEW Sim3Solver(KeyFrame *pKF1, KeyFrame *pKF2, const Buffer< MapPoint * > &vpMatched12, const bool bFixScale=true, const Buffer< KeyFrame * > vpKeyFrameMatchedMP=Buffer< KeyFrame * >())
Constructs the Sim3 solver.
Eigen::Matrix4f GetEstimatedTransformation()
Returns the estimated transformation matrix.
void setRansacParameters(fltp04 probability=0.99f, uint04 minInliers=6, uint04 maxIterations=300)
Sets RANSAC parameters.
Eigen::Vector3f GetEstimatedTranslation()
Returns the estimated translation vector.
Eigen::Matrix3f GetEstimatedRotation()
Returns the estimated rotation matrix.
Eigen::Matrix4f iterate(uint04 nIterations, bool &bNoMore, Buffer< bool > &vbInliers, uint04 &nInliers)
Runs a fixed number of RANSAC iterations.
float GetEstimatedScale()
Returns the estimated scale factor.
Eigen::Matrix4f find(Buffer< bool > &vbInliers12, uint04 &nInliers)
Finds the best Sim3 transformation using RANSAC.
The primary namespace for the NDEVR SDK.
float fltp04
Defines an alias representing a 4 byte floating-point number Bit layout is as follows: -Sign: 1 bit a...
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...