虚拟机Ubuntu下opencv4.0和opencv_contrib4.0的编译安装

1.安装依赖包

sudo apt-get install build-essential  
  
sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev  
  
sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev  

sudo apt-get install build-essential qt5-default ccache libv4l-dev libavresample-dev  libgphoto2-dev libopenblas-base libopenblas-dev doxygen  openjdk-8-jdk pylint libvtk6-dev

sudo apt-get install pkg-config

sudo apt-get install libcanberra-gtk*

2.解压下载好的安装包

sudo tar -xf opencv-4.0.0.tar.gz
sudo tar -xf opencv_contrib-4.0.0.tar.gz 

3.解压完后需要将opencv_contrib复制到opencv目录下,同时在该目录下新建一个文件夹build并打开该文件夹

4.执行cmake生成makefile文件,注意:OPENCV_EXTRA_MODULES_PATH就是你 opencv_contrib-4.0.0下面的modules的绝对路径目录,请按照自己的实际目录修改地址。还有后面的两点不可省略!!

sudo cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local -D OPENCV_EXTRA_MODULES_PATH=/home/long/Documents/Opencv/opencv-4.0.0/opencv_contrib-4.0.0/modules/ ..

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

sudo make -j8    	#8线程编译
sudo make install

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

sudo ldconfig -v  

 

你可能感兴趣的:(OpenCV)