关于高博十四讲中由于g2o更新出现的问题解决

   在高博视觉slam十四讲中的第6讲中实践g2o中出现了编译错误。
/home/ze/am/slambook-master/ch6/g2o_curve_fitting/main.cpp:77:49: error: no matching function for call to ‘g2o::BlockSolver >::BlockSolver(g2o::BlockSolver >::LinearSolverType*&)’
     Block* solver_ptr = new Block( linearSolver );      // 矩阵块求解器

   通过查找百度查询,看到一篇博客展现了也是在编译高博视觉slam十四讲g2o环节出现问题的解决方案,http://blog.csdn.net/robinhjwy/article/details/78084210模仿这位作者的解决过程,修改了我的代码,

typedef g2o::BlockSolver > Block;  // 每个误差项优化变量维度为3,误差值维度为1
std::unique_ptr linearSolver ( new g2o::LinearSolverDense());
//Block::LinearSolverType* linearSolver = new g2o::LinearSolverDense(); // 线性方程求解器
std::unique_ptr solver_ptr ( new Block ( std::move(linearSolver))); 
//Block* solver_ptr = new Block( linearSolver );      // 矩阵块求解器
// 梯度下降方法,从GN, LM, DogLeg 中选
g2o::OptimizationAlgorithmLevenberg* solver = new g2o::OptimizationAlgorithmLevenberg ( std::move(solver_ptr));
//g2o::OptimizationAlgorithmLevenberg* solver = new g2o::OptimizationAlgorithmLevenberg( solver_ptr );


然后就编译成功了。

/home/ze/slam/slambook-master/ch6/g2o_curve_fitting/build> make -j4
[100%] Built target curve_fitting
*** Finished ***








你可能感兴趣的:(十四讲学习过程)