0.3版本的VO就是在0.2的基础上增加了g2o优化:
1、在visual_odometry.cpp中的poseEstimationPNP()函数中,用PNP求出T_c_r_estimated_后,增加了g2o优化,对位姿进行优化。
2、同时增加的还有g2o相关的头文件和源文件:g2o_types.h和g2o_types.cpp
visual_odometry.cpp
//使用BA优化估计的位姿T
//1. 位姿6维,观测点2维
typedef g2o::BlockSolver<g2o::BlockSolverTraits<6,2>> Block;
Block::LinearSolverType* linearSolver = new g2o::LinearSolverDense<Block::PoseMatrixType>();
Block* solver_ptr = new Block( linearSolver );
g2o::OptimizationAlgorithmLevenberg* solver = new g2o::OptimizationAlgorithmLevenberg ( solver_ptr );
g2o::SparseOptimizer optimizer;
optimizer.setAlgorithm ( solver );
//2. 顶点是相机位姿pose
g2o::VertexSE3Expmap* pose = new g2o::VertexSE3Expmap();
pose->setId ( 0 );
pose->setEstimate ( g2o::SE3Quat (
T_c_r_estimated_.rotation_matrix(),
T_c_