Ubuntu 16.04 64位+Qt 5.7.1+opencv 3.2.0 + opencv_contrib 3.2.0

Ubuntu 16.04 64位+Qt 5.7.1+opencv 3.2.0 + opencv_contrib 3.2.0

author@jason_ql
http://blog.csdn.net/lql0716/article/details/54564721

Qt类似visual studio,方便操作,而且有代码提示,是个不错的IDE工具,linux、windows、mac各个版本都有。

  • 各个工具的版本如下:
    • Ubuntu: 16.04 64bit
    • Qt:5.7.1
    • opencv:3.2.0
    • opencv_contrib:3.2.0

opencv3.2.0为2016年12月最新发布的opencv版本。

1. 下载安装包

  • Qt 下载页:https://www.qt.io/download-open-source/

    可以下载各个系统各个版本的Qt

  • Qt 5.7.1下载链接:

    • 链接1:Download

      此链接为Qt 5.7.1的linux离线安装包

    • 链接2:Download

      此链接为Qt 5.7.1的linux离线安装包

    这里写图片描述

  • opencv 3.2.0下载链接:

    链接1:Download1、 Download2

    链接2:Download

    Ubuntu 16.04 64位+Qt 5.7.1+opencv 3.2.0 + opencv_contrib 3.2.0_第1张图片

  • opencv_contrib 3.2.0 下载链接

    链接1:Download

    链接2:
    “wget https://github.com/opencv/opencv_contrib/archive/3.2.0.tar.gz \
    -O opencv_contrib-3.2.0.tar.gz”

    在终端输入以上命令即可下载

    Ubuntu 16.04 64位+Qt 5.7.1+opencv 3.2.0 + opencv_contrib 3.2.0_第2张图片

  • opencv_contrib各个版本下载链接:Download

    • 如果想安装其他版本的opencv_contrib,可以在该链接下载,如果不需要,则不需下载,这里只是给出全部链接,方便收藏其他版本。

    Ubuntu 16.04 64位+Qt 5.7.1+opencv 3.2.0 + opencv_contrib 3.2.0_第3张图片


2. 安装

2.1安装Qt

2.1.1 安装qt-opensource-linux-x64-5.7.1.run

首先双击qt-opensource-linux-x64-5.7.1.run,如果能直接双击安装,则直接安装即可,如果不能直接安装,则按照下面的步骤进行操作。

这里写图片描述

  • 1、将下载的安装文件qt-opensource-linux-x64-5.7.1.run拷贝到home/用户目录,如/home/user
  • 2 、如果qt-opensource-linux-x64-5.7.1.run的属性中拥有者没有运行权限,则可用chmod命令添加执行权限:

    chmod u+x qt-opensource-linux-x64-5.7.1.run

  • 3 、在终端执行:

    ./ qt-opensource-linux-x64-5.7.1.run

  • 4、跳出安装界面,一直点击下一步,直到安装完成即可。


2.2 安装opencv3.2.0

2.2.1 安装opencv依赖库

在终端输入以下命令,进行安装opencv依赖库:

1. sudo apt-get install build-essential

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

3. sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev  
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

2.2.2 cmake

  • 1、将下载的opencv-3.2.0 for linux.zip解压提取

    提取时可以将提取的文件夹存放在/home/user路径下,提取的文件夹名字为:opencv-3.2.0
    这里写图片描述

  • 2、在文件夹opencv-3.2.0下新建文件夹build
    Ubuntu 16.04 64位+Qt 5.7.1+opencv 3.2.0 + opencv_contrib 3.2.0_第4张图片

  • 3、进入build目录并cmake:

在终端执行以下两步:

第一步:
cd opencv-3.2.0/build

第二步:
cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local/opencv320 -D OPENCV_EXTRA_MODULES_PATH=/home/jason/opencv_contrib-3.2.0/modules/ ..

如果不安装opencv_contrib模块,则第二步的命令为:
cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local/opencv320
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11

其中 CMAKE_INSTALL_PREFIX=/usr/local/opencv320 是指将要install的路径,一般默认为 /usr/local,这里 /usr/local/opencv320 是opencv的安装路径;

其中 OPENCV_EXTRA_MODULES_PATH=/home/jason/opencv_contrib-3.2.0/modules/ .. 是指 opencv_contrib-3.2.0 中 modules 所在的路径,后面的两点不可省略;

cmake过程中可能遇到的问题:

如果网络不好,出现ippicv_linux_20151201.tgz无法在终端下载的情况,则可以先单独下载ippicv_linux_20151201.tgz之后,把其移动到终端所提示的路径(终端会提示该路径找不到文件),如路径/opencv-3.2.0/3rdparty/ippicv/downloads/linux-808b791a6eac9ed78d32a7666804320e/

移动的时候,可以另外打开一个终端操作:
sudo mv ippicv_linux_20151201.tgz /opencv-3.2.0/3rdparty/ippicv/downloads/linux-808b791a6eac9ed78d32a7666804320e

如果同样有其他类似的文件无法下载,方法同上。

  • 4、make 与 install
    在第3步cmake完成之后,进行如下操作:
在终端执行以下两步:

第1步:
sudo make

第2步:
sudo make install
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7

以上2步结束之后,如果没有提示error,则为opencv3.2.0 、opencv_contrib 3.2.0安装成功


3. Qt 5.7.1调用opencv3.2.0

  • 1、打开Qt,点击“New Project”

Ubuntu 16.04 64位+Qt 5.7.1+opencv 3.2.0 + opencv_contrib 3.2.0_第5张图片

  • 2、依次选择:application——Qt Console Application,点击右下角Choose

Ubuntu 16.04 64位+Qt 5.7.1+opencv 3.2.0 + opencv_contrib 3.2.0_第6张图片

  • 3、可修改“名称”创建新的路径,也可为默认值。

Ubuntu 16.04 64位+Qt 5.7.1+opencv 3.2.0 + opencv_contrib 3.2.0_第7张图片

  • 4、打开QtOpenCV.pro文件,在其最下面添加如下内容:

注意:以下内容为cmake时设置的路径CMAKE_INSTALL_PREFIX=/usr/local/opencv320下的路径及相应的文件,一般默认的路径是/usr/local/,总之,在cmake时设置的路径下找下列内容即可。

INCLUDEPATH += /usr/local/opencv320/include \
/usr/local/opencv320/include/opencv \
/usr/local/opencv320/include/opencv2

LIBS += /usr/local/opencv320/lib/libopencv_aruco.so \
/usr/local/opencv320/lib/libopencv_bgsegm.so \
/usr/local/opencv320/lib/libopencv_bioinspired.so \
/usr/local/opencv320/lib/libopencv_calib3d.so \
/usr/local/opencv320/lib/libopencv_ccalib.so \
/usr/local/opencv320/lib/libopencv_core.so \
/usr/local/opencv320/lib/libopencv_datasets.so \
/usr/local/opencv320/lib/libopencv_dnn.so \
/usr/local/opencv320/lib/libopencv_dpm.so \
/usr/local/opencv320/lib/libopencv_face.so \
/usr/local/opencv320/lib/libopencv_features2d.so \
/usr/local/opencv320/lib/libopencv_flann.so \
/usr/local/opencv320/lib/libopencv_freetype.so \
/usr/local/opencv320/lib/libopencv_fuzzy.so \
/usr/local/opencv320/lib/libopencv_highgui.so \
/usr/local/opencv320/lib/libopencv_imgcodecs.so \
/usr/local/opencv320/lib/libopencv_imgproc.so \
/usr/local/opencv320/lib/libopencv_ml.so \
/usr/local/opencv320/lib/libopencv_objdetect.so \
/usr/local/opencv320/lib/libopencv_optflow.so \
/usr/local/opencv320/lib/libopencv_phase_unwrapping.so \
/usr/local/opencv320/lib/libopencv_photo.so \
/usr/local/opencv320/lib/libopencv_plot.so \
/usr/local/opencv320/lib/libopencv_reg.so \
/usr/local/opencv320/lib/libopencv_rgbd.so \
/usr/local/opencv320/lib/libopencv_saliency.so \
/usr/local/opencv320/lib/libopencv_shape.so \
/usr/local/opencv320/lib/libopencv_stereo.so \
/usr/local/opencv320/lib/libopencv_stitching.so \
/usr/local/opencv320/lib/libopencv_structured_light.so \
/usr/local/opencv320/lib/libopencv_superres.so \
/usr/local/opencv320/lib/libopencv_surface_matching.so \
/usr/local/opencv320/lib/libopencv_text.so \
/usr/local/opencv320/lib/libopencv_tracking.so \
/usr/local/opencv320/lib/libopencv_video.so \
/usr/local/opencv320/lib/libopencv_videoio.so \
/usr/local/opencv320/lib/libopencv_videostab.so \
/usr/local/opencv320/lib/libopencv_xfeatures2d.so \
/usr/local/opencv320/lib/libopencv_ximgproc.so \
/usr/local/opencv320/lib/libopencv_xobjdetect.so \
/usr/local/opencv320/lib/libopencv_xphoto.so \
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45

Ubuntu 16.04 64位+Qt 5.7.1+opencv 3.2.0 + opencv_contrib 3.2.0_第8张图片

  • 5、打开main.cpp,将以下代码复制进去进行测试
#include 
#include 
#include 
#include 

using namespace cv;

int main()
{
//    QCoreApplication a(argc, argv);
    String title = "img";
    namedWindow( title, WINDOW_AUTOSIZE );
    Mat src1 = imread( "/home/photo/1.jpg" );
    cv::namedWindow(title,cv::WINDOW_NORMAL);
    cv::imshow( title, src1 );
    cv::waitKey(0);
    cv::destroyAllWindows();
//    return a.exec();
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 如果能成功运行,则Qt 5.7.1+opencv 3.2.0 + opencv_contrib 3.2.0成功配置了,可以欢快的使用了。

  • 如果提示以下错误:
    QtOpenCV: error while loading shared libraries: libopencv_core.so.3.2: cannot open shared object file: No such file or directory
    则请参看以下博文的解决方法:http://blog.csdn.net/lql0716/article/details/54434695

4、 ubuntu 16.04 + Qt 5.7.1 无法输入中文的解决方法

  • 参看链接:http://blog.csdn.net/lql0716/article/details/54973160

5、Ubuntu 16.04 64位+anaconda2+opencv 3.2.0 + opencv_contrib 3.2.0

  • python/anaconda2配置opencv3.2.0参看链接:
    http://blog.csdn.net/lql0716/article/details/54910014

6、Windows10 + Visual Studio Ultimate 2013(VS2013) + opencv2413

  • 链接:http://blog.csdn.net/lql0716/article/details/64124700

7、 Windows10 + anaconda2 + opencv2413

  • (1)双击opencv、anaconda2的安装包即可安装

  • (2)默认opencv的安装路径为:C:\opencv

  • (3)默认anaconda2的安装路径为:C:\Anaconda2

  • (4)安装成功之后,将opencv中的路径“C:\opencv\build\python\2.7\x86
    ”的文件cv2.pyd,复制到anaconda2的路径“C:\Anaconda2\Lib\site-packages”中即可使用。

  • 或者参考以下的安装方法
    链接:http://blog.csdn.net/lql0716/article/details/52302458

8、 ubuntu 16.04 + VTK6.3.0 + opencv2.4.13-viz(3D可视化)安装教程

  • 链接:http://blog.csdn.net/lql0716/article/details/71836702

你可能感兴趣的:(Ubuntu 16.04 64位+Qt 5.7.1+opencv 3.2.0 + opencv_contrib 3.2.0)