1、下载OpenCV2.x.x superpackage(地址为:http://wiki.opencv.org.cn/index.php/%E9%A6%96%E9%A1%B5)
2、 配置环境变量
我的电脑--->右键--->属性--->高级--->环境变量--->在用户变量里,新建path和OPENCV两个项,如下图所示:
步骤1:在path中添加 (opencv所在盘符)\OpenCV2.3\build\x86\vc10\bin,就是添加dll文件(在系统变量里面添加PATH)
步骤2:添加OPENCV的环境变量 (opencv所在盘符)\OpenCV2.3\build
3、执行菜单栏“视图——其他窗口——属性管理器”,可以看到“属性管理器”显示在工作区左侧。如下图所示:
4、双击Debug | Win32下的“Microsoft.Cpp.Win32.user“,在弹出的配置框中配置。这个设置是对所有工程有效的。你可以打开其他的工程或者新建新的工程,可以看到都继承了此配置。
5、在"项目"->"属性"--->VC++目录--->包含目录文件中添加
~\OpenCV2.3\build\include
~\OpenCV2.3\build\include\opencv
~\OpenCV2.3\build\include\opencv2
"项目"->"属性"--->VC++目录--->库目录中添加
~\OpenCV2.3\build\x86\vc10\lib
如下图所示:
6、添加静态的lib。每次配置*.lib是不是很麻烦?告诉你个简单方法,2.4.6版本直接复制下面代码,Window MFC程序复制到stdafx.cpp文件最下面即可,其他版本根据版本不同自行修改,哈哈,头文件都省了!
1 // stdafx.cpp : 只包括标准包含文件的源文件 2 // Example_9_4_2.pch 将作为预编译头 3 // stdafx.obj 将包含预编译类型信息 4 5 #include "stdafx.h" 6 #ifdef _DEBUG 7 8 #pragma comment(lib,"opencv_calib3d246d.lib") 9 #pragma comment(lib,"opencv_contrib246d.lib") 10 #pragma comment(lib,"opencv_core246d.lib") 11 #pragma comment(lib,"opencv_features2d246d.lib") 12 #pragma comment(lib,"opencv_flann246d.lib") 13 #pragma comment(lib,"opencv_gpu246d.lib") 14 #pragma comment(lib,"opencv_haartraining_engined.lib") 15 #pragma comment(lib,"opencv_highgui246d.lib") 16 #pragma comment(lib,"opencv_imgproc246d.lib") 17 #pragma comment(lib,"opencv_legacy246d.lib") 18 #pragma comment(lib,"opencv_ml246d.lib") 19 #pragma comment(lib,"opencv_nonfree246d.lib") 20 #pragma comment(lib,"opencv_objdetect246d.lib") 21 #pragma comment(lib,"opencv_photo246d.lib") 22 #pragma comment(lib,"opencv_stitching246d.lib") 23 #pragma comment(lib,"opencv_ts246d.lib") 24 #pragma comment(lib,"opencv_video246d.lib") 25 #pragma comment(lib,"opencv_videostab246d.lib") 26 27 #else 28 29 #pragma comment(lib,"opencv_calib3d246.lib") 30 #pragma comment(lib,"opencv_contrib246.lib") 31 #pragma comment(lib,"opencv_core246.lib") 32 #pragma comment(lib,"opencv_features2d246.lib") 33 #pragma comment(lib,"opencv_flann246.lib") 34 #pragma comment(lib,"opencv_gpu246.lib") 35 #pragma comment(lib,"opencv_haartraining_engine.lib") 36 #pragma comment(lib,"opencv_highgui246.lib") 37 #pragma comment(lib,"opencv_imgproc246.lib") 38 #pragma comment(lib,"opencv_legacy246.lib") 39 #pragma comment(lib,"opencv_ml246.lib") 40 #pragma comment(lib,"opencv_nonfree246.lib") 41 #pragma comment(lib,"opencv_objdetect246.lib") 42 #pragma comment(lib,"opencv_photo246.lib") 43 #pragma comment(lib,"opencv_stitching246.lib") 44 #pragma comment(lib,"opencv_ts246.lib") 45 #pragma comment(lib,"opencv_video246.lib") 46 #pragma comment(lib,"opencv_videostab246.lib") 47 48 #endif