最简单的Qt5.12配置opencv4.0方法,免Cmake版本

≯℡__Kan透↙ 提交于 2020-01-18 04:07:53

事先采用MinGW编译好的OpenCV4.0.1 

https://github.com/huihut/OpenCV-MinGW-Build

在pro文件中加入 头文件路径和库路径

INCLUDEPATH +=D:\OpenCV-MinGW-Build-OpenCV-4.1.1-x64\include
LIBS += D:\OpenCV-MinGW-Build-OpenCV-4.1.1-x64\x64\mingw\bin\libopencv_calib3d411.dll
LIBS += D:\OpenCV-MinGW-Build-OpenCV-4.1.1-x64\x64\mingw\bin\libopencv_core411.dll
LIBS += D:\OpenCV-MinGW-Build-OpenCV-4.1.1-x64\x64\mingw\bin\libopencv_dnn411.dll
LIBS += D:\OpenCV-MinGW-Build-OpenCV-4.1.1-x64\x64\mingw\bin\libopencv_features2d411.dll
LIBS += D:\OpenCV-MinGW-Build-OpenCV-4.1.1-x64\x64\mingw\bin\libopencv_flann411.dll
LIBS += D:\OpenCV-MinGW-Build-OpenCV-4.1.1-x64\x64\mingw\bin\libopencv_gapi411.dll
LIBS += D:\OpenCV-MinGW-Build-OpenCV-4.1.1-x64\x64\mingw\bin\libopencv_highgui411.dll
LIBS += D:\OpenCV-MinGW-Build-OpenCV-4.1.1-x64\x64\mingw\bin\libopencv_imgcodecs411.dll
LIBS += D:\OpenCV-MinGW-Build-OpenCV-4.1.1-x64\x64\mingw\bin\libopencv_imgproc411.dll
LIBS += D:\OpenCV-MinGW-Build-OpenCV-4.1.1-x64\x64\mingw\bin\libopencv_ml411.dll
LIBS += D:\OpenCV-MinGW-Build-OpenCV-4.1.1-x64\x64\mingw\bin\libopencv_objdetect411.dll
LIBS += D:\OpenCV-MinGW-Build-OpenCV-4.1.1-x64\x64\mingw\bin\libopencv_photo411.dll
LIBS += D:\OpenCV-MinGW-Build-OpenCV-4.1.1-x64\x64\mingw\bin\libopencv_stitching411.dll
LIBS += D:\OpenCV-MinGW-Build-OpenCV-4.1.1-x64\x64\mingw\bin\libopencv_video411.dll
LIBS += D:\OpenCV-MinGW-Build-OpenCV-4.1.1-x64\x64\mingw\bin\libopencv_videoio411.dll

 

加入opencv相关头文件 (函数的引用)
#include <opencv2/core/core.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgcodecs/imgcodecs.hpp>
 

显示一个图片代码如下
Mat src = cv::imread("F:/Qt_demo_byown/FFmpegDemo/1.jpg",1);   
Mat img;   
cvtColor(src, img, COLOR_BGR2RGB);    
ui->label->setPixmap(QPixmap::fromImage(QImage(img.data, img.cols, img.rows, img.step, QImage::Format_RGB888)));

记得发布程序的时候需要把 dll文件 和exe文件拷贝到发布路径

 

 

大部分参考https://blog.csdn.net/qq_33474442/article/details/87074218

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!