QT + OpenCV2.4.10环境搭建,我用的是vs2013编译器

注意,我用的是VS2013编译器,这种编译器我能够非常方便的使用OpenCV


写这篇文章就是为了告诉大家,配置OpenCV环境也能够是非常方便的


1,首先要配置OpenCV环境变量,这个去百度就能找到


2,配置项目的pro文件,在pro文件加上如下代码,就可以了

INCLUDEPATH += D:\OpenCv\opencv\build\include
INCLUDEPATH += D:\OpenCv\opencv\build\include\opencv
INCLUDEPATH += D:\OpenCv\opencv\build\include\opencv2
 
  
 
  
LIBS +=D:\OpenCv\opencv\build\x86\vc11\lib\opencv_calib3d2410.lib
LIBS +=D:\OpenCv\opencv\build\x86\vc11\lib\opencv_contrib2410.lib
LIBS +=D:\OpenCv\opencv\build\x86\vc11\lib\opencv_core2410.lib
LIBS +=D:\OpenCv\opencv\build\x86\vc11\lib\opencv_features2d2410.lib
LIBS +=D:\OpenCv\opencv\build\x86\vc11\lib\opencv_flann2410.lib
LIBS +=D:\OpenCv\opencv\build\x86\vc11\lib\opencv_gpu2410.lib
LIBS +=D:\OpenCv\opencv\build\x86\vc11\lib\opencv_highgui2410.lib
LIBS +=D:\OpenCv\opencv\build\x86\vc11\lib\opencv_imgproc2410.lib
LIBS +=D:\OpenCv\opencv\build\x86\vc11\lib\opencv_legacy2410.lib
LIBS +=D:\OpenCv\opencv\build\x86\vc11\lib\opencv_ml2410.lib
LIBS +=D:\OpenCv\opencv\build\x86\vc11\lib\opencv_nonfree2410.lib
LIBS +=D:\OpenCv\opencv\build\x86\vc11\lib\opencv_objdetect2410.lib
LIBS +=D:\OpenCv\opencv\build\x86\vc11\lib\opencv_ocl2410.lib
LIBS +=D:\OpenCv\opencv\build\x86\vc11\lib\opencv_photo2410.lib
LIBS +=D:\OpenCv\opencv\build\x86\vc11\lib\opencv_stitching2410.lib
LIBS +=D:\OpenCv\opencv\build\x86\vc11\lib\opencv_superres2410.lib
LIBS +=D:\OpenCv\opencv\build\x86\vc11\lib\opencv_ts2410.lib
LIBS +=D:\OpenCv\opencv\build\x86\vc11\lib\opencv_video2410.lib
LIBS +=D:\OpenCv\opencv\build\x86\vc11\lib\opencv_videostab2410.lib
 
  
测试代码:
 
  
#include 
#include 
#include "mainwindow.h"
#include 
using namespace cv;
using namespace std;
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    qDebug("ccc");
 //   MainWindow w;
 //   w.show();
    Mat img = imread("d:/我自己.jpg");
  //  VideoCapture capture(0);
    qDebug("bbb");
    waitKey(0);
    qDebug("aaa");
  /*  VideoCapture capture("d:/长东视频测试/123.avi");                     //读入视频
        if (!capture.isOpened())
            return 1;
        double rate = capture.get(CV_CAP_PROP_FPS);
        bool stop(false);
        Mat frame;
 
  
        namedWindow("Canny Video");
        int delay = 1000 / rate;
 
  
        while (!stop)
        {
            if (!capture.read(frame))
                break;
            Mat result;
            Canny(frame, result, 100, 200);                        //边缘算子处理,保存结果在result里面
            threshold(result, result, 128, 255, THRESH_BINARY);
            imshow("Canny Video", result);
 
  
            if (waitKey(delay) >= 0)
                stop = true;
        }
        capture.release();*/
      return a.exec();
}
 
  

你可能感兴趣的:(QT)