1.安装opencv2.4.9,解压,请务必记住自己解压的路径。我自己的路径为例E:\opencv2.4.9
2. 配置环境变量
右击“此电脑”——单击“属性”——“高级系统设置”——“环境变量”
添加“用户变量”:(1) 添加opencv变量,值为E:\opencv2.4.9\opencv\build
(2)添加PATH变量,值为E:\opencv2.4.9\opencv\build\x86\vc12\bin
添加“系统变量”——Path——添加:E:\opencv2.4.9\opencv\build\x86\vc12\bin
此时环境变量就配置完成了,一直确定——确定——确定......就好了
下一步,设置项目的属性。
3. 新建 visual C++项目,如下图所示:
选择Win32控制台应用程序,下面的名称自己起,最好能反映该项目的作用,然后确定,点下一步,进行如下选择:
单击完成!
4.配置属性管理器,如下图所示:
双击 Debug | Win32 下的Microsoft.Cpp.Win32.user——通用属性——VC++目录——包含文件添加:
E:\opencv2.4.9\opencv\build\include
E:\opencv2.4.9\opencv\build\include\opencv
E:\opencv2.4.9\opencv\build\include\opencv2
如下图所示
然后在库目录添加:E:\opencv2.4.9\opencv\build\x86\vc12\lib
如下图所示:
链接器——输入——附加依赖项:(复制下段.lib文件,粘贴即可)
opencv_ml249d.lib
opencv_calib3d249d.lib
opencv_contrib249d.lib
opencv_core249d.lib
opencv_features2d249d.lib
opencv_flann249d.lib
opencv_gpu249d.lib
opencv_highgui249d.lib
opencv_imgproc249d.lib
opencv_legacy249d.lib
opencv_objdetect249d.lib
opencv_ts249d.lib
opencv_video249d.lib
opencv_nonfree249d.lib
opencv_ocl249d.lib
opencv_photo249d.lib
opencv_stitching249d.lib
opencv_superres249d.lib
opencv_videostab249d.lib
双击Release | Win32 下的Microsoft.Cpp.Win32.user
其他与Debug一样,只是”链接器——输入——附加依赖项“不一样,修改为如下:
opencv_objdetect249.lib
opencv_ts249.lib
opencv_video249.lib
opencv_nonfree249.lib
opencv_ocl249.lib
opencv_photo249.lib
opencv_stitching249.lib
opencv_superres249.lib
opencv_videostab249.lib
opencv_calib3d249.lib
opencv_contrib249.lib
opencv_core249.lib
opencv_features2d249.lib
opencv_flann249.lib
opencv_gpu249.lib
opencv_highgui249.lib
opencv_imgproc249.lib
opencv_legacy249.lib
opencv_ml249.lib
至此,所有的配置就都已经完成了!~预祝顺利!~