ubuntu14.04 +opencv3.4.6+opencv_contrib3.4.6配置

1. 下载:一定要下载对应版本!

下载源码:https://github.com/opencv/opencv/releases/tag/3.4.6

下载contrib:https://github.com/opencv/opencv_contrib/releases/tag/3.4.6

ubuntu14.04 +opencv3.4.6+opencv_contrib3.4.6配置_第1张图片

2. 安装

(1) 安装相关包

安装前的必备包

sudo apt-get install build-essential 

sudo apt-get install cmake git g++

安装依赖包

sudo apt-get install libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev libv4l-dev liblapacke-dev
sudo apt-get install checkinstall yasm libxine2-dev libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev libfaac-dev libmp3lame-dev libtheora-dev
sudo apt-get install libopencore-amrnb-dev libopencore-amrwb-dev libavresample-dev x264 v4l-utils

处理图像所需的包

sudo apt-get install libtbb2 libtbb-dev libjpeg-dev libpng12-dev libtiff5-dev libjasper-dev

处理视频所需包

sudo apt-get install libxvidcore-dev libx264-dev

opencv功能优化

sudo apt-get install libatlas-base-dev gfortran 

部分依赖包

sudo apt-get install libopencv-dev qt4-qmake libqglviewer-dev libsuitesparse-dev
sudo apt-get install python-dev python-numpy

可选依赖

sudo apt-get install libprotobuf-dev protobuf-compiler
sudo apt-get install libgoogle-glog-dev libgflags-dev
sudo apt-get install libgphoto2-dev libeigen3-dev libhdf5-dev doxygen

(2)安装完成后,把contrib文件夹放入opencv目录下,并且创建build文件夹;

ubuntu14.04 +opencv3.4.6+opencv_contrib3.4.6配置_第2张图片

手动下载 ippicv_2019_lnx_intel64_general_20180723.tgz,放到/home/joanna/software/文件夹下,并修改opencv/3rdparty/ippicv/ippicv.cmake:

"https://raw.githubusercontent.com/opencv/opencv_3rdparty/${IPPICV_COMMIT}/ippicv/"
修改为:
"file:/home/joanna/software/" 

(3) cmake-gui编译opencv-contrib源码

#安装cmake-gui
sudo apt-get install cmake-gui
#启动cmake-gui
cmake-gui

 ubuntu14.04 +opencv3.4.6+opencv_contrib3.4.6配置_第3张图片

点击configure选择Unix Makefiles,完成后,按如下配置:

1)在CMAKE_BUILD_TYPE 值处输入RELEASE

ubuntu14.04 +opencv3.4.6+opencv_contrib3.4.6配置_第4张图片

2)在OPENCV_EXTRA_MODULES_PATH处,选择输入目录:opencv_contrib文件夹中的modules文件夹 

 

 点击Generate,编译完成。

(4)或者 命令行编译opencv-contrib源码

#
cd build  
#
sudo cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local -D OPENCV_EXTRA_MODULES_PATH=/home/joanna/software/opencv-3.4.6/opencv_contrib-3.4.6/modules/ .. 

在cmake成功之后,就可以在build文件下make了:

sudo make -j8 #8线程编译

sudo make install

(5)链接库共享
编译安装完毕之后,为了让你的链接库被系统共享,让编译器发现,需要执行管理命令ldconfig:

sudo ldconfig -v 

你可能感兴趣的:(C/C++编程)