1、下载OpenCV-2.4.2。
2、安装OpenCV-2.4.2.
3、添加OpenCV的include和lib:
在VS新建一个Win32控制台应用程序(也可以是MFC程序);
在菜单视图中点击属性管理器
C:\OpenCV-2.4.2\build\include;
C:\OpenCV-2.4.2\build\include\opencv;
C:\OpenCV-2.4.2\build\include\opencv2;
6、配置lib路径
在Library Directories中加入:C:\ProgramFiles (x86)\opencv\build\x86\vc10\lib
7、点击C\C++->输入,将以下内容添入:
(注意不同版本之间的差别,如pencv_calib3d242d.lib后面的三个数字242代表版本,在不同版本时注意,刚开始没注意到纠结了好久)
opencv_calib3d242d.lib; opencv_contrib242d.lib; opencv_core242d.lib;opencv_features2d242d.lib; opencv_flann242d.lib; opencv_gpu242d.lib;opencv_highgui242d.lib; opencv_imgproc242d.lib; opencv_legacy242d.lib;opencv_ml242d.lib; opencv_objdetect242d.lib; opencv_ts242d.lib; opencv_video242d.lib
8、设置环境变量(点击我的电脑->属性->高级系统设置->环境变量)
变量名: 变量值:
PATH: C:\OpenCV-2.4.2\build\x86\vc10\bin
TBB: C:\OpenCV-2.4.2build\common\tbb\ia32\vc10
设置完环境后重启电脑,使得环境变量生效。