在系统变量里找到Path变量,在Path中添加值SDK中的bin目录。
本人解压时设置的目录是D:\Program
Files,用到是32位库,VC++用的是2013,因此添加到bin目录为 D:\Program
Files\opencv\build\x86\vc12\bin。
在用户变量里,新建一个opencv的变量值为
D:\Program
Files\opencv\build(根据解压目录)
PATH里增加(注:中间加;隔开,是英文状态下的)
D:\Program
Files\opencv\build\x86\vc12\bin
注:环境变量配置后,需重启系统才能生效。
4、
VC++工程配置
新建一个项目(这个应该都会吧)
然后打开视图->属性管理器
双击标注出的地方,弹出一个属性页
先选择VC++目录
将可执行文件目录
点击右边,选择编辑
新建一个位置
本人输入的是(如果不确定,就点击右边的省略号选择文件夹)
D:\Program
Files\opencv\build\x86\vc12\bin
然后是包含目录
差不多一样
本人输入的是(如果不确定,就点击右边的省略号选择文件夹)
D:\Program Files\opencv\build\include
D:\Program
Files\opencv\build\include\opencv2
D:\Program
Files\opencv\build\include\opencv
下一个是库目录(如果不确定,就点击右边的省略号选择文件夹)
本人输入的是(如果不确定,就点击右边的省略号选择文件夹)
D:\Program
Files\opencv\build\x86\vc12\lib
下一步就是附加依赖项的配置了
- opencv_calib3d249d.lib
- opencv_contrib249d.lib
- opencv_core249d.lib
- opencv_features2d249d.lib
- opencv_flann249d.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
- opencv_nonfree249.lib
- opencv_objdetect249.lib
- opencv_photo249.lib
-
opencv_stitching249.lib
- opencv_ts249.lib
- opencv_video249.lib
- opencv_videostab249.lib
- opencv_gpu249d.lib
- opencv_highgui249d.lib
- opencv_imgproc249d.lib
- opencv_legacy249d.lib
- opencv_ml249d.lib
- opencv_nonfree249d.lib
- opencv_objdetect249d.lib
- opencv_photo249d.lib
- opencv_stitching249d.lib
- opencv_ts249d.lib
- opencv_video249d.lib
- opencv_videostab249d.lib
注:唯一的区别是Debug版用到的dll和lib文件都有后缀d,Release版使用的不带d。配置Release的附加依赖项时别忘了把d删掉
5、 测试环节
添加一个文件
#include #include
using namespace std;
int main()
{
IplImage * test; test = cvLoadImage
("D:\\demo.jpg");
cvNamedWindow("test_demo", 1);
cvShowImage("test_demo", test);
cvWaitKey(0);
cvDestroyWindow("test_demo");
cvReleaseImage(&test); return 0;
}