在QtCreator中使用Opencv2
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
在Qt Creator中使用Opencv 2.3
分类:数字图像处理Qt2012-04-18 17:21 104人阅读评论(0) 收藏举报打开Qt项目中的.pro文件,添加如下代码
INCLUDEPATH+=D:\OpenCV\opencv\build\include\opencv2\
D:\OpenCV\opencv\build\include\opencv\
D:\OpenCV\opencv\build\include
CONFIG(release,debug|release)
{
LIBS+=
D:\OpenCV\opencv\build\x86\vc10\lib\opencv_calib3d231.lib\
D:\OpenCV\opencv\build\x86\vc10\lib\opencv_contrib231.lib\
D:\OpenCV\opencv\build\x86\vc10\lib\opencv_core231.lib\
D:\OpenCV\opencv\build\x86\vc10\lib\opencv_features2d231.lib\ D:\OpenCV\opencv\build\x86\vc10\lib\opencv_flann231.lib\
D:\OpenCV\opencv\build\x86\vc10\lib\opencv_gpu231.lib\
D:\OpenCV\opencv\build\x86\vc10\lib\opencv_highgui231.lib\
D:\OpenCV\opencv\build\x86\vc10\lib\opencv_imgproc231.lib\ D:\OpenCV\opencv\build\x86\vc10\lib\opencv_legacy231.lib\
D:\OpenCV\opencv\build\x86\vc10\lib\opencv_ml231.lib\
D:\OpenCV\opencv\build\x86\vc10\lib\opencv_objdetect231.lib\ D:\OpenCV\opencv\build\x86\vc10\lib\opencv_ts231.lib\
D:\OpenCV\opencv\build\x86\vc10\lib\opencv_video231.lib
}
CONFIG(debug,debug|release)
{
LIBS
+=D:\OpenCV\opencv\build\x86\vc10\lib\opencv_calib3d231d.lib\ D:\OpenCV\opencv\build\x86\vc10\lib\opencv_contrib231d.lib\ D:\OpenCV\opencv\build\x86\vc10\lib\opencv_core231d.lib\
D:\OpenCV\opencv\build\x86\vc10\lib\opencv_features2d231d.lib\ D:\OpenCV\opencv\build\x86\vc10\lib\opencv_flann231d.lib\
D:\OpenCV\opencv\build\x86\vc10\lib\opencv_gpu231d.lib\
D:\OpenCV\opencv\build\x86\vc10\lib\opencv_highgui231d.lib\ D:\OpenCV\opencv\build\x86\vc10\lib\opencv_imgproc231d.lib\ D:\OpenCV\opencv\build\x86\vc10\lib\opencv_legacy231d.lib\ D:\OpenCV\opencv\build\x86\vc10\lib\opencv_ml231d.lib\
D:\OpenCV\opencv\build\x86\vc10\lib\opencv_objdetect231d.lib\ D:\OpenCV\opencv\build\x86\vc10\lib\opencv_ts231d.lib\
D:\OpenCV\opencv\build\x86\vc10\lib\opencv_video231d.lib
}
注意,你的代码中的路径要根据OpenCV的具体安装路径做改变。
测试程序
#include
#include
using namespace std;
using namespace cv;
int main(int argc,char*argv[])
{
QCoreApplication a(argc,argv);
const char*imagename="E:\\library\\Pictures\\lena.jpg";
//从文件中读入图像
Mat img=imread(imagename);
//如果读入图像失败
if(img.empty())
{
fprintf(stderr,"Can not load image%s\n",imagename);
waitKey();
return-1;
}
//显示图像
imshow("image",img);
//此函数等待按键,按键盘任意键就返回
waitKey();
return a.exec();
}