Last active
June 2, 2022 18:36
-
-
Save HoKim98/d04aec141b6b7f9c84c9b6d339e11576 to your computer and use it in GitHub Desktop.
[Ubuntu] OpenVSLAM automatic installation script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
cd ~/Desktop | |
# --------------------------- | |
## 0. Requirements | |
# --------------------------- | |
sudo apt-get update | |
sudo apt-get install -y build-essential git pkg-config cmake make \ | |
gcc curl wget unzip \ | |
libeigen3-dev gfortran libyaml-cpp-dev libgoogle-glog-dev | |
# --------------------------- | |
## 1. Install OpenCV | |
# --------------------------- | |
# Find the library | |
ls /usr/local/lib/libopencv_core.so > /dev/null | |
if [ $? -ne 0 ] # 0 = found the library, 1 = error | |
then | |
# [0] Requirements | |
sudo apt-get install -y libgtk-3-dev libavresample-dev libavutil-dev \ | |
libavcodec-dev libavformat-dev libswscale-dev libv4l-dev \ | |
libxvidcore-dev libx264-dev libjpeg-dev libpng-dev libtiff-dev \ | |
gfortran openexr libatlas-base-dev python3-dev python3-numpy \ | |
libtbb2 libtbb-dev libdc1394-22-dev ffmpeg | |
# [1] Make a directory | |
mkdir build | |
pushd build | |
# [2] Get the source | |
VERSION=4.4.0 | |
wget -O opencv.tar.gz https://github.com/opencv/opencv/archive/$VERSION.tar.gz | |
wget -O opencv_contrib.tar.gz https://github.com/opencv/opencv_contrib/archive/$VERSION.tar.gz | |
# unpack | |
tar xf opencv.tar.gz | |
tar xf opencv_contrib.tar.gz | |
# [3] Build Makefile | |
mkdir -p opencv-$VERSION/build | |
pushd opencv-$VERSION/build | |
cmake \ | |
-D CMAKE_BUILD_TYPE=Release \ | |
-D CMAKE_INSTALL_PREFIX=/usr/local \ | |
-D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib-$VERSION/modules \ | |
-D ENABLE_CXX11=ON \ | |
-D BUILD_DOCS=OFF \ | |
-D BUILD_EXAMPLES=OFF \ | |
-D BUILD_JASPER=OFF \ | |
-D BUILD_OPENEXR=OFF \ | |
-D BUILD_PERF_TESTS=OFF \ | |
-D BUILD_TESTS=OFF \ | |
-D WITH_EIGEN=ON \ | |
-D WITH_FFMPEG=ON \ | |
-D WITH_OPENMP=ON \ | |
.. | |
# [4] Compile the source using the Makefile [3] | |
# -j: the number of your processors | |
make -j8 | |
# [5] Install the libraries compiled in [4] | |
sudo make install | |
# [6] Clean the project | |
popd # the source directory [2] | |
popd # the main directory [1] | |
rm -rf build | |
fi | |
# --------------------------- | |
## 2. Install g2o | |
# --------------------------- | |
# Find the library | |
ls /usr/local/lib/libg2o_core.so > /dev/null | |
if [ $? -ne 0 ] # 0 = found the library, 1 = error | |
then | |
# [0] Requirements | |
sudo apt-get install -y libatlas-base-dev libsuitesparse-dev | |
# [1] Make a directory | |
mkdir build | |
pushd build | |
# [2] Get the source | |
git clone https://github.com/RainerKuemmerle/g2o | |
# [3] Build Makefile | |
mkdir -p g2o/build | |
pushd g2o/build | |
cmake \ | |
-D CMAKE_BUILD_TYPE=Release \ | |
-D CMAKE_INSTALL_PREFIX=/usr/local \ | |
-D CMAKE_CXX_FLAGS=-std=c++11 \ | |
-D BUILD_SHARED_LIBS=ON \ | |
-D BUILD_UNITTESTS=OFF \ | |
-D BUILD_WITH_MARCH_NATIVE=ON \ | |
-D G2O_USE_CHOLMOD=OFF \ | |
-D G2O_USE_CSPARSE=ON \ | |
-D G2O_USE_OPENGL=OFF \ | |
-D G2O_USE_OPENMP=ON \ | |
.. | |
# [4] Compile the source using the Makefile [3] | |
# -j: the number of your processors | |
make -j8 | |
# [5] Install the libraries compiled in [4] | |
sudo make install | |
# [6] Clean the project | |
popd # the source directory [2] | |
popd # the main directory [1] | |
rm -rf build | |
fi | |
# --------------------------- | |
## 3. Install DBoW2 (Modified) | |
# --------------------------- | |
# Find the library | |
ls /usr/local/lib/libdbow2.so > /dev/null | |
if [ $? -ne 0 ] # 0 = found the library, 1 = error | |
then | |
# [0] Requirements | |
# [1] Make a directory | |
mkdir build | |
pushd build | |
# [2] Get the source | |
git clone https://github.com/shinsumicco/DBoW2 | |
# [3] Build Makefile | |
mkdir -p DBoW2/build | |
pushd DBoW2/build | |
cmake \ | |
-D CMAKE_BUILD_TYPE=Release \ | |
-D CMAKE_INSTALL_PREFIX=/usr/local \ | |
.. | |
# [4] Compile the source using the Makefile [3] | |
# -j: the number of your processors | |
make -j8 | |
# [5] Install the libraries compiled in [4] | |
sudo make install | |
# [6] Clean the project | |
popd # the source directory [2] | |
popd # the main directory [1] | |
rm -rf build | |
fi | |
# --------------------------- | |
## 4. Install Pangolin | |
# --------------------------- | |
# Find the library | |
ls /usr/local/lib/libpangolin.so > /dev/null | |
if [ $? -ne 0 ] # 0 = found the library, 1 = error | |
then | |
# [0] Requirements | |
sudo apt-get install -y libgl1-mesa-dev libglew-dev | |
# [1] Make a directory | |
mkdir build | |
pushd build | |
# [2] Get the source | |
git clone https://github.com/stevenlovegrove/Pangolin.git | |
# [3] Build Makefile | |
mkdir -p Pangolin/build | |
pushd Pangolin/build | |
cmake \ | |
-D CMAKE_BUILD_TYPE=Release \ | |
-D CMAKE_INSTALL_PREFIX=/usr/local \ | |
.. | |
# [4] Compile the source using the Makefile [3] | |
# -j: the number of your processors | |
make -j8 | |
# [5] Install the libraries compiled in [4] | |
sudo make install | |
# [6] Clean the project | |
popd # the source directory [2] | |
popd # the main directory [1] | |
rm -rf build | |
fi | |
# --------------------------- | |
## 5. Install OpenVSLAM | |
# --------------------------- | |
cd openvslam/build | |
if [ $? -ne 0 ] # 0 = found the library, 1 = error | |
then | |
# [1] Get the source | |
git clone https://github.com/xdspacelab/openvslam | |
# [2] Build Makefile | |
mkdir -p openvslam/build | |
cd openvslam/build | |
cmake \ | |
-D BUILD_WITH_MARCH_NATIVE=ON \ | |
-D USE_PANGOLIN_VIEWER=ON \ | |
-D USE_SOCKET_PUBLISHER=OFF \ | |
-D USE_STACK_TRACE_LOGGER=ON \ | |
-D BOW_FRAMEWORK=DBoW2 \ | |
-D BUILD_TESTS=ON \ | |
.. | |
# [3] Compile the source using the Makefile [3] | |
# -j: the number of your processors | |
make -j8 | |
# [4] Download the pretrained binaries | |
# download an ORB vocabulary from Google Drive | |
FILE_ID="1wUPb328th8bUqhOk-i8xllt5mgRW4n84" | |
curl -sc /tmp/cookie "https://drive.google.com/uc?export=download&id=${FILE_ID}" > /dev/null | |
CODE="$(awk '/_warning_/ {print $NF}' /tmp/cookie)" | |
curl -sLb /tmp/cookie "https://drive.google.com/uc?export=download&confirm=${CODE}&id=${FILE_ID}" -o orb_vocab.zip | |
unzip orb_vocab.zip | |
# download a sample dataset from Google Drive | |
FILE_ID="1d8kADKWBptEqTF7jEVhKatBEdN7g0ikY" | |
curl -sc /tmp/cookie "https://drive.google.com/uc?export=download&id=${FILE_ID}" > /dev/null | |
CODE="$(awk '/_warning_/ {print $NF}' /tmp/cookie)" | |
curl -sLb /tmp/cookie "https://drive.google.com/uc?export=download&confirm=${CODE}&id=${FILE_ID}" -o aist_living_lab_1.zip | |
unzip aist_living_lab_1.zip | |
# download a sample dataset from Google Drive | |
FILE_ID="1TVf2D2QvMZPHsFoTb7HNxbXclPoFMGLX" | |
curl -sc /tmp/cookie "https://drive.google.com/uc?export=download&id=${FILE_ID}" > /dev/null | |
CODE="$(awk '/_warning_/ {print $NF}' /tmp/cookie)" | |
curl -sLb /tmp/cookie "https://drive.google.com/uc?export=download&confirm=${CODE}&id=${FILE_ID}" -o aist_living_lab_2.zip | |
unzip aist_living_lab_2.zip | |
# [5] Clean up temporary zip files | |
rm *.zip | |
fi | |
# --------------------------- | |
## 6. END! | |
# --------------------------- | |
# the programs are in "~/Desktop/openvslam/build" | |
./run_video_slam \ | |
-v ./orb_vocab/orb_vocab.dbow2 \ | |
-m ./aist_living_lab_1/video.mp4 \ | |
-c ./aist_living_lab_1/config.yaml \ | |
--frame-skip 3 --no-sleep --map-db map.msg |
Sure, feel free to make use of my scripts!
Thanks!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi,
Thanks for providing this useful script.
I'm trying to provide a binary package for the community. A deb package will be generated using github actions. My work in progress can be seen here: https://github.com/m2-farzan/openvslam-ubuntu-package
I just wanted to ask for your permission, because I've based my work on your script. I have credited this gist in the README, and I plan to add an MIT license to my repo if you agree.