1、环境变量

D:SoftOpenCV2MinGW_buildbin;

C:QtQt5.6.2Toolsmingw492_32bin;

D:SoftProgrammingCMake3.7.0bin;

2、OpenCV2.4.13的MinGW_build版本位置

D:SoftOpenCV2MinGW_build\

3、Qt5.6.2位置

C:QtQt5.6.2\

4、Qt的pro文件写法

QT += core  
QT -= gui  
  
INCLUDEPATH+= D:/Soft/OpenCV2/build/include\  
              D:/Soft/OpenCV2/build/include/opencv\  
              D:/Soft/OpenCV2/build/include/opencv2  
  
LIBS += D:\Soft\OpenCV2\MinGW_build\lib\libopencv_core2413.dll.a\  
        D:\Soft\OpenCV2\MinGW_build\lib\libopencv_highgui2413.dll.a\  
        D:\Soft\OpenCV2\MinGW_build\lib\libopencv_imgproc2413.dll.a  
  
TARGET = JfzOpenCV  
CONFIG += console  
CONFIG -= app_bundle  
  
TEMPLATE = app  
  
SOURCES += main.cpp  

5、Qt的main.cpp函数写法

#include<opencv2/opencv.hpp>  
#include"opencv/cv.h"  
#include"opencv/cxcore.h"  
#include"opencv/highgui.h"  
  
using namespace cv;  
int main()  
{  
    //OpenCV2代码测试  
    Mat image=imread("D:\\1.png");         //载入图片  
    namedWindow("OpenCV2代码测试");       //创建窗口  
    imshow("OpenCV2代码测试",image);      //显示图像  
    imwrite("FuckPOI2.png",image);      //保存图像  
  
    //OpenCV1代码测试  
    IplImage *pImg;                     //声明IplImage指针  
    pImg = cvLoadImage("D:\\1.png", 0);   //载入图片  
    cvNamedWindow("OpenCV1代码测试",1);  //创建窗口  
    cvShowImage("OpenCV1代码测试",pImg); //显示图像  
    cvSaveImage("FuckPOI1.jpg",pImg);   //保存图像  
    cvWaitKey(0);                       //等待按键  
    cvDestroyWindow("Image");           //销毁窗口  
    cvReleaseImage(&pImg);              //释放图像  
    waitKey(0);  
}  
文章目录