Linux Mint 18 下部署OpenCV 3.4.10

操作系统信息

jwllinux@jwlLinux ~ $ uname -a

Linux jwlLinux 4.4.0-21-generic #37-Ubuntu SMP Mon Apr 18 18:34:49 UTC 2016 i686 i686 i686 GNU/Linux

jwllinux@jwlLinux ~ $ lsb_release -a

LSB Version:    core-9.20160110ubuntu0.2-ia32:core-9.20160110ubuntu0.2-noarch:cxx-3.0-ia32:cxx-3.0-noarch:cxx-3.1-ia32:cxx-3.1-noarch:cxx-3.2-ia32:cxx-3.2-noarch:cxx-4.0-ia32:cxx-4.0-noarch:cxx-4.1-ia32:cxx-4.1-noarch:security-9.20160110ubuntu0.2-ia32:security-9.20160110ubuntu0.2-noarch

Distributor ID: LinuxMint

Description:    Linux Mint 18 Sarah

Release:        18

Codename:       sarah

下载opencv3. 4.10源码

下载链接:https://opencv.org/releases/

opencv-3.4.10.zip

依赖包安装

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 pkg-config libgtk2.0-dev libavcodec-dev libavformat-dev libswscale-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev

 

sudo apt-get install libtbb2 libtbb-dev

TBBThread Building Blocks线程构建模块

sudo apt install qtbase5-dev

 

主要工具版本

jwllinux@jwlLinux ~/Downloads $ cmake -version

cmake version 3.5.1

jwllinux@jwlLinux ~/Downloads $ make -v

GNU Make 4.1

jwllinux@jwlLinux ~/Downloads $ gcc --version

gcc (Ubuntu 5.4.0-6ubuntu1~16.04.12) 5.4.0 20160609

jwllinux@jwlLinux ~/Downloads $ g++ --version

g++ (Ubuntu 5.4.0-6ubuntu1~16.04.12) 5.4.0 20160609

Copyright (C) 2015 Free Software Foundation, Inc.

jwllinux@jwlLinux ~/Downloads $ git --version

git version 2.7.4

解压组织、编译、安装

  解压文件,新建一个文件夹用于安放编译结果,然后安装(选择安装在/usr/local下面) 

$ unzip opencv-3.4.10.zip
$ cd opencv-3.4.10
$ mkdir release
$ cd release
$ cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_TBB=ON -D WITH_V4L=ON -D WITH_QT=OFF -D WITH_OPENGL=OFF ..

说明:

    这里面主要是 CMake的一些配置项,最后的‘..’ 表示到上层目录下去找CMakeLists.txt文件,笔者看了下OpenCV项目提供的CMakeLists.txt文件,相对复杂,就不过多介绍了。

   另外,知乎文档评价CMake,学习曲线确实高。链接如下:

如何评价CMake

cmake -D

-D :=, -D =

              Create a cmake cache entry.

..

表示CMakeLists.txt在上层目录

执行完后,会产生整个OpenCV项目的构建文件(build),输出如下:

Linux Mint 18 下部署OpenCV 3.4.10_第1张图片

$ make -j $(nproc)      

   // make -j 多核处理器进行编译(默认的make只用一核,很慢),$(nproc)返回自己机器的核数

Linux Mint 18 下部署OpenCV 3.4.10_第2张图片

 

 $ make install                 //把编译结果安装到 /usr/local的 lib/ 和 include/下面

可能遇到的问题

CMake构建使用Qt5源代码。它退出了这个错误:

         CMake Error at CMakeLists.txt:20 (find_package):By not providing "FindQt5Core.cmake" in CMAKE_MODULE_PATH this project has asked CMake to find a package configuration file provided by "Qt5Core", but CMake did not find one.Could not find a package configuration file provided by "Qt5Core" with any of the following names:

    Qt5CoreConfig.cmake

    qt5core-config.cmake

  Add the installation prefix of "Qt5Core" to CMAKE_PREFIX_PATH or set "Qt5Core_DIR" to a directory containing one of the above files.If "Qt5Core" provides a separate development package or SDK, be sure it has been installed.

解决方案:

​​​​​​​方案一:

     需要安装包qtbase5-dev

 

$ sudo apt install qtbase5-dev

方案二:

  Cmake构建选项中,将-D WITH_QT=OFF 填为OFF

至于此构建选项对编译处理的OpenCV的影响,笔者后续用到后再作详细分析。

 

你可能感兴趣的:(Image,Process)