报错:
/home/yk/桌面/slambook-master/project/0.2/test/run_vo.cpp:6:28: fatal error: opencv2/viz.hpp: 没有那个文件或目录
compilation terminated.
test/CMakeFiles/run_vo.dir/build.make:62: recipe for target 'test/CMakeFiles/run_vo.dir/run_vo.cpp.o' failed
make[2]: *** [test/CMakeFiles/run_vo.dir/run_vo.cpp.o] Error 1
CMakeFiles/Makefile2:140: recipe for target 'test/CMakeFiles/run_vo.dir/all' failed
make[1]: *** [test/CMakeFiles/run_vo.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
问题:fatal error: opencv2/viz.hpp: No such file or directory 报错,估计是缺少viz模块,之前安装的是OPENCV3.2.0版本应该没什么问题的,可是现在缺少模块就把缺少的重新编译安装下吧。
解决:看到OPENCV官网上有解决方法,结合自己之前的安装过程,把解决过程梳理下:
1、找到自己当时解压后的opencv3.2源码,当时编译时自己新建了一个build文件夹,编译后的文件都放在这个文件夹里面,所以进到该文件夹中,开始操作。
2、安装依赖
sudo apt-get isntall libvtk5-dev
3、cmake时候加上-DWITH_VTK=ON这个参数
cmake -DWITH_VTK=ON ..
4、编译(时间挺长的)
make -j4
5、安装
sudo make install
就完事了,再次编译刚才缺少模块的项目,发现不报错,编译成功了。
转载参考:https://blog.youkuaiyun.com/weixin_42226918/article/details/85843848