1.安装Qtcreater
2安装opencv--opencv-4.5.2-vc14_vc15
windows下OpenCV的安装配置部署详细教程_万俟淋曦的进击手记-CSDN博客_opencv
3.配置
创建OpenCV项目过程详解 (biancheng.net)
Windows下QT Creator配置OpenCV(VC版)_czl389的专栏-CSDN博客
Pro文件
QT -= gui
CONFIG += c++11 console
CONFIG -= app_bundle
# You can make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
SOURCES += \
main.cpp
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
#包含目录
INCLUDEPATH+=D:\software\opencv\opencv\build\include\opencv2 \
D:\software\opencv\opencv\build\include
#库文件
LIBS+= -LD:\software\opencv\opencv\build\x64\vc15\lib \
#-lopencv_world452
-lopencv_world452d
main.cpp代码
#include "opencv2/opencv.hpp"
#include "opencv2/highgui/highgui.hpp"
using namespace std;
using namespace cv;
int main(int argc,char **argv)
{
Mat src=imread("C:\\Users\\Administrator\\Desktop\\test.jpg"); //在qt里面读取图片貌似只支持绝对路径
imshow("test",src);
waitKey(0);
return 0;
}
把D:\software\opencv\opencv\build\x64\vc15\bin中的文件复制到Qt构建生成的debug文件中
D:\Qtlearn\build-20210719-Desktop_Qt_5_14_2_MSVC2017_64bit-Debug\debug