Ubuntu18.04编译opencv3.4.0 opencv_contrib3.4.0 nonfree world

1.文件准备

wget https://github.com/opencv/opencv/archive/3.4.0.zip
wget https://github.com/opencv/opencv_contrib/archive/3.4.0.zip

2.安装依赖包

一个个装:
2.1

sudo apt-get install build-essential  

2.2

sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev  

2.3

sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev  

对于2.3出现的错误:E: Unable to locate package libjasper-dev的解决办法::

sudo add-apt-repository "deb http://security.ubuntu.com/ubuntu xenial-security main"
sudo apt update
sudo apt install libjasper1 libjasper-dev

2.4

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

2.5

sudo apt-get install pkg-config

3.编译

3.1解压

sudo unzip opencv-3.4.0.zip
sudo unzip opencv_contrib-3.4.0.zip

3.2 cmake

cd opencv-3.4.0
sudo mkdir build
cd build
sudo cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local -D OPENCV_EXTRA_MODULES_PATH=/home/dayday/opencv_contrib-3.4.0/modules -D OPENCV_ENABLE_NONFREE:BOOL=ON -D BUILD_opencv_world:BOOL=ON ..    

注意这一步的编译参数:

  • -D OPENCV_ENABLE_NONFREE:BOOL=ON
  • -D BUILD_opencv_world:BOOL=ON
  • 其他的参数可以自行选择
    这个过程需要下载ippicv和face_landmark_model.dat,下载速度很慢,最好酸酸乳~
    如果没法酸酸乳,那就用下载后修改文件,见https://blog.csdn.net/CSDN330/article/details/86747867

3.3 make

sudo make -j8
sudo make install

3.4 condig

sudo ldconfig -v

你可能感兴趣的:(Ubuntu18.04编译opencv3.4.0 opencv_contrib3.4.0 nonfree world)