JavaScript从零入门到精通详解
2026/4/8 18:21:08
这个代码版本太老,依赖库版本也太老,我的系统是ubuntu20.04,opencv4.5,编译会报很多错
其他库我是在以前运行orbslam2的时候都装好的,可以参照我以前的文章。
https://zhuanlan.zhihu.com/p/544128936
参照这个基本就可以了
1. mkdir -p ~/cubeslam_ws/src 2. cd ~/cubeslam_ws/src 把下载好的cube_slam放到src 3. cd cube_slam sh install_dependenices.sh 4. cd ~/cubeslam_ws 返回根目录 编译 catkin_make -j4 -DPYTHON_EXECUTABLE=/usr/bin/python3然后你就会遇到很多报错!!没事,一个个来解决
cubeslam_ws/src/cube_slam/line_lbd/libs/lsd.cpp:1168:32: error: ‘CV_BGR2GRAY’ was not declared in this scope; did you mean ‘COLOR_BGR2GRAY’? 1168 | cvtColor(_image, gray, CV_BGR2GRAY); | ^~~~~~~~~~~ | COLOR_BGR2GRAY解决:CV_GRAY2BGR→cv::COLOR_GRAY2BGR
2.报错2fatal error: opencv/cv.h: No such file or directory解决:将头文件替换为#include <opencv2/opencv.hpp>
error: ‘std::vector’ has not been declared note: ‘std::vector’ is defined in header '<vector>'; did you forget to '#include <vector>'?解决:
#把下面两行加在 matrix_utils.h 最上面 #include <vector> #include <string> 并且在 matrix_utils.cpp 顶部加上: #include <vector>error: ‘iota’ is not a member of ‘std’解决:
把下面头文件加到出现 iota 的 .cpp 顶部: #include <numeric>算了,一个个看报错太慢了。。我导出来错误有一万多行,虽然有很多事重复的。其实这些报错都是因为opencv版本或者其他依赖库的版本不对导致的,这个代码太老了,我的系统比较新,很多不适配,找到一个博主修改的,感谢大佬!!!
https://github.com/NeSC-IV/cube_slam-on-ubuntu20/blob/master/%E7%BC%96%E8%AF%91%E6%8C%87%E5%8D%97CubeSLAM%20Monocular%203D%20Object%20SLAM.md
先照着他这个一个个改完,应该没啥问题。后续我会考虑把改完的代码上传到github
纪念一下编译成功
今天下雪先休息,明天再更。