Install ORBSLAM2 on ubuntu18.04

        I recently turned around the old project and found that the previous environment did not know what the wind was, so it couldn't be used directly. Well, I simply installed it from scratch.

1. Third-party library

Mainly including Pangolin, OpenCV, Eigen

g2o and DBoW2 come with ORB-SLAM2, so you don’t need to do it yourself

# Update the apt library, update the software list
sudo apt-get update

sudo apt-get upgrade

First install vim, cmake, git, gcc, g++

ctrl+alt+t to open the terminal

sudo apt-get install vim cmake
sudo apt-get install git
sudo apt-get install gcc g++

1、Pangolin

Pangolin is a lightweight OpenGL input/output and video display library that encapsulates OpenGL. 

install dependencies

sudo apt-get install libgl1-mesa-dev
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

It is recommended to download version 0.5, otherwise it will report an error that lEigen cannot be found

git clone -b 0.5 https://github.com/stevenlovegrove/Pangolin.git 

start compiling

# Start compiling and installing
cd Pangolin
mkdir build && cd build 
cmake -DCPP11_NO_BOOST=1 ..
sudo make install 

Verify that the installation was successful

# 验证
cd ../examples/HelloPangolin
mkdir build && cd build
cmake ..
make
./HelloPangolin

After successful installation, you can see the following 

2、opencv

Address: Releases - OpenCV

I am using version 3.4.14

install dependencies

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

If Unable to locate package libjasper-dev appears, use the following method to solve it

sudo add-apt-repository "deb http://security.ubuntu.com/ubuntu xenial-security main"
sudo apt update
sudo apt install libjasper1 libjasper-dev

start compiling

cd opencv/
mkdir build
cd build
cmake ..
make -j4
sudo make install

It is basically no problem to see the following picture after cmake

Verify that the installation was successful

#verify

cd opencv/samples/cpp/example_cmake
cmake .
make
./opencv_example

If successful, you can see the effect in the following figure

 3、Own

I installed Eigen 3.3.7 from source · libeigen / eigen · GitLab

cd eigen
mkdir build && cd build
cmake ..
make
sudo make install

# Include in many programs often use #include <Eigen/Dense> instead of #include <eigen3/Eigen/Dense> #
So after installation, you need to copy the header file from /usr/local/include/eigen3/ to /usr /local/include
sudo cp -r /usr/local/include/eigen3/Eigen /usr/local/include

Verify that the installation was successful

# Create a test test file
touch test_eigen.cpp
gedit test_eigen.cpp
g++ test_eigen.cpp -o test_eigen
./test_eigen

Add the following code in test.cpp

#include <iostream>
//需要将头文件从 /usr/local/include/eigen3/ 复制到 /usr/local/include
#include <Eigen/Dense>
//using Eigen::MatrixXd;
using namespace Eigen;
using namespace Eigen::internal;
using namespace Eigen::Architecture;
using namespace std;
int main()
{
        cout<<"*******************1D-object****************"<<endl;
        Vector4d v1;
        v1<< 1,2,3,4;
        cout<<"v1=\n"<<v1<<endl;
 
        VectorXd v2(3);
        v2<<1,2,3;
        cout<<"v2=\n"<<v2<<endl;
 
        Array4i v3;
        v3<<1,2,3,4;
        cout<<"v3=\n"<<v3<<endl;
 
        ArrayXf v4(3);
        v4<<1,2,3;
        cout<<"v4=\n"<<v4<<endl;
}

After running, you can see the following figure

2. Install ORBSLAM2

git clone https://github.com/raulmur/ORB_SLAM2.git ORB_SLAM2
cd ORB_SLAM2
chmod +x build.sh
./build.sh

You may encounter usleep errors during installation

Just add #include <unistd.h> to ORB_SLAM2/include/System.h to solve it

If there is no problem with the above, it will basically go smoothly here, as you can see in the picture below

Guess you like

Origin blog.csdn.net/athrunsunny/article/details/131350640