安装ORB-SLAM3的过程

1.安装Pangolin

下载源码:git clone https://github.com/stevenlovegrove/Pangolin.git
根据https://github.com/stevenlovegrove/Pangolin#scheme-syntax-for-windowing-and-video
安装依赖
安装:

git clone https://github.com/stevenlovegrove/Pangolin.git
cd Pangolin
mkdir build
cd build
cmake ..
make -j4
sudo make install

出现问题1:

/usr/bin/ld: warning: libopencv_core.so.2.4, needed by //usr/lib/x86_64-linux-gnu/libavfilter-ffmpeg.so.5, not found (try using -rpath or -rpath-link)
/usr/bin/ld: warning: libopencv_imgproc.so.2.4, needed by //usr/lib/x86_64-linux-gnu/libavfilter-ffmpeg.so.5, not found (try using -rpath or -rpath-link)
//usr/lib/x86_64-linux-gnu/libavfilter-ffmpeg.so.5: undefined reference to `cvSmooth'
//usr/lib/x86_64-linux-gnu/libavfilter-ffmpeg.so.5: undefined reference to `cvErode'
//usr/lib/x86_64-linux-gnu/libavfilter-ffmpeg.so.5: undefined reference to `cvReleaseStructuringElement'
//usr/lib/x86_64-linux-gnu/libavfilter-ffmpeg.so.5: undefined reference to `cvCreateStructuringElementEx'
//usr/lib/x86_64-linux-gnu/libavfilter-ffmpeg.so.5: undefined reference to `cvCreateImageHeader'
//usr/lib/x86_64-linux-gnu/libavfilter-ffmpeg.so.5: undefined reference to `cvDilate'
collect2: error: ld returned 1 exit status
tools/VideoViewer/CMakeFiles/VideoViewer.dir/build.make:122: recipe for target 'tools/VideoViewer/VideoViewer' failed
make[2]: *** [tools/VideoViewer/VideoViewer] Error 1
CMakeFiles/Makefile2:289: recipe for target 'tools/VideoViewer/CMakeFiles/VideoViewer.dir/all' failed
make[1]: *** [tools/VideoViewer/CMakeFiles/VideoViewer.dir/all] Error 2
Makefile:149: recipe for target 'all' failed
make: *** [all] Error 2

解决:问题就在ffmpeg不兼容,可能是版本原因,卸载ffmpeg

sudo apt-get purge ffmpeg

卸载后在官网上手动下载:http://ffmpeg.org/releases/ffmpeg-4.3.tar.xz
再解压,安装: 参考

./configure   --enable-shared  --prefix=/usr/local/ffmpeg  --enable-gpl --enable-libx264  --enable-libx265   

若首次configure 会提示yasm未安装错误,处理这个问题很简单,直接安装yasm即可,具体方法是 在命令行终端执行sudo apt-get install yasm。

make

出现问题2:
ERROR: libx264 not found
解决:
git clone git://git.videolan.org/x264
cd x264
./configure --enable-shared    //动态库
make
make install

出现问题3:
ERROR: x265 not found using pkg-config
解决:
# ubuntu packages:
$ sudo apt-get install mercurial cmake cmake-curses-gui build-essential yasm
# Note: if the packaged yasm is older than 1.2, you must download yasm-1.2 and build it
$ hg clone https://bitbucket.org/multicoreware/x265 //下载慢
$https://git.oschina.net/OpenWrt-X/X265.git           //自己同步的 国内下载快 任选一个
$ cd x265/build/linux
$ ./make-Makefiles.bash
$ make
$sudo make install  

重新编译ffmpeg
make
make install

增加安装目录的动态链接库:

export LD_LIBRARY_PATH=/usr/local/ffmpeg/lib:$LD_LIBRARY_PATH

查看指令依赖的动态库

ldd ffmpeg 

测试

ffmpeg  –version

出现错误:

ffmpeg: error while loading shared libraries: libopencv_core.so.2.4: cannot open shared object file: No such file or directory

后面重新编译Panglin时也会出现如下错误

/usr/bin/ld: warning: libopencv_core.so.2.4, needed by //usr/lib/x86_64-linux-gnu/libavfilter-ffmpeg.so.5, not found (try using -rpath or -rpath-link)
/usr/bin/ld: warning: libopencv_imgproc.so.2.4, needed by //usr/lib/x86_64-linux-gnu/libavfilter-ffmpeg.so.5, not found (try using -rpath or -rpath-link)
//usr/lib/x86_64-linux-gnu/libavfilter-ffmpeg.so.5:对‘cvSmooth’未定义的引用
//usr/lib/x86_64-linux-gnu/libavfilter-ffmpeg.so.5:对‘cvErode’未定义的引用
//usr/lib/x86_64-linux-gnu/libavfilter-ffmpeg.so.5:对‘cvReleaseStructuringElement’未定义的引用
//usr/lib/x86_64-linux-gnu/libavfilter-ffmpeg.so.5:对‘cvCreateStructuringElementEx’未定义的引用
//usr/lib/x86_64-linux-gnu/libavfilter-ffmpeg.so.5:对‘cvCreateImageHeader’未定义的引用
//usr/lib/x86_64-linux-gnu/libavfilter-ffmpeg.so.5:对‘cvDilate’未定义的引用

这个问题太烦了,经过谷歌查询,解决方法如下:
下载文件libopencv_core.so.2.4等
将文件夹文件全部放在/usr/lib/x86_64-linux-gun/下

测试

播放IPC摄像头的RTSP流媒体:

ffplay rtsp://192.168.0.123/live/av0

ffmpeg安装完成后,重新编译Pangolin

make -j4
sudo make install

安装opencv3.4

参考链接

安装Eigen3(确认所需版本)

Eigen是一个C++开源线性代数库。它提供了快速的有关矩阵的线性代数运算及求解方程等功能。
执行

sudo apt-get install libeigen3-dev

Eigen头文件存放在“/usr/include/eigen3”中。

编译ORBSLAM3

1、编译过程中遇到Eigen问题,解决办法:
参考该博客解决:Eigen问题
2、如果遇到卡死问题,将./build.sh文件中的 -j4删除
3、还有上面的ffmpeg问题(解决办法在上面):

/usr/bin/ld: warning: libopencv_core.so.2.4, needed by //usr/lib/x86_64-linux-gnu/libavfilter-ffmpeg.so.5, not found (try using -rpath or -rpath-link)
/usr/bin/ld: warning: libopencv_imgproc.so.2.4, needed by //usr/lib/x86_64-linux-gnu/libavfilter-ffmpeg.so.5, not found (try using -rpath or -rpath-link)
//usr/lib/x86_64-linux-gnu/libavfilter-ffmpeg.so.5:对‘cvSmooth’未定义的引用
//usr/lib/x86_64-linux-gnu/libavfilter-ffmpeg.so.5:对‘cvErode’未定义的引用
//usr/lib/x86_64-linux-gnu/libavfilter-ffmpeg.so.5:对‘cvReleaseStructuringElement’未定义的引用
//usr/lib/x86_64-linux-gnu/libavfilter-ffmpeg.so.5:对‘cvCreateStructuringElementEx’未定义的引用
//usr/lib/x86_64-linux-gnu/libavfilter-ffmpeg.so.5:对‘cvCreateImageHeader’未定义的引用
//usr/lib/x86_64-linux-gnu/libavfilter-ffmpeg.so.5:对‘cvDilate’未定义的引用

运行双目EuRoC数据集

https://blog.csdn.net/Banmei_Brandy/article/details/90239123

你可能感兴趣的:(opencv,C++,软件,c++,linux,opencv)