ubuntu20.04安装openvslam--2021.10.19
1.安装依赖
sudo apt-get update sudo apt-get install -y build-essential pkg-config cmake git wget curl unzip //g2o dependencies sudo apt-get install -y libatlas-base-dev libsuitesparse-dev //OpenCV dependencies sudo apt-get install -y libgtk-3-dev sudo apt-get install -y ffmpeg sudo apt-get install -y libavcodec-dev libavformat-dev libavutil-dev libswscale-dev libavresample-dev //eigen dependencies sudo apt install -y gfortran //Pangolin dependencies sudo apt install -y libglew-dev //other dependencies sudo apt install -y libyaml-cpp-dev libgoogle-glog-dev libgflags-dev sudo apt-get install -y libopenblas-dev sudo apt-get install -y libx11-dev sudo apt-get install -y libgl1-mesa-dev
sudo apt-get install libglu1-mesa-dev
sudo apt-get install -y freeglut3-dev sudo apt-get install -y doxygen
2.安装eigen
cd /path/to/working/dir // 可以在官网下载https://gitlab.com/libeigen/eigen/-/releases#3.3.7 wget https://github.com/eigenteam/eigen-git-mirror/archive/3.3.7.tar.gz tar -xzvf 3.3.7.tar.gz mv eigen-git-mirror-3.3.7/ eigen-3.3.7/ cd eigen-3.3.7/ mkdir build && cd build cmake \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_INSTALL_PREFIX=/usr/local \ .. make -j2 sudo make install sudo ldconfig -v
3.安装g2o
git clone https://github.com/RainerKuemmerle/g2o.git cd g2o mkdir build && cd build cmake \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_INSTALL_PREFIX=/usr/local \ -DCMAKE_CXX_FLAGS=-std=c++11 \ -DBUILD_SHARED_LIBS=ON \ -DBUILD_UNITTESTS=OFF \ -DBUILD_WITH_MARCH_NATIVE=ON \ -DG2O_USE_CHOLMOD=OFF \ -DG2O_USE_CSPARSE=ON \ -DG2O_USE_OPENGL=OFF \ -DG2O_USE_OPENMP=ON \ .. make -j12 sudo make install //如果make有错误,cc1plus: error: bad value (‘tigerlake’) for ‘-march=’ switch #46 //可以将g++、gcc改成10 sudo apt install gcc-10 g++-10 sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 100 --slave /usr/bin/g++ g++ /usr/bin/g++-10 --slave /usr/bin/gcov gcov /usr/bin/gcov-10 // 卸载 sudo rm -r /usr/local/include/g2o sudo rm -r /usr/local/lib/libg2o* sudo rm -r /usr/local/bin/g2o*
4.安装OpenCV4
5.安装作者的DBo2
git clone https://github.com/shinsumicco/DBoW2.git cd DBoW2 mkdir build && cd build cmake \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_INSTALL_PREFIX=/usr/local \ .. make -j2 sudo make install sudo ldconfig -v
6.安装yaml-cpp
这里需要在CMakeLists.txt
开启fPIC选项
target_compile_options(yaml-cpp PRIVATE $<${not-msvc}:-Wall -Wextra -Wshadow -Weffc++ -Wno-long-long> # $<${not-msvc}:-pedantic -pedantic-errors> #修改前 $<${not-msvc}:-fPIC -pedantic -pedantic-errors> #修改后
git clone https://github.com/jbeder/yaml-cpp cd yaml-cpp mkdir build && cd build cmake \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_INSTALL_PREFIX=/usr/local \ .. make -j2 sudo make install sudo ldconfig -v
7.安装glew
wget https://nchc.dl.sourceforge.net/project/glew/glew/2.1.0/glew-2.1.0.tgz --no-check-certificate tar -xzvf glew-2.1.0.tgz cd glew-2.1.0/ make -j2 sudo make install sudo ln -s /usr/lib64/libGLEW.so.2.1 /usr/lib/libGLEW.so.2.1 sudo ldconfig -v
8.安装pingolin
这里不要用最新的pangolin,最新版缺少支持
https://github.com/stevenlovegrove/Pangolin.git
cd Pangolin mkdir build && cd build cmake \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_INSTALL_PREFIX=/usr/local \ .. make -j sudo make install sudo ldconfig -v
9.编译openvslam工程
cmake \ -DBUILD_WITH_MARCH_NATIVE=ON \ -DUSE_PANGOLIN_VIEWER=ON \ -DUSE_SOCKET_PUBLISHER=OFF \ -DUSE_STACK_TRACE_LOGGER=ON \ -DBOW_FRAMEWORK=DBoW2 \ -DBUILD_TESTS=ON \ .. make -j12
‘runtime_error’ is not a member of ‘std’
/src/pangolin_viewer/color_scheme.cc
#include<stdexcept>
/home/lhw/Graduate/openvslam/GPS_BA/0/openvslam/src/openvslam/publish/frame_publisher.cc:152:56: error: ‘setprecision’ is not a member of ‘std’
152 | ss << "track time: " << std::fixed << std::setprecision(0) << elapsed_ms << "ms";
#include <iomanip>