高博十四讲中第六章非线性优化 由于g2o更新出现的问题解决
在高博视觉slam十四讲中的第6讲中实践g2o中出现了编译错误:
/home/yk/桌面/slambook-master/ch6/g2o_curve_fitting/main.cpp: In function ‘int main(int, char**)’:
/home/yk/桌面/slambook-master/ch6/g2o_curve_fitting/main.cpp:77:49: error: no matching function for call to ‘g2o::BlockSolver<g2o::BlockSolverTraits<3, 1> >::BlockSolver(g2o::BlockSolver<g2o::BlockSolverTraits<3, 1> >::LinearSolverType*&)’Block* solver_ptr = new Block( linearSolver ); // 矩阵块求解器^
In file included from /usr/local/include/g2o/core/block_solver.h:199:0,from /home/yk/桌面/slambook-master/ch6/g2o_curve_fitting/main.cpp:4:
/usr/local/include/g2o/core/block_solver.hpp:40:1: note: candidate: g2o::BlockSolver<Traits>::BlockSolver(std::unique_ptr<typename Traits::LinearSolverType>) [with Traits = g2o::BlockSolverTraits<3, 1>; typename Traits::LinearSolverType = g2o::LinearSolver<Eigen::Matrix<double, 3, 3> >]BlockSolver<Traits>::BlockSolver(std::unique_ptr<LinearSolverType> linearSolver^
/usr/local/include/g2o/core/block_solver.hpp:40:1: note: no known conversion for argument 1 from ‘g2o::BlockSolver<g2o::BlockSolverTraits<3, 1> >::LinearSolverType* {aka g2o::LinearSolver<Eigen::Matrix<double, 3, 3> >*}’ to ‘std::unique_ptr<g2o::LinearSolver<Eigen::Matrix<double, 3, 3> >, std::default_delete<g2o::LinearSolver<Eigen::Matrix<double, 3, 3> > > >’
/home/yk/桌面/slambook-master/ch6/g2o_curve_fitting/main.cpp:79:103: error: no matching function for call to ‘g2o::OptimizationAlgorithmLevenberg::OptimizationAlgorithmLevenberg(Block*&)’rithmLevenberg* solver = new g2o::OptimizationAlgorithmLevenberg( solver_ptr );^
In file included from /home/yk/桌面/slambook-master/ch6/g2o_curve_fitting/main.cpp:5:0:
/usr/local/include/g2o/core/optimization_algorithm_levenberg.h:47:16: note: candidate: g2o::OptimizationAlgorithmLevenberg::OptimizationAlgorithmLevenberg(std::unique_ptr<g2o::Solver>)explicit OptimizationAlgorithmLevenberg(std::unique_ptr<Solver> solver);^
/usr/local/include/g2o/core/optimization_algorithm_levenberg.h:47:16: note: no known conversion for argument 1 from ‘Block* {aka g2o::BlockSolver<g2o::BlockSolverTraits<3, 1> >*}’ to ‘std::unique_ptr<g2o::Solver>’
CMakeFiles/curve_fitting.dir/build.make:62: recipe for target 'CMakeFiles/curve_fitting.dir/main.cpp.o' failed
make[2]: *** [CMakeFiles/curve_fitting.dir/main.cpp.o] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/curve_fitting.dir/all' failed
make[1]: *** [CMakeFiles/curve_fitting.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
通过查找百度查询,看到一篇博客展现了也是在编译高博视觉slam十四讲g2o环节出现问题的解决方案,(转载于->)https://blog.csdn.net/weixin_38358435/article/details/79082733模仿这位作者的解决过程,修改了我的代码。
typedef g2o::BlockSolver<g2o::BlockSolverTraits<3,1> > Block; // 每个误差项优化变量维度为3,误差值维度为1
std::unique_ptr<Block::LinearSolverType> linearSolver ( new g2o::LinearSolverDense<Block::PoseMatrixType>());
//Block::LinearSolverType* linearSolver = new g2o::LinearSolverDense<Block::PoseMatrixType>(); // 线性方程求解器
std::unique_ptr<Block> 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 );
然后就编译成功了。
g2o安装步骤:
1.看14讲安装。
github下载包。
按照书中安装依赖项。(会出现libcholmod-dev文件找不到:可能由于版本不同吧,所以安装这个依赖项的时候,建议这样做:输入sudo apt-get install libcholmod然后按Tab键,Tab键就是自动补充命令,当你记不住完整命令的时候,你按下它,他会自动搜索!我在这里出来的是libcholmod2.1.2,然后安装就好!接着在输入:sudo apt-get install libqt4-dev qt4-qmake libqglviewer-dev libsuitesaprse-dev libcxsparse3.1.2) 原文:https://blog.csdn.net/hitfangyu/article/details/72665455
再之后的话,建议去github上面下载源码https://github.com/RainerKuemmerle/g2o
将压缩的文件解压,然后到文件目录下,
mkdir build
cd build
cmake …
make
sudo make install
高博十四讲中第六章非线性优化 由于g2o更新出现的问题解决相关推荐
- slam十四讲之第六讲带你看懂g2o
slam十四讲之第六讲g2oCurveFitting代码 #include <iostream> #include <g2o/core/g2o_core_api.h> #inc ...
- 《视觉SLAM十四讲》-第三章第3节第4节-欧拉角、四元数-学习笔记总结
- 《视觉SLAM十四讲》-第三章第3节公式推导-旋转向量-欧拉角--罗德里格斯公式详细推导
- 【SLAM十四讲】ch11 回环检测 词袋法实验 得出相似分数后计算PR曲线 VPR实验 编辑中
[SLAM十四讲]ch11 回环检测 词袋法实验 得出相似分数后计算PR曲线 [SLAM十四讲]ch11 回环检测 词袋法实验 得出相似分数后计算PR曲线 DBow3库安装 ch11编译 ch11 词 ...
- slam十四讲,第五讲中相机坐标系,像素平面坐标系,世界坐标系,归一化坐标系总结
#笔记,方便日后忘记回看,仅总结,具体推导回看十四讲 先上图: 如图,现实世界中有一个P点和一个相机(光心),描述这个P点的空间坐标首先得有一个坐标系,那么以光心为原点O建一个坐标系,叫相机坐标系. ...
- Ubuntu20/视觉SLAM十四讲踩坑记录
Ubuntu/视觉SLAM十四讲踩坑记录 Ubuntu(20)/视觉SLAM十四讲踩坑记录: 共性问题: 1.安装OpenCV后,例程仍无法找到OpenCV文件 ch3 visualizeGeomet ...
- 视觉SLAM十四讲(第二版)环境安装心得体会
前言 将高博的视觉SLAM14讲(第二版)看完后,也将里面所有的代码都跑了一遍,在安装环境的时候遇到了无数的坑.为了后来的人能够更加快速上手SLAM,现将书中环境安装心得记录如下. 环境安装 1. 安 ...
- 《视觉SLAM十四讲》第二版源码slambook2编译调试
slambook2-master/ch2 编译正常,log如下: slambook2-master/ch2# mkdir build && cd build && cm ...
- 视觉SLAM十四讲——ch7
视觉SLAM十四讲--ch7 ch7视觉里程计 本章目标: 1.理解图像特征点的意义,并掌握在单副图像中提取出特征点及多副图像中匹配特征点的方法 2.理解对极几何的原理,利用对极几何的约束,恢复出图像 ...
最新文章
- Django web框架学习笔记
- boost::geometry::compress_variant用法的测试程序
- 如何使用Java创建AWS Lambda函数
- Linux下性能测量和调试诊断工具Systemtap
- js table多层嵌套_只会console.log?8个高效调试js的console方法
- 怎样判断一个领导是否值得追随呢?
- iOS【面试】2018年面试题集锦
- SSM汽车租赁管理系统毕业设计源码052158
- 【C++】给定两个没有刻度的容器,对于任意给定的容积,求出如何只用两个瓶装出L升的水
- 多省市区“十四五”规划布局交通新基建
- NetKeeper720,能上QQ不能上网
- Exploratory Social Network Analysis with Pajek(第三版)8
- 【灵修】人不迷失方向一定是心中有了目标(转)
- 游戏音效设计师的限制
- 68.168.16.153 forum index.php,Discuz1314首页版块N格 带数据缓存功能(study_forum_nge)_Discuz应用中心...
- C语言讲义——开发工具Dev C++
- matlab逐步回归结果分析,matlab中的逐步回归.doc
- 地产“罗生门”:是世茂“不讲武德”,还是福晟“谎话连篇”?
- 电信黑莓手机出国漫游注意事项
- 简约蓝绿岗位竞聘PPT模板