Author:Maddock
Date:2014.12.27
准备工具 windows平台 opencv2.4.10 vs2013
1解压opencv2.4.10.exe,我放在目录 C:\Adisk\software\opencv\opencv2410\opencv
配置环境变量
Path: C:\Adisk\software\opencv\opencv2410\opencv\build\x86\vc12\bin
在x86文件夹内还有vc10,vc11,vc12 3个文件夹,分别对应vs2010,vs2012,vs2013
2 配置VS2013的include 和lib目录
新建win32工程,打开属性管理器(视图–>其他窗口–>属性管理器)
右键Debu32中的Mirosoft.Cpp.Win32.user选择属性,可以看见
编辑包含目录和库目录
包含目录 C:\Adisk\software\opencv\opencv2410\opencv\build\include
库目录 C:\Adisk\software\opencv\opencv2410\opencv\build\x86\vc12\lib
下一步点击连接器的输入选项,编辑附加依赖项,加入
opencv的debug版本和release版本需要的lib不同,但是在编辑右键Debu32中的Mirosoft.Cpp.Win32.user选择属性这一步中,相应的
release版本也跟着变了,如果编译运行debug版本是没有问题,切换到release版本是需要把debug版本去掉,否则opencv中的部分函数将不能
运行。
debug版本
opencv_calib3d2410d.lib
opencv_contrib2410d.lib
opencv_core2410d.lib
opencv_features2d2410d.lib
opencv_flann2410d.lib
opencv_gpu2410d.lib
opencv_highgui2410d.lib
opencv_imgproc2410d.lib
opencv_legacy2410d.lib
opencv_ml2410d.lib
opencv_nonfree2410d.lib
opencv_objdetect2410d.lib
opencv_ocl2410d.lib
opencv_photo2410d.lib
opencv_stitching2410d.lib
opencv_superres2410d.lib
opencv_ts2410d.lib
opencv_video2410d.lib
opencv_videostab2410d.lib
release版本
opencv_calib3d2410.lib
opencv_contrib2410.lib
opencv_core2410.lib
opencv_features2d2410.lib
opencv_flann2410.lib
opencv_gpu2410.lib
opencv_highgui2410.lib
opencv_imgproc2410.lib
opencv_legacy2410.lib
opencv_ml2410.lib
opencv_nonfree2410.lib
opencv_objdetect2410.lib
opencv_ocl2410.lib
opencv_photo2410.lib
opencv_stitching2410.lib
opencv_superres2410.lib
opencv_ts2410.lib
opencv_video2410.lib
opencv_videostab2410.lib
3 测试
// opencvtest.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include <opencv2/opencv.hpp>
using namespace cv;
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
Mat src = imread("image.png", 0);
if (src.empty())
{
cout << "打开图像失败!" << endl;
return -1;
}
namedWindow("image", CV_WINDOW_AUTOSIZE);
imshow("image", src);
waitKey(0);
return 0;
}
如果出现dll文件丢失,可以注销账户或者重启电脑是环境变量生效。