需要各种库的下载安装(Pangolin、Opencv、 Eigen 3安装),与ORB-SLAM2基本相同。
详见:https://blog.csdn.net/weixin_47074246/article/details/108690625
$ sudo apt-get install git
$ sudo apt-get install vim
$ sudo apt-get install g++
$ sudo apt-get install gcc
$ sudo apt-get install cmake
卸载旧版本的cmake
$ sudo apt-get autoremove cmake
下载依赖项
$ sudo apt-get install build-essential
$ sudo apt-get install libssl-dev
下载
$ sudo wget https://github.com/Kitware/CMake/releases/download/v3.18.3/cmake-3.18.3.tar.gz
文件路径一般选择在/opt
或 /usr
路径下, 这里选择/opt
解压并安装
$ tar -zxvf cmake-3.18.3.tar.gz
$ sudo mv cmake-3.18.3 /opt/cmake-3.18.3
$ cd /opt/cmake-3.18.3
$ ./configure
$ make -j8
$ sudo make install
创建软链接。
$ sudo ln -sf /opt/cmake-3.18.3/bin/* /usr/bin/
查看cmake的版本
$ cmake --version
显示
cmake version 3.18.3
CMake suite maintained and supported by Kitware (kitware.com/cmake).
完成安装。
Pangolin是对OpenGL进行封装的轻量级的OpenGL输入/输出和视频显示的库。可以用于3D视觉和3D导航的视觉图,可以输入各种类型的视频、并且可以保留视频和输入数据用于debug。
$ 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 libpython3-dev
$ sudo apt-get install build-essential
$ git clone https://github.com/stevenlovegrove/Pangolin.git
$ cd Pangolin
$ mkdir build
$ cd build
$ cmake ..
$ make
$ sudo make install
原本安装了OpenCV 4.5.0 但是ORB_SLAM3需要版本号为3,需要卸载原版本。
进入原先编译opencv的build目录,执行以下代码。
$ cd opencv/build
$ sudo make uninstall
$ cd ..
$ sudo rm -r build
$ sudo rm -r /usr/local/include/opencv2 /usr/local/include/opencv /usr/include/opencv /usr/include/opencv2 /usr/local/share/opencv /usr/local/share/OpenCV /usr/share/opencv /usr/share/OpenCV /usr/local/bin/opencv* /usr/local/lib/libopencv*
代码执行后会报错,忽略
$ sudo apt-get --purge remove opencv-doc opencv-data python-opencv
检查,用以下代码检查opencv是否卸载干净
$ pkg-config opencv --libs
$ pkg-config opencv --modversion
$ cd /usr
$ find . -name "*opencv*" | xargs sudo rm -rf
若仍能显出opencv的相关信息,则表示未卸载干净
清除干净
$ sudo apt-get autoremove opencv-doc opencv-data libopencv-dev libopencv2.4-java libopencv2.4-jni python-opencv libopencv-core2.4 libopencv-gpu2.4 libopencv-ts2.4 libopencv-photo2.4 libopencv-contrib2.4 libopencv-imgproc2.4 libopencv-superres2.4 libopencv-stitching2.4 libopencv-ocl2.4 libopencv-legacy2.4 libopencv-ml2.4 libopencv-video2.4 libopencv-videostab2.4 libopencv-objdetect2.4 libopencv-calib3d2.4
$ sudo apt-get install build-essential
$ sudo apt-get install libgtk2.0-dev libgtk-3-dev libavcodec-dev libavformat-dev libswscale-dev
# python支持
$ sudo apt install python-dev python-numpy python3-dev python3-numpy
# streamer支持
$ sudo apt install libgstreamer-plugins-base1.0-dev libgstreamer1.0-dev
# 可选的依赖
$ sudo apt install libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libtiff5-dev libwebp-dev libjasper-dev libdc1394-22-dev libopenexr-dev
官网下载:https://opencv.org/releases/
或者源码下载
$ git clone https://github.com/opencv/opencv.git
或
$ git clone https://hub.fastgit.org/opencv/opencv.git
$ cd opencv
$ mkdir build
$ cd build
$ cmake -D CMAKE_BUILD_TYPE=Release -D OPENCV_GENERATE_PKGCONFIG=YES -D CMAKE_INSTALL_PREFIX=/usr/local/ ..
$ make
$ sudo make install
$ sudo find / -iname opencv4.pc
/usr/local/opencv4/lib/pkgconfig/opencv4.pc
/usr/local/include/opencv4/lib/pkgconfig/
路径加入PKG_CONFIG_PATH
:$ sudo gedit /etc/profile.d/pkgconfig.sh
在文件中加入下面一行:
export PKG_CONFIG_PATH=/usr/local/opencv4/lib/pkgconfig:$PKG_CONFIG_PATH
保存退出后,使用命令激活:
$ source /etc/profile
$ pkg-config --libs opencv4
-L/usr/local/opencv4/lib -lopencv_ml -lopencv_dnn -lopencv_video -lopencv_stitching -lopencv_objdetect -lopencv_calib3d -lopencv_features2d -lopencv_highgui -lopencv_videoio -lopencv_imgcodecs -lopencv_flann -lopencv_photo -lopencv_gapi -lopencv_imgproc -lopencv_core
配置OpenCV动态库环境——程序执行时加载动态库*.so的路径。
$ sudo vim /etc/ld.so.conf.d/opencv4.conf
在该文件(可能是空文件)末尾加上:
/usr/local/opencv4/lib
再执行以下命令使刚才配置的路径生效:
$ sudo ldconfig
找到编译好的python cv
库:
$ sudo find / -iname cv2*.so
/home/username/opencv/build/lib/python3/cv2.cpython-35m-x86_64-linux-gnu.so
/usr/local/opencv4/lib/python3.5/dist-packages/cv2/python-3.5/cv2.cpython-35m-x86_64-linux-gnu.so
cv2.cpython-35m-x86_64-linux-gnu.so就
是编译好的python3的opencv库,我们把它复制到对应python解释器的/path/to/dist-packages/
(系统自带的python解释器)和/path/to/site-packages
(用户安装的python解释器)目录下,之后就能在该python解释器中使用python-opencv库。
链接到系统自带的python3解释器中:
$ sudo ln -s /usr/local/opencv4/lib/python3.5/dist-packages/cv2/python-3.5/cv2.cpython-35m-x86_64-linux-gnu.so /usr/lib/python3/dist-packages/cv2.so
链接到Anaconda创建的虚拟环境python3解释器中:
$ ln -s /usr/local/opencv4/lib/python3.5/dist-packages/cv2/python-3.5/cv2.cpython-35m-x86_64-linux-gnu.so ~/anaconda3/lib/python3.7/site-packages/cv2.so
参考:https://blog.csdn.net/new_delete_/article/details/84797041
$ sudo apt-get install libeigen3-dev
$ sudo updatedb
$ locate eigen3
找到位置在/usr/include/eigen3
Eigen库全部由头文件组成要使用Eigen库
在cmake工程中的CMakeLists.txt
文件中指定Eigen的头文件目录:
include_directories("/usr/local/include/eigen3")
运行命令:
$ sudo cp -r /usr/local/include/eigen3/Eigen /usr/local/include
因为eigen3
被默认安装到了usr/local/include
,很多程序经常使用#include
而不是使用#include
。所以要做下处理,否则一些程序在编译时会因找不到Eigen/Dense
而报错。上面指令将usr/local/include/eigen3
文件夹中的Eigen
文件递归地复制到上一层文件夹(直接放到/usr/local/include
中,否则系统无法默认搜索到 -> 此时只能在CMakeLists.txt
用include_libraries
)
$ sudo cp /usr/local/include/eigen3/ /usr/include/ -R
复制至/usr/include/
目录以防万一。
参考:https://blog.csdn.net/ganbaoni9yang/article/details/83956999
详见(3)ORB-SLAM3安装问题 2)Eigen的deprecated错误
编写程序test.cpp
#include
#include
//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;
}
编译
$ g++ test.cpp
运行
./a.out
由于在ORB_SLAM2项目的Thirdparty
下已包含g2o
和DBoW2
,只需安装依赖项。
$ sudo apt-get install cmake libeigen3-dev libsuitesparse-dev qtdeclarative5-dev qt5-qmake libqglviewer-dev //g2o的依赖项
$ sudo apt-get install libboost-dev //DBoW2的依赖项
官网下载 https://github.com/UZ-SLAMLab/ORB_SLAM3
但是国内有限制,下载很慢(平均30kb/s)。可以通过git clone 镜像文件提速。
下载ORB-SLAM3的镜像文件
```
git clone https://hub.fastgit.org/UZ-SLAMLab/ORB_SLAM3.git
```
其他github下载提速方法参考:https://blog.csdn.net/weixin_44821644/article/details/107574297
Ubuntu 16.04 LTS
(Intel® Core™ i5-4210U CPU @ 1.70GHz x86_64-pc-linux-gnu)
Ubuntu 20.04 LTS
(Intel® Core™ i7-10710U CPU @ 1.10GHz × 12 x86_64-pc-linux-gnu)
Pangolin
Opencv 4.5.0
Eigen 3
$ cd ORB_SLAM3
$ chmod +x build.sh
$ ./build.sh
查看占用内存
$ free -m
若虚拟内存不足,编译提示virtual memory exhausted: Cannot allocate memory
,则需增加Swap虚拟内存。
参考:https://blog.csdn.net/zzcchunter/article/details/83587881
EuRoC数据集是使用两个针孔照相机(双目)和一个惯性传感器(IMU)采集的数据
下载ASL格式的序列:https://projects.asl.ethz.ch/datasets/doku.php?id=kmavvisualinertialdatasets#downloads
这里下载的是MH01,Dataset machine hall “easy” 。
下载后进行解压。注意dataset
文件夹与ORB_SLAM3
同路径下,并且dataset
目录下只有一个mav0
文件夹,为解压后的MH_01
。
打开ORB-SLAM3源码中的脚本euroc_examples.sh
,找到包含MH01的指令:
./Examples/Monocular/mono_euroc ./Vocabulary/ORBvoc.txt ./Examples/Monocular/EuRoC.yaml "$pathDatasetEuroc"/MH01 ./Examples/Monocular/EuRoC_TimeStamps/MH01.txt dataset-MH01_mono
将$pathDatasetEuroc/MH01
改成自己数据集的路径。其中我的路径为:ORB_SLAM3/Datasets/MH_01
,并去掉指令中的dataset-MH01_mono
,最终改成的指令如下:
./Examples/Monocular-Inertial/mono_inertial_euroc ./Vocabulary/ORBvoc.txt ./Examples/Monocular-Inertial/EuRoC.yaml ./Dataset/MH01 ./Examples/Monocular-Inertial/EuRoC_TimeStamps/MH01.txt
评价:
纯视觉的轨迹由左摄像头中心采集,通过evaluation文件夹将地面真实轨迹转换为左摄像头的参考轨迹。
执行以下脚本,处理序列并计算RMS ATE:
./Examples/Stereo/stereo_euroc ./Vocabulary/ORBvoc.txt ./Examples/Stereo/EuRoC.yaml ./Dataset/MH01 ./Examples/Stereo/EuRoC_TimeStamps/MH01.txt dataset-MH01_stereo
echo “------------------------------------”
echo “Evaluation of MH01 trajectory with Stereo sensor”
python evaluation/evaluate_ate_scale.py evaluation/Ground_truth/EuRoC_left_cam/MH01_GT.txt f_dataset-MH01_stereo.txt --plot MH01_stereo.pdf
/usr/lib may be hidden by files in /home/username/anaconda/lib
系统存在两个动态链接库(.so文件),分别在 /usr/lib 和 anaconda/lib 下。
由于曾分别用常规方式和 anaconda 安装过 opencv。用anaconda安装后, 默认的路径就是anaconda, 因此链接不到 /usr/lib 下的库文件,所以报错。
参考:https://blog.csdn.net/weixin_30555753/article/details/98960883
解决方法:删除或转移相关的文件
Could NOT find Doxygen (missing: DOXYGEN_EXECUTABLE)
解决办法:安装 Doxygen
sudo apt-get install doxygen
../../src/libpangolin.so: undefined reference to `png_set_longjmp_fn'
未找到动态库层的函数,可能是版本过低的原因,需要链接更高版本的libpng
库。
查看系统png
库的版本
$ cd /lib/x86_64-linux-gnu
$ ll | grep png
输出
lrwxrwxrwx 1 root root 18 7月 11 2018 libpng12.so.0 -> libpng12.so.0.54.0
-rw-r--r-- 1 root root 149904 7月 11 2018 libpng12.so.0.54.0
$ cd /usr/lib/x86_64-linux-gnu
$ ll | grep png
输出
-rw-r--r-- 1 root root 243746 7月 11 2018 libpng12.a
lrwxrwxrwx 1 root root 13 7月 11 2018 libpng12.so -> libpng12.so.0
lrwxrwxrwx 1 root root 35 7月 11 2018 libpng12.so.0 -> /lib/x86_64-linux-gnu/libpng12.so.0
lrwxrwxrwx 1 root root 10 7月 11 2018 libpng.a -> libpng12.a
lrwxrwxrwx 1 root root 11 7月 11 2018 libpng.so -> libpng12.so
现在用的libpng
是libpng12.so
解决方法:
1)创建一个软链接libpng16.so
指向libpng16.so.16
$ cd /usr/lib/x86_64-linux-gnu
$ sudo ln -s libpng16.so.16 libpng16.so
$ ll | grep png
输出
-rw-r--r-- 1 root root 243746 7月 11 2018 libpng12.a
lrwxrwxrwx 1 root root 13 7月 11 2018 libpng12.so -> libpng12.so.0
lrwxrwxrwx 1 root root 35 7月 11 2018 libpng12.so.0 -> /lib/x86_64-linux-gnu/libpng12.so.0
lrwxrwxrwx 1 root root 14 9月 24 16:37 libpng16.so -> libpng16.so.16
lrwxrwxrwx 1 root root 10 7月 11 2018 libpng.a -> libpng12.a
lrwxrwxrwx 1 root root 11 7月 11 2018 libpng.so -> libpng12.so
2)删除之前的软链接libpng.so
$ cd /usr/lib/x86_64-linux-gnu
$ sudo rm -rf libpng.so
$ ll | grep png
输出
-rw-r--r-- 1 root root 243746 7月 11 2018 libpng12.a
lrwxrwxrwx 1 root root 13 7月 11 2018 libpng12.so -> libpng12.so.0
lrwxrwxrwx 1 root root 35 7月 11 2018 libpng12.so.0 -> /lib/x86_64-linux-gnu/libpng12.so.0
lrwxrwxrwx 1 root root 14 9月 24 16:37 libpng16.so -> libpng16.so.16
lrwxrwxrwx 1 root root 10 7月 11 2018 libpng.a -> libpng12.a
chan@chanpc:/usr/lib/x86_64-linux-gnu$
3)创建一个新的软链接libpng.so
指向libpng16.so
$ cd /usr/lib/x86_64-linux-gnu
$ sudo ln -s libpng16.so libpng.so
$ ll | grep png
-rw-r--r-- 1 root root 243746 7月 11 2018 libpng12.a
lrwxrwxrwx 1 root root 13 7月 11 2018 libpng12.so -> libpng12.so.0
lrwxrwxrwx 1 root root 35 7月 11 2018 libpng12.so.0 -> /lib/x86_64-linux-gnu/libpng12.so.0
lrwxrwxrwx 1 root root 14 9月 24 16:37 libpng16.so -> libpng16.so.16
lrwxrwxrwx 1 root root 10 7月 11 2018 libpng.a -> libpng12.a
lrwxrwxrwx 1 root root 11 9月 24 16:44 libpng.so -> libpng16.so
4)仍然报错No rule to make target '/usr/lib/x86_64-linux-gnu/libpng.so', needed by 'src/libpangolin.so'. Stop.
动态链接库的链接性中断,搜索发现libpng.so文件存在与anaconda目录.
libpng.so
文件路径: 本机中路径为:~/anaconda3/libuuid/libpng.so
sudo ln -s ~/anaconda3/libuuid/libpng.so /usr/lib/x86_64-linux-gnu/libpng.so
报错File exists,则删除原有文件
sudo rm /usr/lib/x86_64-linux-gnu/libpng.so
重新建立软连接即可。
参考:http://blog.csdn.net/wangpanbaoding/article/details/104185058
CMakeFiles/Makefile2:136: recipe for target 'src/CMakeFiles/pangolin.dir/all' failed
make[1]: *** [src/CMakeFiles/pangolin.dir/all] Error 2
Makefile:149: recipe for target 'all' failed
make: *** [all] Error 2
由于系统安装了Anaconda产生了冲突,可以采取软连接的方式指定。
looking for ccache --not found
解决方法:
$ sudo apt-get install ccache
No package 'gtk+-3.0' found
安装gtk±3.0
$ sudo apt install libgtk-3-devgtk+-3.0
或
$ sudo apt-get install libgtk-3-dev
Could NOT find OpenJPEG
安装依赖项
$ sudo apt-get install liblcms2-dev libtiff-dev libpng-dev libz-dev
下载并解压
$ git clone https://github.com/uclouvain/openjpeg.git
编译
$ cd openjpeg
$ mkdir build
$ cd build
$ cmake .. -DCMAKE_BUILD_TYPE=Release
$ make
参考官网:https://github.com/uclouvain/openjpeg/blob/master/INSTALL.md
参考:https://www.cnblogs.com/yongy1030/p/10293178.html
打开ippicv.cmake文件
$ sudo gedit ~/opencv/3rdparty/ippicv/ippicv.cmake
第一个是IPPICV_COMMIT
,它的值可以从代码中找到:
set(IPPICV_COMMIT "a56b6ac6f030c312b2dce17430eef13aed9af274")
第二个是OPENCV_IPPICV_URL
,同理可以找到:
$ENV{OPENCV_IPPICV_URL}"
"https://raw.githubusercontent.com/opencv/opencv_3rdparty/${IPPICV_COMMIT}/ippicv/
最后一个是文件名OPENCV_ICV_NAME
:
if(X86_64)
set(OPENCV_ICV_NAME "ippicv_2020_lnx_intel64_20191018_general.tgz")
set(OPENCV_ICV_HASH "7421de0095c7a39162ae13a6098782f9")
这三个联合起来就可以得到文件的下载路径为:
https://raw.githubusercontent.com/opencv/opencv_3rdparty/a56b6ac6f030c312b2dce17430eef13aed9af274/ippicv/ippicv_2020_lnx_intel64_20191018_general.tgz
ps: 解决GitHub的raw.githubusercontent.com无法连接问题
修改host
文件
$ sudo gedit /etc/hosts
添加以下内容保存即可 (IP地址查询后相应修改,可以ping不同IP的延时 选择最佳IP地址)
#GitHub Start
52.74.223.119 github.com
192.30.253.119 gist.github.com
54.169.195.247 api.github.com
185.199.111.153 assets-cdn.github.com
151.101.108.133 raw.githubusercontent.com
151.101.108.133 user-images.githubusercontent.com
151.101.76.133 gist.githubusercontent.com
151.101.76.133 cloud.githubusercontent.com
151.101.76.133 camo.githubusercontent.com
151.101.76.133 avatars0.githubusercontent.com
151.101.76.133 avatars1.githubusercontent.com
151.101.76.133 avatars2.githubusercontent.com
151.101.76.133 avatars3.githubusercontent.com
151.101.76.133 avatars4.githubusercontent.com
151.101.76.133 avatars5.githubusercontent.com
151.101.76.133 avatars6.githubusercontent.com
151.101.76.133 avatars7.githubusercontent.com
151.101.76.133 avatars8.githubusercontent.com
#GitHub End
参考:https://www.cnblogs.com/sinferwu/p/12726833.html
sudo wget https://raw.githubusercontent.com/opencv/opencv_3rdparty/a56b6ac6f030c312b2dce17430eef13aed9af274/ippicv/ippicv_2020_lnx_intel64_20191018_general.tgz
将如下的地址
"${OPENCV_IPPICV_URL}"
"$ENV{OPENCV_IPPICV_URL}"
"https://raw.githubusercontent.com/opencv/opencv_3rdparty/${IPPICV_COMMIT}/ippicv/"
修改为ippicv安装包所在本地路径file://本地路径
最后还是报错,直接将文件修改名字后放在.cache下载文件夹、
Could not find OpenBLAS include. Turning OpenBLAS_FOUND off
-- Could not find OpenBLAS lib. Turning OpenBLAS_FOUND off
-- Could NOT find Atlas (missing: Atlas_CBLAS_INCLUDE_DIR Atlas_CLAPACK_INCLUDE_DIR Atlas_CBLAS_LIBRARY Atlas_BLAS_LIBRARY Atlas_LAPACK_LIBRARY)
-- A library with BLAS API not found. Please specify library location.
-- LAPACK requires BLAS
-- A library with LAPACK API not found. Please specify library location.
$ sudo apt-get install libopenblas-dev
$ sudo apt-get install libatlas-dev
$ sudo apt-get install liblapacke-dev
找到API,仍然找不到库文件和头文件,报错
-- Could not find OpenBLAS include. Turning OpenBLAS_FOUND off
-- Could not find OpenBLAS lib. Turning OpenBLAS_FOUND off
-- Could NOT find Atlas (missing: Atlas_CBLAS_LIBRARY Atlas_BLAS_LIBRARY)
安装gfortran编译器
$ sudo apt-get install gfortran
下载blas, cblas, lapack 源代码
官网:http://www.netlib.org/blas
依次解压之后有三个文件夹,BLAS-3.8.0
,CBLAS
, lapack-3.9.0
编译 blas
$ cd BLAS-3.8.0
$ gfortran -c -O3 -fPIC *.f # 编译所有的 .f 文件,生成 .o文件 加上了-fPIC
$ gcc -shared *.o -fPIC -o libblas.so
$ sudo cp libblas.so /usr/local/lib/
$ ar rv libblas.a *.o # 链接所有的 .o文件,生成 .a 文件
$ sudo cp libblas.a /usr/local/lib # 将库文件复制到系统库目录
编译 cblas
进入CBLAS
文件夹,根据计算机平台,将目录下某个 Makefile.XXX
复制为 Makefile.in
。XXX表示计算机的平台,如果是Linux,那么就将Makefile.LINUX
复制为 Makefile.in
。
$ cd CBLAS
$ sudo cp ../BLAS-3.8.0/libblas.a testing # 将上一步编译成功的 libblas.a 复制到 CBLAS目录下的testing子目录
$ make # 编译所有的目录
$ sudo cp lib/cblas_LINUX.a /usr/local/lib/libcblas.a # 将lib文件夹下cblas-LINUX.a文件名改为libcblas.a 将库文件复制到系统库目录下
编译 lapack
进入lapack-3.9.0
文件夹,根据平台将INSTALL
目录下对应的make.inc.XXX
复制一份到 lapack-3.9.0
目录下,并命名为make.inc
, 这里复制的是 INSTALL/make.inc.gfortran
$ sudo cp INSTALL/make.inc.gfortran make.inc
修改Makefile, 因为lapack以来于blas库,所以需要做如下修改
$ sudo gedit Makefile
.PHONY: lib
lib: lapacklib tmglib
#lib: blaslib variants lapacklib tmglib
改为
#lib: lapacklib tmglib
lib: blaslib variants lapacklib tmglib
修改make.inc 文件
$ sudo gedit make.inc
将
#
BLASLIB = $(TOPSRCDIR)/librefblas.a
CBLASLIB = $(TOPSRCDIR)/libcblas.a
LAPACKLIB = $(TOPSRCDIR)/liblapack.a
TMGLIB = $(TOPSRCDIR)/libtmglib.a
LAPACKELIB = $(TOPSRCDIR)/liblapacke.a
改为
BLASLIB = /usr/local/lib/libblas.a
CBLASLIB = /usr/local/lib/libcblas.a
LAPACKLIB = liblapack.a
TMGLIB = libtmglib.a
LAPACKELIB = liblapacke.a
设定好对应的blas
和cblas
目标文件的链接路径(在系统库目录下的)。
$ make # 编译所有的lapack文件
$ cd LAPACKE # 进入LAPACKE 文件夹,这个文件夹包含lapack的C语言接口文件
$ make # 编译lapacke
$ sudo cp include/*.h /usr/local/include #将lapacke的头文件复制到系统头文件目录
$ cd .. #返回到 lapack-3.9.0 目录
$ sudo cp *.a /usr/local/lib # 将生成的所有库文件复制到系统库目录
头文件包括: lapacke.h, lapacke_config.h, lapacke_mangling.h, lapacke_mangling_with_flags.h lapacke_utils.h
库文件包括:liblapack.a, liblapacke.a, librefblas.a, libtmglib.a
检查/usr/local/lib
,发现缺少lapacke_mangling_with_flags.h
,返回LAPACKE/include
文件夹将后缀h.in
修改为.h
,重新复制。
发现缺少liblapacke.a
和libtmglib.a
,发现之前安装过的文件放在/usr/lib/x86_64-linux-gnu
,重新复制。
发现缺少librefblas.a
,且本机无相关文件,阅读make.inc和example文件发现与liblapack.a相同,链接BLASLIB,忽略。
尝试将文件复制到/usr/lib和/usr/include
的目录下
/usr/local/lib$ sudo cp *.a /usr/lib
/usr/local/include$ sudo cp *.h /usr/include
最后发现是文件放在/usr/lib/x86_64-linux-gnu
cmake文件没有搜到,修改OpenCVFindOpenBLAS.cmake
$ sudo gedit opencv/cmake/OpenCVFindOpenBLAS.cmake
找到
SET(Open_BLAS_INCLUDE_SEARCH_PATHS
添加路径/usr/include/x86_64-linux-gnu
找到
SET(Open_BLAS_LIB_SEARCH_PATHS
添加路径/usr/lib/x86_64-linux-gnu
参考:https://www.jianshu.com/p/33c4aea6117b
Could NOT find JNI (missing: JAVA_AWT_LIBRARY JAVA_JVM_LIBRARY JAVA_INCLUDE_PATH JAVA_INCLUDE_PATH2 JAVA_AWT_INCLUDE_PATH)
尝试安装jdk-8u202-linux-x64.tar.gz解决问题
参考:https://blog.csdn.net/zbj18314469395/article/details/86064849
· 下载推荐镜像地址:https://mirrors.huaweicloud.com/java/jdk/
· 解压缩到指定目录(以jdk-8u202-linux-x64.tar.gz为例)
创建目录:
$ sudo mkdir /usr/lib/jvm
解压缩到该目录:
$ sudo tar -zxvf jdk-8u202-linux-x64.tar.gz -C /usr/lib/jvm
· 修改环境变量:
$ sudo gedit ~/.bashrc
在文件末尾追加下面内容:
#set oracle jdk environment
export JAVA_HOME=/usr/lib/jvm/jdk1.8.0_202 ## 这里要注意目录要换成自己解压的jdk 目录
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH
· 使环境变量马上生效:
$ source ~/.bashrc
· 系统注册此jdk
$ sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.8.0_202/bin/java 300
· 查看java版本,看看是否安装成功:
$ java -version
重启生效
VTK is not found. Please set -DVTK_DIR in CMake to VTK build directory, or to VTK install subdirectory with VTKConfig.cmake file
$ sudo apt install libvtk6-dev
一连串的报错
The imported target "vtkHashSource" references the file
"/usr/bin/vtkHashSource-6.3"
but this file does not exist.
$ sudo apt-get install libgl1-mesa-dev
$ sudo apt-get install libglu1-mesa-dev
$ sudo apt-get install freeglut3-dev
$ sudo apt-get install mesa-common-dev
$ sudo apt-get install cmake-curses-gui
下载源码:https://vtk.org/download/
建议使用git clone
$ git clone https://gitlab.kitware.com/vtk/vtk.git
或镜像文件
$ git clone https://hub.fastgit.org/Kitware/VTK
下载的版本为9.0.1
配置VTK
$ cd VTK
$ mkdir build
$ cd build
$ ccmake ..
主要配置选项:
# 按照VTK tutorial要求,每设置完一项均按'c'进行一次configuration,直到所有项目设置完,
BUILD_SHARED_LIBS = ON
BUILD_TESTING = ON # 默认OFF,如果打开的话,编译时会由于下载测试数据所用url过旧而报错,建议OFF
CMAKE_BUILD_TYPE = Release # 默认Debug运行会较慢
CMAKE_INSTALL_PREFIX = /usr/local # 这里用默认就行,或者改到想要安装的位置
# 以下为高级设置,需先在命令行按't'才可见
VTK_FORBID_DOWNLOADS = ON # 默认OFF,建议打开,否则编译会报错,理由同BUILD_TESTING
# 按 c 进行configure
# 此时应已经出现'g' generating 的按键选项,按 'g' 即完成配置.
编译安装VTK
$ cd /VTK/build
$ cmake -DVTK_QT_VERSION:STRING=5 \
-DQT_QMAKE_EXECUTABLE:PATH=/opt/Qt5.12.9/5.12.9/gcc_64/bin/qmake \
-DVTK_Group_Qt:BOOL=ON \
-DCMAKE_PREFIX_PATH:PATH=/opt/Qt5.12.9/5.12.9/gcc_64/lib/cmake \
-DBUILD_SHARED_LIBS:BOOL=ON ..
$ sudo make -j8
$ sudo make install
官方cmake
编译容易报错,可以采用以下的cmake gui
的方式
$ sudo apt install cmake-qt-gui
在build目录下运行
$ cd VTK/build
$ sudo cmake-gui
弹出配置窗口
configure
报错,cmake
版本需要在3.7以上。原版本为3.5.1,需要更新。
ubuntu20.04更新后重复以上操作,会安装3.16.3的版本。
但ubuntu16.04会安装回3.5.1版本,回到cmake-3.18.3
目录,进行编译。
$ cd /opt/cmake-3.18.3
$ ./configure --qt-gui
$ make -j8
$ sudo make install
· cmake上advance
打勾,将VTK_Group_Qt
打勾,制定Qt相应模块的目录
点击configure
点击generate
最后编译:
$ sudo make -j8
$ sudo make install
完成安装,再次编译OpenCV已找到VTK。
若仍然无法找到VTK,用cmake-gui进行配置OpenCV:
1、找到VTK_DIR
,填写VTK
的build
目录
2、勾选WITH_VTK
.
3、勾选BIULD_opencv_world
(勾选此项,编译之后会生成opencv_world.lib)。点击configure
按钮。没有红色标识后,点击generate
按钮。
参考:
https://blog.csdn.net/weixin_30552635/article/details/96263611
https://blog.csdn.net/sinat_28752257/article/details/79169647
https://blog.csdn.net/luolinll1212/article/details/102721840
VTK仍然没有找到,cmake预设目录查找。
发现本机缺少安装Qt5。
采用cmake-gui的时候报错
Found unsuitable Qt version "" from NOTFOUND, this code requires Qt 4.x
Call Stack (most recent call first):
需要qt4.x以上的安装。
下载官网:http://download.qt.io/archive/qt/4.8/4.8.6/
或者选择镜像文件
$ sudo wget https://mirror.tuna.tsinghua.edu.cn/qt/archive/qt/5.12/5.12.9/qt-opensource-linux-x64-5.12.9.run
解压后将文件移动至/opt/
文件夹进行编译安装
$ sudo mv qt-opensource-linux-x64-5.12.9.run /opt/
$ cd /opt/
$ sudo chmod +x qt-opensource-linux-x64-5.12.9.run
$ sudo ./qt-opensource-linux-x64-5.12.9.run
进行注册后按照步骤进行安装
安装成功后返回cmake-gui进行路径设置
重新编译VTK
-- Checking for module 'libavresample'
-- No package 'libavresample' found
安装libavresample
$ sudo apt-get install libavresample-dev
CMake Warning at cmake/OpenCVFindVA_INTEL.cmake:28 (message):
Intel OpenCL installation is not found.
Call Stack (most recent call first):
cmake/OpenCVFindLibsVideo.cmake:333 (include)
CMakeLists.txt:693 (include)
CMake Error at CMakeLists.txt:31 (message):
OpenCV > 2.4.3 not found.
问题应该是OpenCV要求在3.x的版本,但是下载了较高版本的4.5.0,尝试卸载重装。
重新设置OpenCV路径
$ sudo gedit /ORB_SLAM3/CMakeLists.txt
set(OpenCV_DIR /home/username/opencv/build)
find_package(OpenCV REQUIRED)
编译ORB-SLAM3时,出现关于eigen的deprecated错误,如下:
出现这个问题是因为安装的eigen版本太高,需要降低到3.2.1版本。
查看版本
$ sudo gedit /usr/local/include/Eigen/src/Core/util/Macros.h
操作方法:
$ sudo rm -rf /usr/local/include/Eigen
下载
$ sudo wget https://gitlab.com/libeigen/eigen/-/archive/3.2.1/eigen-3.2.1.zip
$ mkdir build && cd build
$ cmake ..
$ sudo make install
参考:https://blog.csdn.net/u010003609/article/details/100676041
-- Performing Test COMPILER_SUPPORT_wd981 - Failed
-- Performing Test COMPILER_SUPPORT_wd2304 - Failed
(2)
qmake: could not find a Qt installation of ''
之前安装过旧版本的 Qt ,所以 qmake 软链接发生错误
$ sudo rm /usr/bin/qmake # 删除原先的链接
$ sudo ln -s Qt-qmake的位置 /usr/bin/qmake #建立新的链接
若仍然未解决
添加#include
到System.h
参考:https://github.com/raulmur/ORB_SLAM2/issues/661
报错
CMake Error at CMakeLists.txt:72 (FIND_PACKAGE):
By not providing "FindEigen3.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "Eigen3", but
CMake did not find one.
Could not find a package configuration file provided by "Eigen3" (requested
version 3.1.0) with any of the following names:
Eigen3Config.cmake
eigen3-config.cmake
Add the installation prefix of "Eigen3" to CMAKE_PREFIX_PATH or set
"Eigen3_DIR" to a directory containing one of the above files. If "Eigen3"
provides a separate development package or SDK, be sure it has been
installed.
对路径为 …/ORB-SLAM3/CMakeLists.txt的47行,进行修改
find_package(Eigen3 3.1.0 REQUIRED)
去掉3.1.0限制,改为
find_package(Eigen3 REQUIRED)
同时对路径 …/ORB_SLAM3/Thirdparty/g2o/CMakeLists.txt
的第72行,进行修改
FIND_PACKAGE(Eigen3 3.1.0 REQUIRED)
去掉3.1.0限制,改为
FIND_PACKAGE(Eigen3 REQUIRED)
参考:https://blog.csdn.net/ly869915532/article/details/107899708
1、找到FindEigen3.cmake
文件路径
/usr/local/include/eigen3/cmake
2、复制到自己这个的工程下
$ sudo cp /usr/local/include/eigen3/cmake/FindEigen3.cmake /home/chan/ORB_SLAM3
3、在工程的CMakeLists.txt里面。
$ sudo gedit ~/ORB_SLAM3/CMakeLists.txt
添加这句话:
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR})
find_package(Eigen3)
if(NOT EIGEN3_FOUND)
# Fallback to cmake_modules
find_package(cmake_modules REQUIRED)
find_package(Eigen REQUIRED)
set(EIGEN3_INCLUDE_DIRS ${EIGEN_INCLUDE_DIRS})
set(EIGEN3_LIBRARIES ${EIGEN_LIBRARIES}) # Not strictly necessary as Eigen is head only
# Possibly map additional variables to the EIGEN3_ prefix.
else()
set(EIGEN3_INCLUDE_DIRS ${EIGEN3_INCLUDE_DIR})
endif()
参考:https://blog.csdn.net/handsome_for_kill/article/details/53288771
/home/chan/ORB_SLAM3/src/Optimizer.cc:28:10: fatal error: unsupported/Eigen/MatrixFunctions: No such file or directory
28 | #include
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
$ cd eigen-3.2.1 #eigen的解压安装包的位置
$ sudo cp -r unsupported/ /usr/local/include
error: static assertion failed: std::map must have the same value_type as its allocator
把ORB-SLAM3
源码目录中include/LoopClosing.h
文件中的
typedef map,
Eigen::aligned_allocator > > KeyFrameAndPose;
修改为
typedef map,
Eigen::aligned_allocator > > KeyFrameAndPose;