QT+opencv显示图片

借鉴该文章 https://blog.csdn.net/m0_60259116/article/details/128104565

 

opencv的Mingw版本放在E盘

所以在工程文件中添加如下地址:

INCLUDEPATH +=E:\opencv3.4.0\OpenCV-MinGW-Build-OpenCV-3.4.5\include\
              E:\opencv3.4.0\OpenCV-MinGW-Build-OpenCV-3.4.5\include\
              E:\opencv3.4.0\OpenCV-MinGW-Build-OpenCV-3.4.5\include\opencv2

LIBS +=E:\opencv3.4.0\OpenCV-MinGW-Build-OpenCV-3.4.5\x86\mingw\bin\libopencv_*.dll

在main.cpp中写如下程序:
#include "mainwindow.h"
#include <QApplication>
#include "opencv2/opencv.hpp"
#include <iostream>
using namespace cv;
using namespace std;
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    string image="E:/3.jpg";

    Mat colorr;
    colorr=imread(image);
    imshow("color",colorr);
    //MainWindow w;
    //w.show();

    return a.exec();
}

完成

posted @ 2023-02-14 20:40  blackstrom  阅读(53)  评论(1编辑  收藏  举报