美文网首页
在QT下配置opencv

在QT下配置opencv

作者: Westring | 来源:发表于2018-04-26 21:23 被阅读0次

    花了一天时间终于大功告成了,主要事件都花在下载opencv的开源代码上了,虽然不大(也就80多M),但是网速炸啊。十几二十几K的下,开了vpn都没用,一样是龟速。言归正传

    要准备三样东西,一个是QT的开源代码(注意是源码,不是什么安装包),一个是CMake,还有一个就是opencv啦。具体的链接自己去官网找吧。。。我用的是qt5.5.1,CMake最新版,opencv2.4.11(因为最新的opencv我编译的时候总是出错,只好用opencv2了)

    首先要把QT装好,然后配置好环境变量Path,这也不细说。接下来安装CMake,注意勾选将XXX加入环境变量。装好CMake后就可以开始安装opencv啦。先把下好的opencv源码解压好,打开CMake,在源路径中填上源码的路径,在目标路径中填上你想安装的路径(最好是你要安装的位置,见一个build文件夹)不用源码安装的话,目录下最终会生成build,source文件夹,分别存放待编译的文件和源码。

    点击configure,然后选WINGW Makefile 和下面第二个选项,然后c和c++的编译器要到QT的安装目录的mingw里面找。等待。然后勾上WITH_QT,WITH_OPENGL;在次点击configure(重要!)。然后generate;

    进入cmd,找到相应目录,mingw32-make 漫长的等待。。。。   mingw32-make install

    安装成功,接下来就是配置。

    下面是我的 pro 配置

    QT += core gui widgets

    TARGET = opencvtest

    CONFIG += console

    CONFIG -= app_bundle

    TEMPLATE = app

    SOURCES += main.cpp

    INCLUDEPATH += $$quote(C:\Program Files\opencv2411\install\include\opencv)

    INCLUDEPATH += $$quote(C:\Program Files\opencv2411\install\include\opencv2)

    INCLUDEPATH += $$quote(C:\Program Files\opencv2411\install\include)

    LIBS +=  $$quote(C:\Program Files\opencv2411\install\x64\mingw\lib\libopencv_calib3d2411.dll.a)

    LIBS +=  $$quote(C:\Program Files\opencv2411\install\x64\mingw\lib\libopencv_contrib2411.dll.a)

    LIBS +=  $$quote(C:\Program Files\opencv2411\install\x64\mingw\lib\libopencv_core2411.dll.a)

    LIBS +=  $$quote(C:\Program Files\opencv2411\install\x64\mingw\lib\libopencv_features2d2411.dll.a)

    LIBS +=  $$quote(C:\Program Files\opencv2411\install\x64\mingw\lib\libopencv_flann2411.dll.a)

    LIBS +=  $$quote(C:\Program Files\opencv2411\install\x64\mingw\lib\libopencv_gpu2411.dll.a)

    LIBS +=  $$quote(C:\Program Files\opencv2411\install\x64\mingw\lib\libopencv_highgui2411.dll.a)

    LIBS +=  $$quote(C:\Program Files\opencv2411\install\x64\mingw\lib\libopencv_imgproc2411.dll.a)

    LIBS +=  $$quote(C:\Program Files\opencv2411\install\x64\mingw\lib\libopencv_legacy2411.dll.a)

    LIBS +=  $$quote(C:\Program Files\opencv2411\install\x64\mingw\lib\libopencv_ml2411.dll.a)

    LIBS +=  $$quote(C:\Program Files\opencv2411\install\x64\mingw\lib\libopencv_nonfree2411.dll.a)

    LIBS +=  $$quote(C:\Program Files\opencv2411\install\x64\mingw\lib\libopencv_objdetect2411.dll.a)

    LIBS +=  $$quote(C:\Program Files\opencv2411\install\x64\mingw\lib\libopencv_ocl2411.dll.a)

    LIBS +=  $$quote(C:\Program Files\opencv2411\install\x64\mingw\lib\libopencv_photo2411.dll.a)

    LIBS +=  $$quote(C:\Program Files\opencv2411\install\x64\mingw\lib\libopencv_stitching2411.dll.a)

    LIBS +=  $$quote(C:\Program Files\opencv2411\install\x64\mingw\lib\libopencv_superres2411.dll.a)

    LIBS +=  $$quote(C:\Program Files\opencv2411\install\x64\mingw\lib\libopencv_ts2411.a)

    LIBS +=  $$quote(C:\Program Files\opencv2411\install\x64\mingw\lib\libopencv_video2411.dll.a)

    LIBS +=  $$quote(C:\Program Files\opencv2411\install\x64\mingw\lib\libopencv_videostab2411.dll.a)

    完成图

    相关文章

      网友评论

          本文标题:在QT下配置opencv

          本文链接:https://www.haomeiwen.com/subject/clzmlftx.html