本教程参考yexinrong18的百度经验,由于常需配置,故记之。
安装OpenCV 2.4.9
双击安装包安装到路径,以我的为例D:\opencv。
配置环境变量
- 系统变量Path,添加D:\opencv\build\x86\vc12\bin
- 用户变量中添加opencv变量:D:\opencv\build
- 用户变量中添加PATH变量:D:\opencv\build\x86\vc12\bin
VS配置
win32编译方式配置
找到属性管理器,右键Debug win32 - 属性,设置如下:
VC++目录 - 包含目录中新加
1
2
3D:\opencv\build\include
D:\opencv\build\include\opencv
D:\opencv\build\include\opencv2VC++目录 - 库目录中新加
1
D:\Program Files\opencv\build\x86\vc12\lib
链接器 - 输入 - 附加依赖项
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19opencv_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.libRelease配置同上,附加依赖项替换为
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19opencv_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
x64编译方式
找到属性管理器,右键Debug x64 - 属性,设置如下:
- VC++目录 - 包含目录中同上
- VC++目录 - 库目录中新加
1
D:\Program Files\opencv\build\x64\vc12\lib
- 链接器 - 输入 - 附加依赖项同上