qt5.4.0 + opencv2.4.10

PC: win7(X64)

Qt: qt-opensource-windows-x86-msvc2013_64-5.4.0

opencv: opencv-2.4.10


1、将qt正确安装到D盘,将opencv解压到D盘;


2、配置opencv环境变量

选择“我的电脑”,右键选择“属性”,

qt5.4.0 + opencv2.4.10_第1张图片

在弹出的对话框中选择“高级系统设置”,

qt5.4.0 + opencv2.4.10_第2张图片

然后在弹出的对话框中选择“高级”->环境变量

qt5.4.0 + opencv2.4.10_第3张图片

在变量值中添加opencv的路径

1)D:\opencv\build\include

2)D:\opencv\build\include\opencv

3)D:\opencv\build\include\opencv2

每个路径之间用分号隔开;

qt5.4.0 + opencv2.4.10_第4张图片


3、新建一个Qt项目,例opencvTest

在opencvTest.pro里面添加包含路径和库

INCLUDEPATH+=   D:\opencv\build\include\
                D:\opencv\build\include\opencv\
                D:\opencv\build\include\opencv2

LIBS+=D:\opencv\build\x64\vc12\lib\opencv_ml2410d.lib
LIBS+=D:\opencv\build\x64\vc12\lib\opencv_calib3d2410d.lib
LIBS+=D:\opencv\build\x64\vc12\lib\opencv_contrib2410d.lib
LIBS+=D:\opencv\build\x64\vc12\lib\opencv_core2410d.lib
LIBS+=D:\opencv\build\x64\vc12\lib\opencv_features2d2410d.lib
LIBS+=D:\opencv\build\x64\vc12\lib\opencv_flann2410d.lib
LIBS+=D:\opencv\build\x64\vc12\lib\opencv_gpu2410d.lib
LIBS+=D:\opencv\build\x64\vc12\lib\opencv_highgui2410d.lib
LIBS+=D:\opencv\build\x64\vc12\lib\opencv_imgproc2410d.lib
LIBS+=D:\opencv\build\x64\vc12\lib\opencv_legacy2410d.lib
LIBS+=D:\opencv\build\x64\vc12\lib\opencv_objdetect2410d.lib
LIBS+=D:\opencv\build\x64\vc12\lib\opencv_ts2410d.lib
LIBS+=D:\opencv\build\x64\vc12\lib\opencv_video2410d.lib
LIBS+=D:\opencv\build\x64\vc12\lib\opencv_nonfree2410d.lib
LIBS+=D:\opencv\build\x64\vc12\lib\opencv_ocl2410d.lib
LIBS+=D:\opencv\build\x64\vc12\lib\opencv_photo2410d.lib
LIBS+=D:\opencv\build\x64\vc12\lib\opencv_stitching2410d.lib
LIBS+=D:\opencv\build\x64\vc12\lib\opencv_superres2410d.lib
LIBS+=D:\opencv\build\x64\vc12\lib\opencv_videostab2410d.lib
qt5.4.0 + opencv2.4.10_第5张图片

添加之后,选中新建项目opencvTest右键,选中“执行qmake”;

然后在main.cpp里面输入测试代码

#include 
#include 
#include 
#include 
using namespace std;
using namespace cv;
 
  
int main(int argc, char *argv[])
{
    //QCoreApplication a(argc, argv);
    //return a.exec();
    cout<<"opencv"< 
  
    Mat src=imread("C:/Users/user/Desktop/tt.jpg");  //绝对路径
    imshow("test",src);
    waitKey(0);
    return 0;
 
  
}
可以正常显示图片。

配置成功!


你可能感兴趣的:(Qt)