OpenCV2.4.13+Qt5.6.2配置方法

1、环境变量

D:\Soft\OpenCV2\MinGW_build\bin;

C:\Qt\Qt5.6.2\Tools\mingw492_32\bin;

D:\Soft\Programming\CMake3.7.0\bin;

2、OpenCV2.4.13的MinGW_build版本位置

D:\Soft\OpenCV2\MinGW_build\

3、Qt5.6.2位置

C:\Qt\Qt5.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);  
}  
点赞

发表评论

电子邮件地址不会被公开。 必填项已用*标注