1、安装Eigen
sudo apt-get install libeigen3-dev
2、安装Sophus
Sophus 库是 Strasdat 维护的一个较好的李代数库,《视觉SLAM十四讲》使用非模板的 Sophus 库。可以输入以下命令获得非模板类的 Sophus:
git clone https://github.com/strasdat/Sophus.git cd Sophus git checkout a621ff
Sophus库只需编译,不需安装,在根目录下的终端,输入:
mkdir build cd ./build cmake .. make
3、安装OpenCV
先来安装 OpenCV 的依赖项:
sudo apt-get install build-essential libgtk2.0-dev libvtk5-dev libjpeg-dev libtiff4-dev libjasper-dev libopenexr-dev libtbb-dev
OpenCV下载地址: http://opencv.org/downloads.html 选择 OpenCV for Linux 版本,获得一个像 opencv-3.1.0.zip 这样的压缩包
解压缩后,进入文件根目录,执行:
mkdir build cd ./build cmake .. make (或者make -j4) sudo make install
备注:
OpenCV的卸载方法,进入build文件夹,执行:
sudo make uninstall
4、点云库的安装较为容易,只需执行:
sudo add-apt-repository ppa:v-launchpad-jochen-sprickerhof-de/pcl sudo apt-get update sudo apt-get install libpcl-all
5、Ceres安装
安装依赖项:
sudo apt-get install liblapack-dev libsuitesparse-dev libcxsparse3.1.4 libgflags-dev libgoogle-glog-dev libgtest-dev
Ceres下载地址:https://github.com/ceres-solver/ceres-solver
git clone https://github.com/ceres-solver/ceres-solver
编译并安装Ceres,进入文件根目录,执行:
mkdir build cd ./build cmake .. make sudo make install
备注(摘录自https://www.cnblogs.com/didada/p/12305066.html):
Ceres安装可能会出现以下错误:
在安装Ceres库cmake时报错提示找不到Eigen3.3,在对应的CMakeLists.txt中可以看到,由于BA优化在小于3.3.4版本的Eigen中可能失败,所以要求Eigen的版本不小于3.3.4。
解决方法:
卸载原来的Eigen,安装3.3.4之后的新版本:
(1)首先卸载Eigen,定位到相关文件,直接手动删除
sudo updatedb locate eigen3 sudo rm -rf /usr/include/eigen3 /usr/lib/cmake/eigen3 /usr/share/doc/libeigen3-dev /usr/share/pkgconfig/eigen3.pc /var/lib/dpkg/info/libeigen3-dev.list /var/lib/dpkg/info/libeigen3-dev.md5sums
然后下载安装3.3.4版本之后的Eigen,apt-get不能指定Eigen版本,这里推荐手动安装,下载地址 https://gitlab.com/libeigen/eigen/-/archive/3.3.7/eigen-3.3.7.tar.gz
安装依赖项:
sudo apt-get install libopenblas-dev
sudo apt-get install --no-install-recommends libboost1.58-all-dev sudo apt-get install libx11-dev sudo apt-get install libgl1-mesa-dev sudo apt-get install libglu1-mesa-dev sudo apt-get install freeglut3-dev sudo apt-get install doxygen sudo apt-get install cmake sudo wget https://nchc.dl.sourceforge.net/project/glew/glew/2.1.0/glew-2.1.0.tgz --no-check-certificate sudo tar -xzvf glew-2.1.0.tgz cd glew-2.1.0/ sudo make sudo make install sudo ldconfig -v
编译安装:
mkdir build cd build cmake .. make sudo make install sudo ldconfig -v
apt-get安装eigen3的路径为 /usr/include/eigen3 ,这里也保持一直;此外,需使用下面命令将Eigen映射到 /usr/include 路径下,因为在很多程序中include时经常使用#include <Eigen/Dense>而不是使用#include <eigen3/Eigen/Dense>,不映射的话一些程序在编译时会因找不到Eigen/Dense而报错:
sudo cp -r /usr/local/include/eigen3 /usr/include/eigen3
sudo ln -s /usr/include/eigen3/Eigen /usr/include/Eigen
然后再安装Ceres就不会报错了。
6、安装g2o
下载地址:https://github.com/RainerKuemmerle/g2o
git clone https://github.com/RainerKuemmerle/g2o
安装依赖:
sudo apt-get install libqt4-dev qt4-qmake libqglviewer-dev libsuitesparse-dev libcxsparse3.1.4 libcholmod3.0.6
编译安装:
mkdir build cd ./build cmake .. make sudo make install