orb slam [RGBD-1] process has died解决

本文讲述了在运行Orb-SLAM3时遇到的编译错误,解决过程涉及第三方库DBoW2和g2o的重新编译,特别是当项目文件夹名改变时,务必更新库的构建文件夹。

运行orb slam3时出现如下报错

[RGBD-1] process has died [pid 36546, exit code -4, cmd /orb_slam3/RGBD /ORB_SLAM3/Examples/ROS/ORB_SLAM3/../../../Vocabulary/ORBvoc.txt XX.yaml __name:=RGBD __log:=/.ros/log/2dc5-11ed-b022-6c02e04b2bf3/RGBD-1.log].
log file: /log/2dc5-11ed-b022-6c02e04b2bf3/RGBD-1*.log

重新编译orb slam3发现问题,就是第三方库
(仔细看编译过程中报的错,可能报错了但编译仍在继续,然后错会被忽略掉)
Thirdparty文件夹下,
DBoW2和g2o之前都编译过,build文件夹也在

之后改了orb slam3的文件夹名,之前叫ORB_SLAM3-beta-4.0什么的,后来改成了ORB_SLAM3
而那俩Thirdpary没有重新编译,导致链接仍然在之前的文件夹下,
第三方库删掉build文件夹,重新编译即可

/home/dhm/桌面/slamhuanjing/ORB_SLAM3-RGBD-Inertial/include/ORBextractor.h:24:10: fatal error: opencv/cv.h: 没有那个文件或目录 24 | #include <opencv/cv.h> | ^~~~~~~~~~~~~ compilation terminated. [ 89%] Building CXX object CMakeFiles/ORB_SLAM3.dir/src/MLPnPsolver.cpp.o make[2]: *** [CMakeFiles/ORB_SLAM3.dir/build.make:232:CMakeFiles/ORB_SLAM3.dir/src/Optimizer.cc.o] 错误 1 In file included from /home/dhm/桌面/slamhuanjing/ORB_SLAM3-RGBD-Inertial/include/KeyFrame.h:27, from /home/dhm/桌面/slamhuanjing/ORB_SLAM3-RGBD-Inertial/include/MapPoint.h:23, from /home/dhm/桌面/slamhuanjing/ORB_SLAM3-RGBD-Inertial/include/PnPsolver.h:52, from /home/dhm/桌面/slamhuanjing/ORB_SLAM3-RGBD-Inertial/src/PnPsolver.cc:50: /home/dhm/桌面/slamhuanjing/ORB_SLAM3-RGBD-Inertial/include/ORBextractor.h:24:10: fatal error: opencv/cv.h: 没有那个文件或目录 24 | #include <opencv/cv.h> | ^~~~~~~~~~~~~ compilation terminated. In file included from /home/dhm/桌面/slamhuanjing/ORB_SLAM3-RGBD-Inertial/include/KeyFrame.h:27, from /home/dhm/桌面/slamhuanjing/ORB_SLAM3-RGBD-Inertial/include/MapPoint.h:23, from /home/dhm/桌面/slamhuanjing/ORB_SLAM3-RGBD-Inertial/include/Map.h:23, from /home/dhm/桌面/slamhuanjing/ORB_SLAM3-RGBD-Inertial/include/Atlas.h:22, from /home/dhm/桌面/slamhuanjing/ORB_SLAM3-RGBD-Inertial/include/MapDrawer.h:23, from /home/dhm/桌面/slamhuanjing/ORB_SLAM3-RGBD-Inertial/src/MapDrawer.cc:20: /home/dhm/桌面/slamhuanjing/ORB_SLAM3-RGBD-Inertial/include/ORBextractor.h:24:10: fatal error: opencv/cv.h: 没有那个文件或目录 24 | #include <opencv/cv.h> | ^~~~~~~~~~~~~ compilation terminated. make[2]: *** [CMakeFiles/ORB_SLAM3.dir/build.make:245:CMakeFiles/ORB_SLAM3.dir/src/PnPsolver.cc.o] 错误 1 make[2]: *** [CMakeFiles/ORB_SLAM3.dir/build.make:219:CMakeFiles/ORB_SLAM3.dir/src/MapDrawer.cc.o] 错误 1 In file included from /home/dhm/桌面/slamhuanjing/ORB_SLAM3-RGBD-Inertial/include/KeyFrame.h:27, from /home/dhm/桌面/slamhuanjing/ORB_SLAM3-RGBD-Inertial/include/MapPoint.h:23, from /home/dhm/桌面/slamhuanjing/ORB_SLAM3-RGBD-Inertial/include/MLPnPsolver.h:52, from /home/dhm/桌面/slamhuanjing/ORB_SLAM3-RGBD-Inertial/src/MLPnPsolver.cpp:48: /home/dhm/桌面/slamhuanjing/ORB_SLAM3-RGBD-Inertial/include/ORBextractor.h:24:10: fatal error: opencv/cv.h: 没有那个文件或目录 24 | #include <opencv/cv.h> | ^~~~~~~~~~~~~ compilation terminated. In file included from /home/dhm/桌面/slamhuanjing/ORB_SLAM3-RGBD-Inertial/include/KeyFrame.h:27, from /home/dhm/桌面/slamhuanjing/ORB_SLAM3-RGBD-Inertial/include/MapPoint.h:23, from /home/dhm/桌面/slamhuanjing/ORB_SLAM3-RGBD-Inertial/include/Map.h:23, from /home/dhm/桌面/slamhuanjing/ORB_SLAM3-RGBD-Inertial/include/Atlas.h:22, from /home/dhm/桌面/slamhuanjing/ORB_SLAM3-RGBD-Inertial/include/Tracking.h:29, from /home/dhm/桌面/slamhuanjing/ORB_SLAM3-RGBD-Inertial/include/FrameDrawer.h:23, from /home/dhm/桌面/slamhuanjing/ORB_SLAM3-RGBD-Inertial/include/Viewer.h:23, from /home/dhm/桌面/slamhuanjing/ORB_SLAM3-RGBD-Inertial/src/Viewer.cc:20: /home/dhm/桌面/slamhuanjing/ORB_SLAM3-RGBD-Inertial/include/ORBextractor.h:24:10: fatal error: opencv/cv.h: 没有那个文件或目录 24 | #include <opencv/cv.h> | ^~~~~~~~~~~~~ compilation terminated. make[2]: *** [CMakeFiles/ORB_SLAM3.dir/build.make:388:CMakeFiles/ORB_SLAM3.dir/src/MLPnPsolver.cpp.o] 错误 1 make[2]: *** [CMakeFiles/ORB_SLAM3.dir/build.make:310:CMakeFiles/ORB_SLAM3.dir/src/Viewer.cc.o] 错误 1 In file included from /home/dhm/桌面/slamhuanjing/ORB_SLAM3-RGBD-Inertial/include/KeyFrame.h:27, from /home/dhm/桌面/slamhuanjing/ORB_SLAM3-RGBD-Inertial/include/LocalMapping.h:23, from /home/dhm/桌面/slamhuanjing/ORB_SLAM3-RGBD-Inertial/src/LocalMapping.cc:20: /home/dhm/桌面/slamhuanjing/ORB_SLAM3-RGBD-Inertial/include/ORBextractor.h:24:10: fatal error: opencv/cv.h: 没有那个文件或目录 24 | #include <opencv/cv.h> | ^~~~~~~~~~~~~ compilation terminated. make[2]: *** [CMakeFiles/ORB_SLAM3.dir/build.make:89:CMakeFiles/ORB_SLAM3.dir/src/LocalMapping.cc.o] 错误 1 In file included from /home/dhm/桌面/slamhuanjing/ORB_SLAM3-RGBD-Inertial/include/KeyFrame.h:27, from /home/dhm/桌面/slamhuanjing/ORB_SLAM3-RGBD-Inertial/src/KeyFrame.cc:19: /home/dhm/桌面/slamhuanjing/ORB_SLAM3-RGBD-Inertial/include/ORBextractor.h:24:10: fatal error: opencv/cv.h: 没有那个文件或目录 24 | #include <opencv/cv.h> | ^~~~~~~~~~~~~ compilation terminated. make[2]: *** [CMakeFiles/ORB_SLAM3.dir/build.make:180:CMakeFiles/ORB_SLAM3.dir/src/KeyFrame.cc.o] 错误 1 In file included from /home/dhm/桌面/slamhuanjing/ORB_SLAM3-RGBD-Inertial/include/KeyFrame.h:27, from /home/dhm/桌面/slamhuanjing/ORB_SLAM3-RGBD-Inertial/include/MapPoint.h:23, from /home/dhm/桌面/slamhuanjing/ORB_SLAM3-RGBD-Inertial/include/Map.h:23, from /home/dhm/桌面/slamhuanjing/ORB_SLAM3-RGBD-Inertial/include/Optimizer.h:23, from /home/dhm/桌面/slamhuanjing/ORB_SLAM3-RGBD-Inertial/src/Initializer.cc:23: /home/dhm/桌面/slamhuanjing/ORB_SLAM3-RGBD-Inertial/include/ORBextractor.h:24:10: fatal error: opencv/cv.h: 没有那个文件或目录 24 | #include <opencv/cv.h> | ^~~~~~~~~~~~~ compilation terminated. make[2]: *** [CMakeFiles/ORB_SLAM3.dir/build.make:297:CMakeFiles/ORB_SLAM3.dir/src/Initializer.cc.o] 错误 1 In file included from /home/dhm/桌面/slamhuanjing/ORB_SLAM3-RGBD-Inertial/include/KeyFrame.h:27, from /home/dhm/桌面/slamhuanjing/ORB_SLAM3-RGBD-Inertial/include/Sim3Solver.h:26, from /home/dhm/桌面/slamhuanjing/ORB_SLAM3-RGBD-Inertial/src/Sim3Solver.cc:20: /home/dhm/桌面/slamhuanjing/ORB_SLAM3-RGBD-Inertial/include/ORBextractor.h:24:10: fatal error: opencv/cv.h: 没有那个文件或目录 24 | #include <opencv/cv.h> | ^~~~~~~~~~~~~ compilation terminated. make[2]: *** [CMakeFiles/ORB_SLAM3.dir/build.make:284:CMakeFiles/ORB_SLAM3.dir/src/Sim3Solver.cc.o] 错误 1 In file included from /home/dhm/桌面/slamhuanjing/ORB_SLAM3-RGBD-Inertial/include/KeyFrame.h:27, from /home/dhm/桌面/slamhuanjing/ORB_SLAM3-RGBD-Inertial/include/KeyFrameDatabase.h:27, from /home/dhm/桌面/slamhuanjing/ORB_SLAM3-RGBD-Inertial/src/KeyFrameDatabase.cc:20: /home/dhm/桌面/slamhuanjing/ORB_SLAM3-RGBD-Inertial/include/ORBextractor.h:24:10: fatal error: opencv/cv.h: 没有那个文件或目录 24 | #include <opencv/cv.h> | ^~~~~~~~~~~~~ compilation terminated. make[2]: *** [CMakeFiles/ORB_SLAM3.dir/build.make:271:CMakeFiles/ORB_SLAM3.dir/src/KeyFrameDatabase.cc.o] 错误 1 In file included from /home/dhm/桌面/slamhuanjing/ORB_SLAM3-RGBD-Inertial/include/KeyFrame.h:27, from /home/dhm/桌面/slamhuanjing/ORB_SLAM3-RGBD-Inertial/include/G2oTypes.h:36, from /home/dhm/桌面/slamhuanjing/ORB_SLAM3-RGBD-Inertial/src/Frame.cc:21: /home/dhm/桌面/slamhuanjing/ORB_SLAM3-RGBD-Inertial/include/ORBextractor.h:24:10: fatal error: opencv/cv.h: 没有那个文件或目录 24 | #include <opencv/cv.h> | ^~~~~~~~~~~~~ compilation terminated. make[2]: *** [CMakeFiles/ORB_SLAM3.dir/build.make:258:CMakeFiles/ORB_SLAM3.dir/src/Frame.cc.o] 错误 1 In file included from /home/dhm/桌面/slamhuanjing/ORB_SLAM3-RGBD-Inertial/include/KeyFrame.h:27, from /home/dhm/桌面/slamhuanjing/ORB_SLAM3-RGBD-Inertial/include/LoopClosing.h:23, from /home/dhm/桌面/slamhuanjing/ORB_SLAM3-RGBD-Inertial/src/LoopClosing.cc:20: /home/dhm/桌面/slamhuanjing/ORB_SLAM3-RGBD-Inertial/include/ORBextractor.h:24:10: fatal error: opencv/cv.h: 没有那个文件或目录 24 | #include <opencv/cv.h> | ^~~~~~~~~~~~~ compilation terminated. make[2]: *** [CMakeFiles/ORB_SLAM3.dir/build.make:102:CMakeFiles/ORB_SLAM3.dir/src/LoopClosing.cc.o] 错误 1 In file included from /home/dhm/桌面/slamhuanjing/ORB_SLAM3-RGBD-Inertial/include/KeyFrame.h:27, from /home/dhm/桌面/slamhuanjing/ORB_SLAM3-RGBD-Inertial/include/G2oTypes.h:36, from /home/dhm/桌面/slamhuanjing/ORB_SLAM3-RGBD-Inertial/src/G2oTypes.cc:19: /home/dhm/桌面/slamhuanjing/ORB_SLAM3-RGBD-Inertial/include/ORBextractor.h:24:10: fatal error: opencv/cv.h: 没有那个文件或目录 24 | #include <opencv/cv.h> | ^~~~~~~~~~~~~ compilation terminated.项目本身是opencv3的cmake我修改为opencv4.20之后报错
07-19
### 问题分析 在将 ORB_SLAM3 项目从 OpenCV 3 迁移到 OpenCV 4.20 后,出现 `opencv/cv.h` 头文件找不到的错误,主要原因是 OpenCV 4 中对头文件结构进行了调整,废弃了旧的 `cv.h` 兼容头文件。OpenCV 3 中的 `cv.h` 是一个聚合头文件,包含了多个模块的定义,而 OpenCV 4 则要求开发者显式包含所需的模块头文件[^1]。 ### 解决方案 #### 1. 替换旧的头文件引用 将所有使用 `#include <opencv/cv.h>` 的语句替换为 OpenCV 4 中对应的模块头文件。例如: ```cpp #include <opencv2/core.hpp> #include <opencv2/imgproc.hpp> #include <opencv2/highgui.hpp> ``` 根据具体代码中使用的功能,选择性地包含所需模块的头文件。这种方式不仅符合 OpenCV 4 的规范,还能提高编译效率[^1]。 #### 2. 修改 CMakeLists.txt 中的 OpenCV 版本检测逻辑 确保 `CMakeLists.txt` 中正确识别 OpenCV 4.20 的版本,并链接所需的模块。可以使用如下方式指定模块: ```cmake find_package(OpenCV REQUIRED core imgproc highgui) ``` 这样可以确保在构建时正确链接 OpenCV 4 的核心库[^1]。 #### 3. 检查系统中 OpenCV 的安装路径与版本 使用以下命令确认当前系统中安装的 OpenCV 版本: ```bash pkg-config --modversion opencv4 ``` 如果输出为 `4.20`,说明 OpenCV 4.20 已正确安装。否则,可能需要重新安装或配置环境变量以指向正确的 OpenCV 安装路径[^1]。 #### 4. 使用兼容性命名空间(可选) OpenCV 4 提供了兼容性命名空间 `cv::legacy` 和 `cv::cuda::npp` 等,用于支持部分 OpenCV 3 的接口。如果某些模块尚未完全迁移到新接口,可以尝试使用这些命名空间进行适配。 --- ### 示例代码修改 假设在 `System.cc` 中存在如下代码: ```cpp #include <opencv/cv.h> ``` 应修改为: ```cpp #include <opencv2/core.hpp> #include <opencv2/imgproc.hpp> #include <opencv2/highgui.hpp> ``` 并在使用 OpenCV 函数时,确保使用 `cv::` 命名空间前缀,例如: ```cpp cv::Mat frame; cv::imshow("Frame", frame); ``` --- ### 编译与测试 完成上述修改后,重新运行 CMake 并构建项目: ```bash mkdir build && cd build cmake .. make -j$(nproc) ``` 如果仍然存在编译错误,建议逐个检查未更新的头文件引用,并确保所有 OpenCV 接口调用符合 OpenCV 4 的标准。 ---
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

蓝羽飞鸟

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值