Cube-slam复现及报错解决

https://github.com/shichaoy/cube_slam

这个代码版本太老,依赖库版本也太老,我的系统是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

然后你就会遇到很多报错!!没事,一个个来解决

二、报错解决

1. 报错1

复制代码
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_GRAY2BGRcv::COLOR_GRAY2BGR

2.报错2

复制代码
fatal error: opencv/cv.h: No such file or directory

解决:将头文件替换为#include <opencv2/opencv.hpp>

3. 报错3

复制代码
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>

4. 报错4

复制代码
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

纪念一下编译成功

三、运行

今天下雪先休息,明天再更。

相关推荐
一点一木43 分钟前
🚀 2026 年 6 月 GitHub 十大热门项目排行榜 🔥
人工智能·github
aneasystone本尊44 分钟前
学习 turbovec 的 SIMD 搜索内核
人工智能
阳光是sunny10 小时前
别再被 worktree 绕晕了!AI 编程时代你必须掌握的 Git 隔离神器
前端·人工智能·后端
冬奇Lab10 小时前
每日一个开源项目(第148篇):obsidian-skills - Obsidian CEO 亲写的 AI Agent 格式规范,让 Agent 不再破坏你的 Vault
人工智能·开源·资讯
ethantan10 小时前
AI Agent 组成:像人一样思考的智能体
人工智能·程序员·架构
冬奇Lab11 小时前
Workflow 系列(05):评测体系——三层测试结构与 Trace 追踪
人工智能·工作流引擎
ethantan11 小时前
一篇讲解AI Agent 组成:像人一样思考的智能体
人工智能·后端·程序员
Cosolar13 小时前
vLLM 生产级部署完全指南
人工智能·后端·架构
CodePlayer竟然被占用了13 小时前
被美国政府封杀18天,Claude Fable 5 回来了——但代价是什么?
人工智能
IT_陈寒14 小时前
垃圾回收器选错了,我的Java服务内存炸了
前端·人工智能·后端