Windows下配置QT OpenCV

时间:2022-06-18 04:51:06

说明:

配置参考链接:

.NET/youhaipeng/article/details/7453034

测试代码:

.pro文件

[plain]  

 

#-------------------------------------------------  

#  

# Project created by QtCreator 2012-05-07T12:27:37  

#  

#-------------------------------------------------  

  

QT       += core gui  

  

TARGET = test_opencv  

TEMPLATE = app  

  

  

SOURCES += main.cpp\  

        widget.cpp  

  

HEADERS  += widget.h  

  

FORMS    += widget.ui  

  

INCLUDEPATH += E:\opencv\build\include\opencv\  

                                 E:\opencv\build\include\opencv2\  

                                 E:\opencv\build\include\  

  

LIBS        +=  E:\opencv_obj\lib\libopencv_calib3d240.dll.a\  

                       E:\opencv_obj\lib\libopencv_core240.dll.a\  

                       E:\opencv_obj\lib\libopencv_features2d240.dll.a\  

                       E:\opencv_obj\lib\libopencv_flann240.dll.a\  

                       E:\opencv_obj\lib\libopencv_gpu240.dll.a\  

                       E:\opencv_obj\lib\libopencv_highgui240.dll.a\  

                       E:\opencv_obj\lib\libopencv_imgproc240.dll.a\  

                       E:\opencv_obj\lib\libopencv_legacy240.dll.a\  

                       E:\opencv_obj\lib\libopencv_ml240.dll.a\  

                       E:\opencv_obj\lib\libopencv_objdetect240.dll.a\  

                       E:\opencv_obj\lib\libopencv_video240.dll.a  


widget.cpp:

[cpp]  

 

#include "widget.h"  

#include "ui_widget.h"  

#include  "highgui.h"  

#include "cv.h"  

#include "cxcore.h"  

  

Widget::Widget(QWidget *parent) :  

    QWidget(parent),  

    ui(new Ui::Widget)  

{  

    ui->setupUi(this);  

  

    IplImage *img = cvLoadImage("lena.jpg");  

  

    cvNamedWindow("jdh",CV_WINDOW_AUTOSIZE);  

  

    cvShowImage("jdh",img);  

    cvWaitKey(0);  

    cvReleaseImage(&img);  

    cvDestroyWindow("jdh");  

}  

  

Widget::~Widget()  

{  

    delete ui;  

}  


运行结果:

Windows下配置QT OpenCV

Windows下配置QT OpenCV