参考连接如:ORB_SLAM3/README.md at master · Mauhing/ORB_SLAM3 · GitHub
一、必要环境
sudo add-apt-repository "deb http://security.ubuntu.com/ubuntu xenial-security main"
sudo apt update
sudo apt-get install build-essential
sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev
sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libdc1394-22-dev libjasper-dev
sudo apt-get install libglew-dev libboost-all-dev libssl-dev
sudo apt install libeigen3-dev
二、安装、编译opencv库到系统中
cd ~
mkdir Dev && cd Dev
git clone https://github.com/opencv/opencv.git
cd opencv
git checkout 4.5.0
原文是:git checkout 3.2.0 这里改成:git checkout 4.5.0 (这里其实最后看到orb_slam是要求>4.4.0的opencv,这里我建议把3.2.0改成4.5.0) 其他版本共存问题可以看文章多版本opencv共存(1条消息) Opencv c版本安装,持续更新其使用方法_苏歆_sssuxin的博客-CSDN博客
Put the following at the top of header file gedit ./modules/videoio/src/cap_ffmpeg_impl.hpp
#define AV_CODEC_FLAG_GLOBAL_HEADER (1 << 22)
#define CODEC_FLAG_GLOBAL_HEADER AV_CODEC_FLAG_GLOBAL_HEADER
#define AVFMT_RAWPICTURE 0x0020
and save and close the file
mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=Release -D WITH_CUDA=OFF -D CMAKE_INSTALL_PREFIX=/usr/local ..
make -j 3(-j的意思是告诉编译器你系统处理器核的个数,可以通过命令nproc查看)
sudo make install
(-j的意思是告诉编译器你系统处理器核的个数,可以通过命令nproc查看)(这里不建议把核数选满,cpu占用过大导致系统无法进行其他操作)
三、安装Pangolin
cd ~/Dev
git clone https://github.com/stevenlovegrove/Pangolin.git
cd Pangolin
mkdir build
cd build
cmake .. -D CMAKE_BUILD_TYPE=Release
make -j 3
sudo make install
这里git clone这行需要变化(变化如下面连接),Pangolin选择5.0版本(太高版本sorb-lam会编译失败) make -j 安装自己的核数来选择参数
选择下载5.0版本的方法参照https://github.com/stevenlovegrove/Pangolin/issues/769
(现在编译似乎出现问题,可以参照视觉SLAM十四讲 Ubuntu20.04 Pangolin 环境配置_pangolin-0.5-20.04-CSDN博客解决--24/07/09)
四、安装ORB-SLAM 3
cd ~/Dev
git clone https://github.com/UZ-SLAMLab/ORB_SLAM3.git
cd ORB_SLAM3
We need to change the header file gedit ./include/LoopClosing.h
at line 51
fromEigen::aligned_allocator<std::pair<const KeyFrame*, g2o::Sim3> > > KeyFrameAndPose;
toEigen::aligned_allocator<std::pair<KeyFrame *const, g2o::Sim3> > > KeyFrameAndPose;
in order to make this comiple.
Now, we can comiple ORB-SLAM3 and it dependencies as DBoW2 and g2o.
Now Simply just run (if you encounter compiler, try to run the this shell script 2 or 3 more time. It works for me.)
./build.sh
这里可能会遇到点小问题ffmpeg
解决方法就是把cmakelist里关于ffmpeg的注释掉
五、数据集
下载数据集(链接: 百度网盘 请输入提取码 密码: 269k)
数据集解压到主目录/Datasets/EuRoc/MH01下
参考连接:安装运行okvis_a7691176的博客-CSDN博客
测试
cd ~/Dev/ORB_SLAM3
# Pick of them below that you want to run
# Mono
./Examples/Monocular/mono_euroc ./Vocabulary/ORBvoc.txt ./Examples/Monocular/EuRoC.yaml ~/Datasets/EuRoc/MH01 ./Examples/Monocular/EuRoC_TimeStamps/MH01.txt dataset-MH01_mono
# Mono + Inertial
./Examples/Monocular-Inertial/mono_inertial_euroc ./Vocabulary/ORBvoc.txt ./Examples/Monocular-Inertial/EuRoC.yaml ~/Datasets/EuRoc/MH01 ./Examples/Monocular-Inertial/EuRoC_TimeStamps/MH01.txt dataset-MH01_monoi
# Stereo
./Examples/Stereo/stereo_euroc ./Vocabulary/ORBvoc.txt ./Examples/Stereo/EuRoC.yaml ~/Datasets/EuRoc/MH01 ./Examples/Stereo/EuRoC_TimeStamps/MH01.txt dataset-MH01_stereo
# Stereo + Inertial
./Examples/Stereo-Inertial/stereo_inertial_euroc ./Vocabulary/ORBvoc.txt ./Examples/Stereo-Inertial/EuRoC.yaml ~/Datasets/EuRoc/MH01 ./Examples/Stereo-Inertial/EuRoC_TimeStamps/MH01.txt dataset-MH01_stereoi