视觉SLAM十四讲用到了opencv3.1,而opencv3.3增加了深度学习方面的应用,因此,编译二者用于下一步的学习和研究。
1.安装opencv3.1
安装参考链接:https://docs.opencv.org/3.1.0/d7/d9f/tutorial_linux_install.html
简要步骤:
1.1 需要的包
[compiler] sudo apt-get install build-essential
[required] sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev
[optional] sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev
1.2 下载opencv3.1
打包下载:https://github.com/opencv/opencv/archive/3.1.0.zip
也可以github源码下载:
cd ~/<my_working_directory>
git clone https://github.com/Itseez/opencv.git
git clone https://github.com/Itseez/opencv_contrib.git
1.3 编译安装
cd ~/opencv
mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local ..
(也可以cmake ..)
make -j7
sudo make install
1.4 可能碰到的问题
-- ICV: Downloading ippicv_linux_20151201.tgz...
CMake Error at 3rdparty/ippicv/downloader.cmake:73 (file):
file DOWNLOAD HASH mismatch
for file: [/home/huicanlin/Downloads/software/opencv-3.1.0/3rdparty/ippicv/downloads/linux-808b791a6eac9ed78d32a7666804320e/ippicv_linux_20151201.tgz]
expected hash: [808b791a6eac9ed78d32a7666804320e]
actual hash: [f13eaae8a6fdcdd119ee111515313781]
解决办法:
手动下载该文件,放到适当的路径,重新编译即可。
下载链接:
(1)http://www.linuxfromscratch.org/blfs/view/7.9/general/opencv.html
(2) https://pan.baidu.com/s/1gfgYnDp 密码: 242j
适当路径:/opencv-3.1.0/3rdparty/ippicv/downloads/linux-808b791a6eac9ed78d32a7666804320e/
2安装opencv3.3
安装参考链接:https://docs.opencv.org/3.3.0/d7/d9f/tutorial_linux_install.html
简要步骤:
2.1需要的包
[compiler] sudo apt-get install build-essential
[required] sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev
[optional] sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev
2.2下载opencv3.3
下载链接:https://github.com/opencv/opencv/archive/3.3.0.zip
当然也可以github上下载源码
2.3编译安装
cd ~/opencv
mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local ..
(也可以cmake ..)
make -j7
sudo make install
2.4可能碰到的问题
在cmake ..步骤中,下载ippicv_2017u2_lnx_intel64_20170418.tgz文件的时候出错.
解决办法也是手动下载,并放到合适路径,该问题的解决办法参考链接:https://github.com/opencv/opencv/issues/8641。
链接简要内容:
> $ cat CMakeDownloadLog.txt
use_cache "/home/alalek/projects/opencv/dev/.cache"
do_unpack "ippicv_2017u2_lnx_intel64_20170418.tgz" "87cbdeb627415d8e4bc811156289fa3a" "https://raw.githubusercontent.com/opencv/opencv_3rdparty/a62e20676a60ee0ad6581e217fe7e4bada3b95db/ippicv/ippicv_2017u2_lnx_intel64_20170418.tgz" "/home/alalek/projects/opencv/build/opencv/3rdparty/ippicv"
#cmake_download "/home/alalek/projects/opencv/dev/.cache/ippicv/87cbdeb627415d8e4bc811156289fa3a-ippicv_2017u2_lnx_intel64_20170418.tgz" "https://raw.githubusercontent.com/opencv/opencv_3rdparty/a62e20676a60ee0ad6581e217fe7e4bada3b95db/ippicv/ippicv_2017u2_lnx_intel64_20170418.tgz"Take a look on #cmake_download
line.
下载链接:
(1)http://linuxfromscratch.org/blfs/view/svn/general/opencv.html
(2) https://pan.baidu.com/s/1bR9wdS 密码: maj4
适当路径:~/Downloads/software/opencv-3.3.0/.cache/ippicv/
将下载的文件重命名为:87cbdeb627415d8e4bc811156289fa3a-ippicv_2017u2_lnx_intel64_20170418.tgz
重新编译安装即可。