34 #ifndef GSLAM_CORE_OPTIMIZER_H_ 35 #define GSLAM_CORE_OPTIMIZER_H_ 42 #define GSLAM_REGISTER_OPTIMIZER(OPT_CLASS) \ 43 extern "C" std::shared_ptr<GSLAM::Optimizer> createOptimizerInstance() { \ 44 return std::shared_ptr<GSLAM::Optimizer>(new OPT_CLASS()); \ 46 class OPT_CLASS##_Register { \ 48 OPT_CLASS##_Register() { \ 49 GSLAM::Optimizer::buildin()=createOptimizerInstance; \ 51 } OPT_CLASS##_Register_instance; 56 typedef std::shared_ptr<Optimizer> (*funcCreateOptimizerInstance)();
58 enum CameraProjectionType {
63 enum InvDepthEstimationDOF {
67 UPDATE_ID_IDEPTHSIGMA = UPDATE_ID_IDEPTH | UPDATE_ID_SIGMA
70 enum KeyFrameEstimzationDOF {
79 UPDATE_KF_TRANSLATION = UPDATE_KF_X | UPDATE_KF_Y | UPDATE_KF_Z,
80 UPDATE_KF_XYZ = UPDATE_KF_TRANSLATION,
81 UPDATE_KF_ROTATION = UPDATE_KF_RX | UPDATE_KF_RY | UPDATE_KF_RZ,
82 UPDATE_KF_SE3 = UPDATE_KF_TRANSLATION | UPDATE_KF_ROTATION,
83 UPDATE_KF_SIM3 = UPDATE_KF_SE3 | UPDATE_KF_SCALE
86 enum CameraEstimationDOF {
87 UPDATE_CAMERA_NONE = 0,
88 UPDATE_CAMERA_FOCAL = 1,
89 UPDATE_CAMERA_CENTER = 2,
92 UPDATE_CAMERA_P1 = 16,
93 UPDATE_CAMERA_P2 = 32,
94 UPDATE_CAMERA_K3 = 64,
95 UPDATE_CAMERA_K = UPDATE_CAMERA_K1 | UPDATE_CAMERA_K2 | UPDATE_CAMERA_K3,
96 UPDATE_CAMERA_P = UPDATE_CAMERA_P1 | UPDATE_CAMERA_P2,
97 UPDATE_CAMERA_KP = UPDATE_CAMERA_K | UPDATE_CAMERA_P,
98 UPDATE_CAMERA_PINHOLE = UPDATE_CAMERA_FOCAL | UPDATE_CAMERA_CENTER,
99 UPDATE_CAMERA_FISHEYE = UPDATE_CAMERA_PINHOLE | UPDATE_CAMERA_KP
107 GSLAM::PointID frameId;
109 IdepthEstimation estimation;
110 InvDepthEstimationDOF dof;
113 typedef std::pair<GSLAM::Point3d, bool>
118 KeyFrameEstimzationDOF dof;
122 GSLAM::FrameID pointId, frameId;
123 CameraAnchor measurement;
130 GSLAM::FrameID firstId, secondId;
139 GSLAM::FrameID firstId, secondId;
145 GSLAM::FrameID frameId;
152 std::vector<InvDepthEstimation>
154 std::vector<MapPointEstimation>
156 std::vector<KeyFrameEstimzation>
160 std::vector<BundleEdge> invDepthObserves,
164 std::vector<SIM3Edge>
171 CameraEstimationDOF cameraDOF;
175 CameraProjectionType cameraProjectionType = PROJECTION_PINHOLE;
177 double projectErrorHuberThreshold = 0.01;
179 int maxIterations = 500;
181 bool verbose =
false;
193 virtual bool optimizePose(
194 std::vector<std::pair<CameraAnchor, CameraAnchor> >& matches,
195 std::vector<IdepthEstimation>& firstIDepth,
197 KeyFrameEstimzationDOF dof = UPDATE_KF_SE3,
double* information = NULL) {
202 virtual bool optimizePnP(
203 const std::vector<std::pair<GSLAM::Point3d, CameraAnchor> >& matches,
204 GSLAM::SE3& pose, KeyFrameEstimzationDOF dof = UPDATE_KF_SE3,
205 double* information = NULL) {
210 virtual bool optimizeICP(
211 const std::vector<std::pair<GSLAM::Point3d, GSLAM::Point3d> >&
214 KeyFrameEstimzationDOF dof = UPDATE_KF_SE3,
215 double* information = NULL) {
220 virtual bool fitSim3(
221 const std::vector<std::pair<GSLAM::SE3, GSLAM::SE3> >& matches,
222 GSLAM::SIM3& sim3, KeyFrameEstimzationDOF dof = UPDATE_KF_SIM3,
223 double* information = NULL) {
229 virtual bool optimize(
BundleGraph& graph) {
return false; }
234 static std::shared_ptr<Optimizer> create(std::string pluginName =
"") {
235 if (pluginName.empty()) {
236 if (buildin())
return buildin()();
237 pluginName = svar.GetString(
"OptimizerPlugin",
"libgslam_optimizer");
239 std::shared_ptr<SharedLibrary> plugin = Registry::get(pluginName);
240 if (!plugin)
return std::shared_ptr<Optimizer>();
241 funcCreateOptimizerInstance createFunc =
242 (funcCreateOptimizerInstance)plugin->getSymbol(
243 "createOptimizerInstance");
245 return std::shared_ptr<Optimizer>();
250 static funcCreateOptimizerInstance& buildin(){
static funcCreateOptimizerInstance v=
nullptr;
return v;}
255 typedef std::shared_ptr<Optimizer> OptimizerPtr;
258 #endif // GSLAM_CORE_OPTIMIZER_H_ Definition: Optimizer.h:116
Definition: Optimizer.h:150
Definition: Optimizer.h:121
Definition: Optimizer.h:174
Definition: Optimizer.h:144
Definition: Optimizer.h:129
Definition: Optimizer.h:138
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
Definition: Optimizer.h:106
Definition: Optimizer.h:184