参考资料:
http://jingyan.baidu.com/article/75ab0bcbee4b47d6864db2fc.html
注: x86 x64 这些根据自己的系统以及需求而定, 这里就不赘述
1. 下载安装包 opencv3.0.0.exe, 解压到 E:\tools\opencv3.0.0 得到 D:\E:\tools\opencv3.0.0\opencv
2. 设置环境变量(注意你设置了环境变量之后, 确保 VS 重启一次):
Path += E:\tools\opencv3.0.0\opencv\build\x86\vc12\bin
注: 添加 Path 的目的是为了找到 dll 的位置.
3. 创建 Win32 控制台项目测试
3.1.
设置头文件路径:
E:\tools\opencv3.0.0\opencv\build\include
E:\tools\opencv3.0.0\opencv\build\include\opencv
E:\tools\opencv3.0.0\opencv\build\include\opencv2
3.2.
设置库文件路径:
E:\tools\opencv3.0.0\opencv\build\x86\vc12\lib
E:\tools\opencv3.0.0\opencv\build\x86\vc12\staticlib
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. 测试代码:
#include "stdafx.h" #include <cv.h>
#include <highgui.h> int main()
{
IplImage * test;
test = cvLoadImage("D:\\sample.png");//图片路径
cvNamedWindow("test_demo", );
cvShowImage("test_demo", test);
cvWaitKey();
cvDestroyWindow("test_demo");
cvReleaseImage(&test);
return ;
}