经过小一个月的努力,终于能够在最新的树莓派 5 系统上编译通过 orb-slam3,留档一下过程
环境概述
- 树莓派 5 系统, aikit 配件
Linux raspberrypi 6.6.31+rpt-tpi-v8 #1 SMP PREEMPT Debian 1:6.6.31-1+rpt1 (2024-05-29) aarch64 GNU/Linux
- gcc 版本
12.2.0 (Debian 12.2.0-14)
- ffmpeg 版本
5.1.6-0+deb12u1+rpt1
- libpng-dev 版本
1.6.39-2
编译前置依赖库
OpenCV
尝试了 3.4.16
, 4.2.0
, 4.6.0
几个版本,最终使用4.6.0
版本
在源码文件夹外新建build
文件夹,使用 cmake 指令
1 | cmake -D CMAKE_BUILD_TYPE=Release –D CMAKE_INSTALL_PREFIX=/home/rbpi/cpp/opencv/opencv-4.6.0/install -D WITH_FFMPEG=OFF ../opencv-4.6.0 |
error: ‘CODEC_ID_H264’ was not declared in this scope
等一堆报错原因是 ffmpeg 版本太高,但是要降版本好像很麻烦。
解决方法:cmake 时使用-D WITH_FFMPEG=OFF
关闭 ffmpeg,会导致无法读取视频,解决方法在这。error: comparing the result of pointer addition ‘(src + ((sizetype)off))’ and NULL [-Werror=address]
问题原因不明,怀疑与 gcc 版本有关
解决方法:从报错路径找对应的flags.make
文件,直接把其中的-Werror=address
字段删掉,使其忽略此报错。我当时的路径是opencv-3.4.16/build/modules/core/CMakeFiles/opencv_core.dir/flags.make
error: unrecognized command-line option ‘--param=ipcp-unit-growth=100000’; did you mean ‘--param=ipa-cp-unit-growth=’?
问题
似乎和 gcc 版本有关。
解决方法:将3rdparty/carotene/CMakeLists.txt
和3rdparty/carotene/hal/CMakeLists.txt
中的ipcp-unit-growth
全部替换成ipa-cp-unit-growth
参考链接error: ‘sleep_for’ is not a member of ‘std::this_thread’
问题
好像还是和 gcc 版本有关。
解决方法:往报错路径文件中增加一行#include <thread>
。
参考链接编译到 99%后冒出来一大堆类似
error: ‘GInferListOutputs’ does not name a type GAPI_EXPORTS_W inline GInferListOutputs infer2
的报错
把 build 文件夹建在源码里面就可能会出现的神秘报错,不过 install 文件夹倒好像不影响
解决方法: 把 build 文件夹建到 opencv 文件夹之外。
参考链接
Eigen3
选择3.1.0
版本后报错找不到 eigen,换成3.3.0
版本解决,编译未出现问题。
Pangolin
一定要在 eigen3 编译完后编译,选择0.6
版本,未出现问题。
- 出现一堆找不到
x264
相关定义的报错
1 | /usr/bin/ld: ../../src/libpangolin.so: undefined reference to `BZ2_bzDecompress' |
原因不明,但是和用了交叉编译的ffmpeg
有关。
解决方法:把交叉编译的ffmpeg
删了,在文件夹里sudo make uninstall
。
error: pybind11/pybind11.h: No such file or directory
问题
找不到pybind11
,解决方法是自己编译一个。
1 | git clone https://github.com/pybind/pybind11.git |
error: ‘numeric_limits’ is not a member of ‘std’
问题
和 qt 版本有关。
解决方法:在报错对应的文件里面加上一行#include <limits>
DBoW2 和 g2o
二者都包含在 orb-slam3 源码的三方库文件夹中,编译未出现问题。
sophus
包含在源码三方库文件夹中。
error: array subscript ‘__Float32x4_t[0]’ is partly outside array bounds of ‘Sophus::Vector3<float> [1]’
问题原因是 gcc 版本过高,尝试回退 gcc 至 4.8 但未起效。
解决方法:给/usr/lib/gcc/aarch64-linux-gnu/12/include/arm_neon.h
下的源码增加一行预编译指令#pragma GCC diagnostic ignored "-Warray-bounds"
使其忽略此报错
编译 ORB-SLAM3
Cannot find -lboost_serialization
问题
缺库,sudo apt install libboost-serialization-dev
。fatal error: openssl/md5.h: No such file or directory
问题
缺库,sudo apt install libssl-dev
运行测试视频
使用 kitti 数据集跑 demo
1 | ./Examples/Monocular/mono_kitti Vocabulary/ORBvoc.txt Examples/Monocular/KITTI00-02.yaml /home/raspi/cpp/dataset/data_odometry_gray/dataset/sequences/00 |
这是我把 kitti 数据集扔 cpp/dataset
下了
libpng warning: iCCP: known incorrect sRGB profile
问题,读不了图片和视频
怀疑是 libpng 与 OpenCV 版本不兼容导致。
解决方法:使用4.6.0
版本 OpenCV。出现:
折叠代码块 复制代码1
2
3
4
5Error: Unspecified error (The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Carbon support
...
巴拉巴拉
...
If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script in function cvNamedWindow解决方法:字面意思,
apt install libgtk2.0-dev pkg-config
然后重新编译 OpenCV
成功运行。
也许其他还有些简单的一搜就能搜到解决方法的报错,已经不记得了
- 本文标题:build orb-slam3 on raspberry pi
- 创建时间:2024-09-22 22:39:11
- 本文链接:https://pineoncellar.cn/2024/09/22/build-orb-slam3-on-raspberry-pi/
- 版权声明:本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!