ORB_SLAM3 -- 配置安装

安装环境 Ubuntu20.04

Eigen3安装

sudo apt install libeigen3-dev
sudo ln -s /usr/include/eigen3/Eigen /usr/include/Eigen

ORB_SLAM3依赖项安装

opencv3

ORB_SLAM3可用opencv3或opencv4编译,ORB-SLAM3最新版本明确需要OpenCV4,文章已经修改为OpenCV4.5.5版本

Step1: 安装opencv的依赖包

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 libjasper-dev libdc1394-22-dev
  • 如果提示找不到libjasper-dev软件包
sudo apt-add-repository "deb http://security.ubuntu.com/ubuntu xenial-security main"
sudo apt update
sudo apt install libjasper1 libjasper-dev

Step2: 下载opencv和opencv_contrib

cd ~/<my_working_directory> # <my_working_directory>替换为你的工作目录
git clone https://github.com/opencv/opencv.git
git clone https://github.com/opencv/opencv_contrib.git
cd opencv
git checkout 4.5.5
cd ..
cd opencv_contrib
git checkout 4.5.5
cd ..

Step3: 编译和安装opencv以及opencv_contrib模块

Step3.1 创建build目录
cd opencv
mkdir build
cd build
Step3.2 执行cmake命令
cmake -D CMAKE_BUILD_TYPE=RELEASE \
      -D CMAKE_INSTALL_PREFIX=/usr/local \
      -D INSTALL_C_EXAMPLES=ON \
      -D INSTALL_PYTHON_EXAMPLES=ON \
      -D WITH_TBB=ON \
      -D WITH_V4L=ON \
      -D WITH_QT=ON \
      -D WITH_OPENGL=ON \
      -D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules \
      -D BUILD_EXAMPLES=ON ..
Step3.3 编译并安装
# 执行如下命令后获取cpu核心数以加快编译
nproc
# 将nproc得到的数字放在make -j后面,作者的电脑有16的CPU核心
make -j16
sudo make install
sudo sh -c 'echo "/usr/local/lib" >> /etc/ld.so.conf.d/opencv.conf'
sudo ldconfig
  • opencv安装参考

Pangolin

  • pangolin版本更新到了0.6。此版本编译ORB_SLAM2,ORB_SLAM3,DSO,LDSO等SLAM框架时均会出现问题
  • 解决方法:采用较早版本的pangolin

非常不建议使用最新版本的pangolin进行编译安装,会遇到error: ‘slots_reference’ was not declared in this scope或者cannot findind Eigen3.cmake
issue: https://github.com/raulmur/ORB_SLAM2/issues/1015

Step1: 安装Pangolin的依赖包

sudo apt-get install libglew-dev
sudo apt-get install cmake
sudo apt-get install libpython2.7-dev
sudo apt-get install ffmpeg libavcodec-dev libavutil-dev libavformat-dev libswscale-dev
sudo apt-get install libdc1394-22-dev libraw1394-dev
sudo apt-get install libjpeg-dev libpng12-dev libtiff5-dev libopenexr-dev
  • libpng12-dev安装可能会报错,但不影响后续步骤。
# Ubuntu 16.04 之后不支持 libpng12-dev 修改为
sudo apt install libpng-dev

这里提供一个较早版本的Pangolin, 这里提供了百度网盘的版本
链接:https://pan.baidu.com/s/1R4dP4rH10dzrkvvAZ-rHzA
提取码:5k0q
--来自百度网盘超级会员V5的分享

Step2: 编译并安装Pangolin

cd Pangolin
# 百度网盘的版本有build文件,要先删除再创建
rm -rf build 
mkdir build
cd build
cmake ..
# 16替换为你自己电脑的CPU核心数
make -j16 
sudo make install
  • pangolin安装参考

ORB_SLAM3安装

Step1: 安装ORB_SLAM3的依赖包

sudo apt install libpython2.7-dev

Step2: 下载、编译并安装ORB_SLAM3

git clone https://github.com/UZ-SLAMLab/ORB_SLAM3.git ORB_SLAM3
cd ORB_SLAM3
chmod +x build.sh
# 可以修改 CMakeList.txt 中的`make -j`为`make -j16`来加快编译速度。16替换为你的电脑的CPU核心数
./build.sh 

编译ORB_SLAM3常见问题

  • /usr/bin/ld: cannot find -lboost_serializatio
  • 解决方法:执行如下命令
sudo apt install libboost-serialization-dev
  • ORBSLAM3 fatal error: openssl/md5.h: No such file or directory
  • 解决方法:执行如下命令
sudo apt install libssl-dev
  • make[2]: *** [CMakeFiles/ORB_SLAM3.dir/build.make:89: CMakeFiles/ORB_SLAM3.dir/src/LocalMapping.cc.o] Error 1
  • 解决方法:在orb_SLAM3/include/CameraModels/KannalaBrandt8.h中添加
namespace cv 
{ 
    template<typename _Tp, int m, int n> static inline Matx<_Tp, m, n> operator/(const Matx<_Tp, m, n>& a, float alpha) 
    {
        return Matx<_Tp, m, n>(a, 1.f/alpha, Matx_ScaleOp()); 
    } 
}
  • ORB_SLAM3安装参考
posted @ 2021-10-25 16:31  huoyanCC  阅读(2908)  评论(2编辑  收藏  举报