svo
Semi-Direct Visual Odometry
include/svo/bundle_adjustment.h
Go to the documentation of this file.
00001 // This file is part of SVO - Semi-direct Visual Odometry.
00002 //
00003 // Copyright (C) 2014 Christian Forster <forster at ifi dot uzh dot ch>
00004 // (Robotics and Perception Group, University of Zurich, Switzerland).
00005 //
00006 // SVO is free software: you can redistribute it and/or modify it under the
00007 // terms of the GNU General Public License as published by the Free Software
00008 // Foundation, either version 3 of the License, or any later version.
00009 //
00010 // SVO is distributed in the hope that it will be useful, but WITHOUT ANY
00011 // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00012 // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
00013 //
00014 // You should have received a copy of the GNU General Public License
00015 // along with this program.  If not, see <http://www.gnu.org/licenses/>.
00016 
00017 #ifndef SVO_BUNDLE_ADJUSTMENT_H_
00018 #define SVO_BUNDLE_ADJUSTMENT_H_
00019 
00020 #include <svo/global.h>
00021 
00022 namespace g2o {
00023 class EdgeProjectXYZ2UV;
00024 class SparseOptimizer;
00025 class VertexSE3Expmap;
00026 class VertexSBAPointXYZ;
00027 }
00028 
00029 namespace svo {
00030 
00031 typedef g2o::EdgeProjectXYZ2UV g2oEdgeSE3;
00032 typedef g2o::VertexSE3Expmap g2oFrameSE3;
00033 typedef g2o::VertexSBAPointXYZ g2oPoint;
00034 
00035 class Frame;
00036 class Point;
00037 class Feature;
00038 class Map;
00039 
00041 namespace ba {
00042 
00044 struct EdgeContainerSE3
00045 {
00046   g2oEdgeSE3*     edge;
00047   Frame*          frame;
00048   Feature*        feature;
00049   bool            is_deleted;
00050   EdgeContainerSE3(g2oEdgeSE3* e, Frame* frame, Feature* feature) :
00051     edge(e), frame(frame), feature(feature), is_deleted(false)
00052   {}
00053 };
00054 
00057 void twoViewBA(Frame* frame1, Frame* frame2, double reproj_thresh, Map* map);
00058 
00062 void localBA(
00063     Frame* center_kf,
00064     set<FramePtr>* core_kfs,
00065     Map* map,
00066     size_t& n_incorrect_edges_1,
00067     size_t& n_incorrect_edges_2,
00068     double& init_error,
00069     double& final_error);
00070 
00073 void globalBA(Map* map);
00074 
00076 void setupG2o(g2o::SparseOptimizer * optimizer);
00077 
00079 void runSparseBAOptimizer(
00080     g2o::SparseOptimizer* optimizer,
00081     unsigned int num_iter,
00082     double& init_error,
00083     double& final_error);
00084 
00086 g2oFrameSE3* createG2oFrameSE3(
00087     Frame* kf,
00088     size_t id,
00089     bool fixed);
00090 
00092 g2oPoint* createG2oPoint(
00093     Vector3d pos,
00094     size_t id,
00095     bool fixed);
00096 
00098 g2oEdgeSE3* createG2oEdgeSE3(
00099     g2oFrameSE3* v_kf,
00100     g2oPoint* v_mp,
00101     const Vector2d& f_up,
00102     bool robust_kernel,
00103     double huber_width,
00104     double weight = 1);
00105 
00106 } // namespace ba
00107 } // namespace svo
00108 
00109 #endif // SVO_BUNDLE_ADJUSTMENT_H_
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines