参考资料:
http://jingyan.baidu.com/article/75ab0bcbee4b47d6864db2fc.html
注: x86 x64 这些根据自己的系统以及需求而定, 这里就不赘述
1. 下载安装包 opencv3.0.0.exe, 解压到 E: oolsopencv3.0.0 得到 D:E: oolsopencv3.0.0opencv
2. 设置环境变量(注意你设置了环境变量之后, 确保 VS 重启一次):
Path += E: oolsopencv3.0.0opencvuildx86vc12in
注: 添加 Path 的目的是为了找到 dll 的位置.
3. 创建 Win32 控制台项目测试
3.1.
设置头文件路径:
E: oolsopencv3.0.0opencvuildinclude
E: oolsopencv3.0.0opencvuildincludeopencv
E: oolsopencv3.0.0opencvuildincludeopencv2
3.2.
设置库文件路径:
E: oolsopencv3.0.0opencvuildx86vc12lib
E: oolsopencv3.0.0opencvuildx86vc12staticlib
3.3.
注意: OpenCV 的库文件不能乱用. Debug 配置就用 xxxd.lib, Release 配置就用 xxx.lib (无d后缀). 否则会出现莫名其妙的内存访问错误.
设置库文件依赖项(Debug就添加*d.lib, Release就添加*(无d后缀).lib, 反正把上面路径中的lib文件添加了即可):
opencv_ts300d.lib
opencv_world300d.lib
IlmImfd.lib
ippicvmt.lib
libjasperd.lib
libjpegd.lib
libpngd.lib
libtiffd.lib
libwebpd.lib
opencv_calib3d300d.lib
opencv_core300d.lib
opencv_features2d300d.lib
opencv_flann300d.lib
opencv_hal300d.lib
opencv_highgui300d.lib
opencv_imgcodecs300d.lib
opencv_imgproc300d.lib
opencv_ml300d.lib
opencv_objdetect300d.lib
opencv_photo300d.lib
opencv_shape300d.lib
opencv_stitching300d.lib
opencv_superres300d.lib
opencv_video300d.lib
opencv_videoio300d.lib
opencv_videostab300d.lib
zlibd.lib
3.4. 测试代码:
1 #include "stdafx.h" 2 3 #include <cv.h> 4 #include <highgui.h> 5 6 int main() 7 { 8 IplImage * test; 9 test = cvLoadImage("D:\sample.png");//图片路径 10 cvNamedWindow("test_demo", 1); 11 cvShowImage("test_demo", test); 12 cvWaitKey(0); 13 cvDestroyWindow("test_demo"); 14 cvReleaseImage(&test); 15 return 0; 16 }