Posts

Thursday, 7 February 2019

How to install ORB_SLAM2 and test it on ubuntu16.04

< What I did >

How to install ORB_SLAM2 and test it on Ubuntu 16.04

1. Create a new folder

mkdir ORB_SLAM
cd ORB_SLAM

2. Install the prerequisite software

(1) Update apt library
sudo apt-get update
(2) Install git
sudo apt-get install git
(3) Install cmake
sudo apt-get install cmake
(4) Install Pangolin
installation dependencies:
Opengl / GLEW :
sudo apt-get install libglew-dev
Boost :
sudo apt-get install libboost-dev libboost-thread-dev libboost-filesystem-dev
Python2/Python3 :
sudo apt-get install libpython2.7-dev
compile the base library :
sudo apt-get install build-essential
How to build Pangolin :
git clone https://github.com/stevenlovegrove/Pangolin.git
cd Pangolin
mkdir build
cd build
cmake ..
cmake --build .
(5) Install Eigen
cd ~/ORB_SLAM
sudo apt install mercurial
hg clone https://bitbucket.org/eigen/eigen/
cd eigen
mkdir build
cd build
cmake ..
make
sudo make install
(6) Install the BLAS and LAPACK library
sudo apt-get install libblas-dev
sudo apt-get install liblapack-dev
(7) Install OpenCV
# Install Dependencies

sudo apt-get update
sudo apt-get install -y build-essential
sudo apt-get install -y cmake
sudo apt-get install -y libgtk2.0-dev
sudo apt-get install -y pkg-config
sudo apt-get install -y python-numpy python-dev
sudo apt-get install -y libavcodec-dev libavformat-dev libswscale-dev
sudo apt-get install -y libjpeg-dev libpng-dev libtiff-dev libjasper-dev
sudo apt-get -qq install libopencv-dev build-essential checkinstall cmake pkg-config yasm libjpeg-dev libjasper-dev libavcodec-dev libavformat-dev libswscale-dev libdc1394-22-dev libxine2 libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev libv4l-dev python-dev python-numpy libtbb-dev libqt4-dev libgtk2.0-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libtheora-dev libvorbis-dev libxvidcore-dev x264 v4l-utils

# Download opencv-2.4.11

wget http://downloads.sourceforge.net/project/opencvlibrary/opencv-unix/2.4.11/opencv-2.4.11.zip
unzip opencv-2.4.11.zip
cd opencv-2.4.11
mkdir release
cd release
cd ~/ORB_SLAM
git clone https://github.com/opencv/opencv_extra.git
cd opencv-2.4.11/release
Please change -DOPENCV_TEST_DATA_PATH line below as yours.
  • Set OPENCV_TEST_DATA_PATH environment variable to <path to opencv_extra/testdata>.

cmake \
      -DBUILD_EXAMPLES=ON                                                     \
      -DBUILD_OPENCV_JAVA=OFF                                                 \
      -DBUILD_OPENCV_JS=ON                                                    \
      -DBUILD_OPENCV_NONFREE=ON                                               \
      -DBUILD_OPENCV_PYTHON=ON                                                \
      -DCMAKE_BUILD_TYPE=RELEASE                                              \
      -DCMAKE_INSTALL_PREFIX=$INSTALL_PATH                                    \
      -DCMAKE_LIBRARY_PATH=$CUDA_PATH/lib64/stubs/                            \
      -DCUDA_CUDA_LIBRARY=$CUDA_PATH/lib64/stubs/libcuda.so                   \
      -DCUDA_FAST_MATH=ON                                                     \
      -DCUDA_TOOLKIT_ROOT_DIR=$CUDA_PATH                                      \
      -DENABLE_CCACHE=ON                                                      \
      -DENABLE_FAST_MATH=ON                                                   \
      -DENABLE_PRECOMPILED_HEADERS=OFF                                        \
      -DINSTALL_C_EXAMPLES=ON                                                 \
      -DINSTALL_PYTHON_EXAMPLES=ON                                            \
      -DINSTALL_TESTS=ON                                                      \
      -DOPENCV_EXTRA_MODULES_PATH=$DOWNLOAD_PATH/opencv_contrib/modules/      \
      -DOPENCV_ENABLE_NONFREE=ON                                              \
      -DOPENCV_TEST_DATA_PATH= ~/ORB_SLAM/opencv_extra/testdata/              \
      -DWITH_CUBLAS=ON                                                        \
      -DWITH_CUDA=ON                                                          \
      -DWITH_FFMPEG=ON                                                        \
      -DWITH_GDAL=ON                                                          \
      -DWITH_GSTREAMER=ON                                                     \
      -DWITH_LIBV4L=ON                                                        \
      -DWITH_NVCUVID=ON                                                       \
      -DWITH_OPENCL=ON                                                        \
      -DWITH_OPENGL=ON                                                        \
      -DWITH_OPENMP=ON                                                        \
      -DWITH_QT=ON                                                            \
      -DWITH_TBB=ON                                                           \
      -DWITH_V4L=ON                                                           \
      -DWITH_VTK=ON                                                           \
      -DWITH_XINE=ON                                                          \
..

make all -j12 #12 cores
sudo make install
sudo apt-get install python-opencv
I got the cmake error like down below and the solution is on that link.

Error :
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
CUDA_nppi_LIBRARY (ADVANCED)

Solution :
https://stackoverflow.com/questions/46584000/cmake-error-variables-are-set-to-notfound

And then, I did cmake again and it worked!


3. Install ORB_SLAM

(1) Clone the repository:
git clone https://github.com/raulmur/ORB_SLAM2.git ORB_SLAM2
(2) Compile:
cd ORB_SLAM2
chmod +x build.sh
./build.sh
I got the error after this, so I added '#include<unistd.h>' in 'system.h' file.

Error:
‘usleep’ was not declared in this scope usleep(3000);

Solution:
Modify ORB_SLAM2-master/include/system.h, add "#include <unistd.h>" in header.

And then, I deleted every build file in ORB_SLAM2, DBoW, g2o and run 'build.sh' again.
It worked!

4. Test ORB_SLAM2

A test data set for a monocular camera was downloaded for testing.

(1) Download the test data set
Download a sequence from http://vision.in.tum.de/data/datasets/rgbd-dataset/download and uncompress it.
wget https://vision.in.tum.de/rgbd/dataset/freiburg1/rgbd_dataset_freiburg1_xyz.tgz

(2) Execution command:
Execute the following command. Change TUMX.yaml to TUM1.yaml, TUM2.yaml or TUM3.yaml for freiburg1, freiburg2 and freiburg3 sequences respectively. Change PATH_TO_SEQUENCE_FOLDER to the uncompressed sequence folder.

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


The result is OK, and some research records will be made on the ORB-SLAM algorithm in the future. Stay tuned.



1 comment:

  1. World777 is an eSports fantasy justice game played by roughly 13 million people. It has a total standing of3.9/ 5 and has been installed till date. In this game, the player can form a platoon of 11 members by opting them from a pool of 25 or 30 players. The performance of the 11 players on your platoon earns you the points just as the live match begins. Your final score gives you a ranking at the end.

    ReplyDelete

[ new blog ]

new blog https://jihyo-jeon.github.io/