视觉SLAM十四讲第二版实践操作问题汇总(更新中…)
Ubuntu系统版本为 18.04,IDE为CLion2019.3
-
第3讲
问题:
plotTrajectory.cpp文件中报错“cannot find trajectory file at ./examples/trajectory.txt”。因为CLion默认会在工程目录下创建cmake-build-debug文件夹用来存放中间文件。
解决:
string trajectory_file = "./examples/trajectory.txt"
修改为string trajectory_file = "../trajectory.txt"
-
第4讲
1.模板类Sophus库
问题:
useSophus.cpp文件中,#include "sophus/se3.hpp"
出现红色下划波浪线提示:“sophus/se3.hpp: 没有那个文件或目录”,也即是说find_package命令并没有找到该库文件,在/usr/local/include下也没有找到sophus文件夹。
解决:
编译后安装Sophus库解决该问题。
cd Sophus
mkdir build
cd build
cmake ..
make
sudo make install
2.文件路径
问题:
./example/groundtruth.txt not found.
./example/estimated.txt not found.
解决:
trajectoryError.cpp文件中修改string groundtruth_file = "./example/groundtruth.txt"
为string groundtruth_file = "../../example/groundtruth.txt"
;
修改string estimated_file = "./example/estimated.txt"
为string estimated_file = "../../example/estimated.txt"
- 第5讲
本人安装的是opencv-3.4.3,提取码:1r0z
1.源码编译
问题:
源码编译opencv卡在IPPICV: Download: ippicv_2017u3_lnx_intel64_general_20180518.tgz
解决:
手动下载ippicv_2017u3_lnx_intel64_general_20180518.tgz,提取码:i3so
修改opencv里相关配置文件,打开终端,输入
gedit /home/chenlin/opencv-3.4.3/3rdparty/ippicv/ippicv.cmake #记得chenlin换成自己的用户名
将47行的
"https://raw.githubusercontent.com/opencv/opencv_3rdparty/${IPPICV_COMMIT}/ippicv/"
改为手动下载的ippicv_2017u3_lnx_intel64_general_20180518.tgz文件的本地路径:
"file:///home/chenlin/opencv-3.4.3/3rdparty/ippicv/" (根据自己的实际路径填写)
2.问题:
报错:Failed to load module “canberra-gtk-module”
解决:
解决措施(1)
安装“canberra-gtk-module”
sudo apt-get install libcanberra-gtk-module
安装之后执行程序则不再出现。
解决措施(2)
想通过建立软连接的方式解决,结果又报错:opencv GTK+ 2.x symbols detected. Using GTK+ 2.x and GTK+ 3 in the same process is not supported
故采用如下方法:
重新安装opencv3.4.3,先卸载opencv3.4.3。
安装依赖项修改为:
sudo apt-get install build-essential libgtk3.0-dev libvtk6-dev libjpeg-dev libtiff5-dev libopenexr-dev libtbb-dev
加粗的为与书中不一样的地方,卸载旧版本的依赖项。然后安装opencv3.4.3:
mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local ..
make
sudo make install
- 第7讲
1.问题
orb_self.cpp中402行代码:cv::DMatch m{i1, 0, 256};
报错:warning: narrowing conversion of ‘i1’ from ‘size_t {aka long unsigned int}’ to ‘int’ inside { } [-Wnarrowing]
解决:
size_t和int的区别:size_t是一些C/C++标准在stddef.h中定义的,其的真实类型与操作系统有关。(在32位架构中被普遍定义为:typedef unsigned int size_t;
在64位架构中被定义为:typedef unsigned long size_t;
)。即 size_t在32位架构上是4字节,在64位架构上是8字节;而int在不同架构下都是4字节。进行强制类型转换,将变量i1强制转换为int型。
2.问题
pose_estimation_3d3d: /usr/include/eigen3/Eigen/src/Core/MapBase.h:191: void Eigen::MapBase<Derived, 0>::checkSanity(typename Eigen::internal::enable_if<(Eigen::internal::traits::Alignment > 0), void*>::type) const [with T = Eigen::Map<Eigen::Matrix<double, 3, 6, 0, 3, 6>, 32, Eigen::Stride<0, 0> >; Derived = Eigen::Map<Eigen::Matrix<double, 3, 6, 0, 3, 6>, 32, Eigen::Stride<0, 0> >; typename Eigen::internal::enable_if<(Eigen::internal::traits::Alignment > 0), void*>::type = void*]: Assertion `( ((internal::UIntPtr(m_data) % internal::traits::Alignment) == 0) || (cols() * rows() * innerStride() * sizeof(Scalar)) < internal::traits::Alignment ) && “data is not aligned”’ failed.
解决:
在CLion下增加CMake的release模式(点击File->Settings->Build,Execution,Deployment->CMake,然后点击+号,增加一个模式,会自动生成Release版本),然后把debug改成release模式(点击右上角的下三角箭头,这是里面会有Debug和Release两个选项,就可以在 Release模式下运行了)。