ORBSLAM2的编译与运行
环境:Ubuntu16.04 ORBSLAM2
(1)安装工具
sudo apt-get install cmake
sudo apt-get install git
sudo apt-get install gcc g++
(2) 安装pangolin
安装依赖项:
sudo apt-get install libglew-dev
sudo apt-get install libboost-dev libboost-thread-dev libboost-filesystem-dev
sudo apt-get install libpython2.7-dev
下载并安装
git clone https://github.com/stevenlovegrove/Pangolin.git
cd Pangolin
mkdir build
cd build
cmake -DCPP11_NO_BOOSR=1 …
make -j
sudo make install
(3)安装opencv
ORBSLAM2支持opencv2和3,这里我安装的是opencv3.2.0
安装依赖:
sudo apt-get install build-essential
sudo apt-get install libgtk2.0-dev
sudo apt-get install pkg-config
去官网下载opencv3.2.0,将下载的OpenCV解压到自己的指定目录,然后cd到OpenCV的目录下
mkdir build
cd build
cmake …
make
sudo make install
(4)安装Eigen3
在http://eigen.tuxfamily.org 下载Eigen3的最新版本,解压,cd到该目录下
mkdir build
cd build
cmake …
make
sudo make install
(5)安装ORBSLAM2
clone它的源代码到ORB-SLAM2目录下:
git clone https://github.com/raulmur/ORB_SLAM2.git ORB_SLAM2
cd 到该目录下
cd ORB_SLAM2
chmod +x build.sh
./build.sh
如果没有出错的话那么就编译完成了
很多个.cpp和.h文件因为都没有添加头文件<unistd.h>而报错;
error: ‘usleep’ was not declared in this scope
usleep(1000);
解决办法:使用VScode查找orb-slam2的全局搜索,找到所有的usleep;然后每个文件都添加头文件
#include <unistd.h>
./build.sh即可
(6)运行RGB实例
下载数据集并解压
http://vision.in.tum.de/data/datasets/rgbd-dataset/download#freiburg1_desk
./Examples/RGB-D/rgbd_tum Vocabulary/ORBvoc.txt Examples/RGB-D/TUM1.yaml /home/rgbd_dataset_freiburg1_desk /home/ORB-SLAM2-master/Example/RGB-D/associations/fr1_desk.txt