ORB-SLAM2安装与运行(非ROS环境下)

1.Prerequisites

1.1 C++11 or C++0x Compiler

We use the new thread and chrono functionalities of C++11.

所以需要安装C++11编译器,运行:

$ sudo apt-get install gcc g++

1.2 Pangolin

We use [Pangolin](https://github.com/stevenlovegrove/Pangolin) for visualization and user interface. Dowload and install instructions can be found at: https://github.com/stevenlovegrove/Pangolin.

$ sudo apt-get install libglew-dev   #安装Glew  
$ sudo apt-get install cmake         #安装CMake  
    #安装Boost  
$ sudo apt-get install libboost-dev libboost-thread-dev libboost-filesystem-dev  
$ sudo apt-get install libpython2.7-dev  #安装Python2 / Python3  
   #下载、编译、安装Pangolin:  
$ git clone https://github.com/stevenlovegrove/Pangolin.git  
$ cd Pangolin  
$ mkdir build  
$ cd build  
$ cmake -DCPP11_NO_BOOST=1 ..  
$ make  
$ sudo make install  

1.3 OpenCV(2.4.13)

We use [OpenCV](http://opencv.org) to manipulate images and features. Dowload and install instructions can be found at: http://opencv.org. **Required at leat 2.4.3. Tested with OpenCV 2.4.11 and OpenCV 3.2**.

$ sudo apt-get install build-essential libgtk2.0-dev libjpeg-dev libtiff4-dev libjasper-dev libopenexr-dev cmake python-dev python-numpy python-tk libtbb-dev libeigen2-dev yasm libfaac-dev libopencore-amrnb-dev libopencore-amrwb-dev libtheora-dev libvorbis-dev libxvidcore-dev libx264-dev libqt4-dev libqt4-opengl-dev sphinx-common texlive-latex-extra libv4l-dev libdc1394-22-dev libavcodec-dev libavformat-dev libswscale-dev  
$ unzip  opencv-2.4.13.zip    
$ cd opencv-2.4.13;mkdir build;cd build;   
$ cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_TBB=ON -D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_V4L=ON -DINSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON -DBUILD_EXAMPLES=ON -D WITH_QT=ON -D WITH_OPENGL=ON -DCUDA_GENERATION=Kepler ..      
$ make  
$ sudo make install   
#在其中写入: /usr/local/lib  
sudo gedit /etc/ld.so.conf.d/opencv.conf   
 
#在文件末尾写入:    
#PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig   
#export PKG_CONFIG_PATH  
sudo ldconfig sudo gedit/etc/bash.bashrc  
 
#source此脚本  
source /etc/bash.bashrc  

1.4 Eigen3

Required by g2o (see below). Download and install instructions can be found at: http://eigen.tuxfamily.org. **Required at least 3.1.0**.
注意:Opencv2.4.13编译时依赖此模块,最好在OpenCV2.4.13编译前安装

它能提供以下功能模块:
   1) 密集矩阵和数组操作
   2) 解密集线性方程组和矩阵分解
        -求解线性最小二乘系统
        -密集矩阵分解 (Cholesky, LU, QR, SVD, 特征值分解)
   3) 解稀疏线性方程组和矩阵分解
        -稀疏矩阵操作
        -求解稀疏线性最小二乘系统
        -稀疏矩阵分解(SpareCore, OrderingMethods, SpareCholesky, SpareLU, SparseQR,迭代线性求解)
   4) 空间变换
        - 2D旋转(角度)
        - 3D旋转(角度+轴)
        - 3D旋转(四元组: quaternion)
        - N维缩放
        - N维平移
        - N维仿射变换
        - N维线性变换(旋转、平移、缩放)
运行:

$ sudo apt-get install libeigen3-dev  

1.5 BLAS and LAPACK

   g2o需要BLAS和LAPACK

(1) BLAS: Basic Linear Algebra Subprograms

     提供了基本的向量和矩阵操作:
     - Level-1 BLAS: 支持 标量、向量、向量-向量 操作
     - Level-2 BLAS: 支持 矩阵-向量 操作
     - Level-3 BLAS: 支持 矩阵-矩阵 操作

(2) LAPACK:Linear Algebra PACKage

    它调用BLAS来实现更高级的功能,支持以下操作:

    - 解线性方程组
    - 线性方程组的最小二乘解
    - 特征值问题和奇异值问题
    - 矩阵分解 (LU, Cholesky, QR, SVD, Schur, generalized Schur)
    - 支持密集和带状矩阵,但不支持一般的稀疏矩阵
    - 支持单精度和双精度

运行:

$ sudo apt-get install libblas-dev  
$ sudo apt-get install liblapack-dev  

1.6 DBoW2 and g2o (Included in Thirdparty folder)

We use modified versions of the [DBoW2](https://github.com/dorian3d/DBoW2) library to perform place recognition and [g2o](https://github.com/RainerKuemmerle/g2o) library to perform non-linear optimizations. Both modified libraries (which are BSD) are included in the *Thirdparty* folder.

2 Building ORB-SLAM2 library and TUM/KITTI examples

2.1 编译ORB-SLAM2库

运行:

$ git clone https://github.com/raulmur/ORB_SLAM2.git ORB_SLAM2  
$ cd ORB_SLAM2  
$ chmod +x build.sh  
$ ./build.sh  
生成的libORB_SLAM2.so位于/ORB-SLAM2/lib目录下,可执行程序mono_tum, mono_kitti, rgbd_tum, stereo_kitti, mono_euroc and stereo_euroc位于/ORB-SLAM2/Examples目录下。

2.2 运行TUM/KITTI例子程序

2.2.1 Monocular 实例

      1)TUM 数据集

       从http://vision.in.tum.de/data/datasets/rgbd-dataset/download下载并解压一个序列,如:rgbd_dataset_freiburg1_desk2.tgz

     ./Examples/Monocular/mono_tum Vocabulary/ORBvoc.txt Examples/Monocular/TUMX.yaml PATH_TO_SEQUENCE_FOLDER

       运行上面的命令(把TUMX.yaml 修改为TUM1.yaml < freiburg1序列>,TUM2.yaml < freiburg2序列> or TUM3.yaml < freiburg3序列> ,PATH_TO_SEQUENCE_FOLDER是存放下载好的序列的目录

#for example
$ cd ORB-SLAM2  
$ ./Examples/Monocular/mono_tum Vocabulary/ORBvoc.txt ./Examples/Monocular/TUM1.yaml Dataset/TUM-dataset/rgbd_dataset_freiburg1_desk2  

     2) KITTI 数据集

      从 http://www.cvlibs.net/datasets/kitti/eval_odometry.php下载数据集(灰度图像), 把KITTIX.yaml  修改为 KITTI00-02.yaml, KITTI03.yaml or KITTI04-12.yaml,这些*xx.yaml各自对应于序列 0 to 2, 3, and 4 to 12. Change PATH_TO_DATASET_FOLDER to the uncompressed dataset folder. Change SEQUENCE_NUMBER to 00, 01, 02,.., 11.

#for example
$ ./Examples/Monocular/mono_kitti Vocabulary/ORBvoc.txt Examples/Monocular/KITTIX.yaml PATH_TO_DATASET_FOLDER/dataset/sequences/SEQUENCE_NUMBER

 2.2.2 Stereo 实例

      1)KITTI 数据集

      从 http://www.cvlibs.net/datasets/kitti/eval_odometry.php下载数据集(灰度图像),把KITTIX.yaml  修改为 KITTI00-02.yaml, KITTI03.yaml or KITTI04-12.yaml,这些*xx.yaml各自对应于序列 0 to 2, 3, and 4 to 12. Change PATH_TO_DATASET_FOLDER to the uncompressed dataset folder. Change SEQUENCE_NUMBER to 00, 01, 02,.., 11.

#for example
$ ./Examples/Stereo/stereo_kitti Vocabulary/ORBvoc.txt Examples/Stereo/KITTIX.yaml PATH_TO_DATASET_FOLDER/dataset/sequences/SEQUENCE_NUMBER  

2.2.3 RGB-D 实例

      1)TUM 数据集

       从http://vision.in.tum.de/data/datasets/rgbd-dataset/download下载并解压一个序列,如:rgbd_dataset_freiburg1_desk2.tgz

       运行RGB-D实例时需要RGBD(depth)图像和RGB图像,所以需要把每一张RGB图像与之对应的RGBD图像建立关联(在Examples/RGB-D/associations/目录下有一部分关联文件,可以直接使用),关联Python文件associate.py(根据timestamp进行关联)。

#for example
$ python associate.py PATH_TO_SEQUENCE/rgb.txt PATH_TO_SEQUENCE/depth.txt > associations.txt

       执行下面的命令(把TUMX.yaml 修改为TUM1.yaml < freiburg1序列>,TUM2.yaml < freiburg2序列> or TUM3.yaml < freiburg3序列> ),把 ASSOCIATIONS_FILE修改为对应的关联文件。

$./Examples/RGB-D/rgbd_tum Vocabulary/ORBvoc.txt Examples/RGB-D/TUMX.yaml PATH_TO_SEQUENCE_FOLDER ASSOCIATIONS_FILE  
   # for example  
$./Examples/RGB-D/rgbd_tum Vocabulary/ORBvoc.txt ./Examples/RGB-D/TUM1.yaml  ../tum-data/rgbd_dataset_freiburg1_desk2/ ./Examples/RGB-D/associations/fr1_desk2.txt 

 





你可能感兴趣的:(VSLAM,Ubuntu14.04,ORB-SLAM2,非ROS)