33 #ifndef GSLAM_CORE_ESTIMATOR_H_ 34 #define GSLAM_CORE_ESTIMATOR_H_ 38 #include "GSLAM/core/SIM3.h" 39 #include "GSLAM/core/Svar.h" 40 #include "GSLAM/core/Registry.h" 42 #define USE_ESTIMATOR_PLUGIN(EST_CLASS) \ 43 extern "C" GSLAM::Estimator* createEstimatorInstance() { \ 44 return new EST_CLASS(); \ 46 class EST_CLASS##_Register { \ 48 EST_CLASS##_Register() { \ 49 GSLAM::Estimator::buildinEstimators()\ 50 .Set<funcCreateEstimatorInstance>\ 51 ("Default",createEstimatorInstance); \ 53 } EST_CLASS##_Register_instance; 58 typedef std::shared_ptr<Estimator> EstimatorPtr;
59 typedef Estimator* (*funcCreateEstimatorInstance)();
60 typedef Matrix3d Homography2D;
61 typedef Matrix<double,2,3> Affine2D;
62 typedef Matrix3d Fundamental;
63 typedef Fundamental Essential;
64 typedef Matrix<double,3,4> Affine3D;
65 typedef unsigned char uchar;
67 enum EstimatorMethod {
98 virtual std::string type()
const {
return "Estimator"; }
101 virtual bool findHomography(Homography2D* H,
102 const std::vector<Point2d>& srcPoints,
103 const std::vector<Point2d>& dstPoints,
104 int method = H4_Point&RANSAC,
105 double threshold = 3,
106 double confidence = 0.99,
107 std::vector<uchar>* mask = NULL)
const = 0;
109 virtual bool findAffine2D(Affine2D* A,
110 const std::vector<Point2d>& srcPoints,
111 const std::vector<Point2d>& dstPoints,
112 int method = A3_Point&RANSAC,
113 double threshold = 3,
114 double confidence = 0.99,
115 std::vector<uchar>* mask = NULL)
const =0;
117 virtual bool findFundamental(Fundamental* F,
118 const std::vector<Point2d>& points1,
119 const std::vector<Point2d>& points2,
120 int method = F8_Point&RANSAC,
121 double threshold = 3.,
122 double confidence = 0.99,
123 std::vector<uchar>* mask = NULL)
const = 0;
125 virtual bool findEssentialMatrix(Essential* E,
126 const std::vector<Point2d>& points1,
127 const std::vector<Point2d>& points2,
128 int method = E5_Nister&RANSAC,
129 double threshold = 0.01,
130 double confidence = 0.99,
131 std::vector<uchar>* mask = NULL)
const = 0;
134 virtual bool findSIM3(
SIM3* S,
135 const std::vector<Point3d>& from,
136 const std::vector<Point3d>& to,
137 int method = S3_Horn&RANSAC,
138 double threshold = 0.01,
139 double confidence = 0.99,
140 std::vector<uchar>* mask = NULL)
const = 0;
142 virtual bool findAffine3D(Affine3D* A,
143 const std::vector<Point3d>& src,
144 const std::vector<Point3d>& dst,
145 int method = A4_Point&RANSAC,
146 double threshold = 0.01,
147 double confidence = 0.99,
148 std::vector<uchar>* mask = NULL)
const = 0;
150 virtual bool findPlane(
SE3* plane,
151 const std::vector<Point3d>& points,
152 int method = P3_Plane&RANSAC,
153 double threshold = 0.01,
154 double confidence = 0.99,
155 std::vector<uchar>* mask = NULL)
const = 0;
158 virtual bool findPnP(
SE3* world2camera,
159 const std::vector<Point3d>& objectPoints,
160 const std::vector<Point2d>& imagePoints,
161 int method = P3_ITERATIVE&RANSAC,
162 double threshold = 0.01,
163 double confidence = 0.99,
164 std::vector<uchar>* mask = NULL)
const = 0;
166 virtual bool trianglate(
Point3d* refPt,
169 const Point3d& curDirection)
const = 0;
171 static Svar& buildinEstimators(){
175 static EstimatorPtr create(std::string pluginName =
"") {
176 funcCreateEstimatorInstance createFunc =buildinEstimators()
177 .Get<funcCreateEstimatorInstance>(
"Default",NULL);
178 if (createFunc)
return EstimatorPtr(createFunc());
180 if (pluginName.empty()) {
181 pluginName = svar.GetString(
"EstimatorPlugin",
"libgslam_estimator");
183 SharedLibraryPtr plugin = Registry::get(pluginName);
184 if (!plugin)
return EstimatorPtr();
185 createFunc = (funcCreateEstimatorInstance)plugin->getSymbol(
186 "createEstimatorInstance");
188 return EstimatorPtr();
190 return EstimatorPtr(createFunc());
194 #endif // GSLAM_CORE_ESTIMATOR_H_ static Svar object(const std::map< std::string, Svar > &m={})
Create an Object instance.
Definition: Svar.h:632
Definition: Estimator.h:92
The Svar class, A Tiny Modern C++ Header Brings Unified Interface for Different Languages.
Definition: Svar.h:561
Represent a three-dimensional similarity transformation,7 degrees of freedom a rotation: R (Here is r...
Definition: SIM3.h:57
Represent a three-dimensional Euclidean transformation (a rotation and a translation).
Definition: SE3.h:69