VS2015配置OpenCV2.4.9 (win7系统)

                                                                     VS2015配置OpenCV2.4.9 (win7系统)

  1. OpenCV

(1). 官网下载OpenCV并解压缩

(2). 配置OpenCV环境变量

VS2015配置OpenCV2.4.9 (win7系统)_第1张图片

VS2015配置OpenCV2.4.9 (win7系统)_第2张图片

 

添加OpenCV路径,如:

64位:

添加 D:\Program File\opencv2.4.9\opencv\build\x64\vc12\bin;

D:\Program File\opencv2.4.9\opencv\build\x86\vc12\bin

32位:

添加 D:\Program File\opencv2.4.9\opencv\build\x86\vc12\bin

 

添加用户变量

VS2015配置OpenCV2.4.9 (win7系统)_第3张图片

D:\Program File\opencv2.4.9\opencv\build

至此,环境变量配置结束。

2. VS2015

(1). 新建win32控制台项目

VS2015配置OpenCV2.4.9 (win7系统)_第4张图片

点击“确定”->“下一步”->“空项目”

(2). 新建源文件

VS2015配置OpenCV2.4.9 (win7系统)_第5张图片

VS2015配置OpenCV2.4.9 (win7系统)_第6张图片

VS2015配置OpenCV2.4.9 (win7系统)_第7张图片 

测试代码:

#include 

#include 

using namespace cv;

void main()

{


       IplImage *src = cvLoadImage("lena.jpg"); //这里将lena.jpg和lena.cpp文件放在同一个文件夹下

       cvNamedWindow("lena", CV_WINDOW_AUTOSIZE);

       cvShowImage("lena", src);

       cvWaitKey(0);

       cvDestroyWindow("lena");

       cvReleaseImage(&src);

}

 

(3). 配置OpenCV(以Debug|Win32为例)

VS2015配置OpenCV2.4.9 (win7系统)_第8张图片

VS2015配置OpenCV2.4.9 (win7系统)_第9张图片

添加可执行文件

添加 D:\Program File\opencv2.4.9\opencv\build\x86\vc12\bin

Release|Win32同上

Debug/Release|x64添加D:\Program File\opencv2.4.9\opencv\build\x64\vc12\bin

 

接下来分别添加包含目录和库目录

VS2015配置OpenCV2.4.9 (win7系统)_第10张图片

配置包含目录时 Release|Win32 Debug/Release|x64均同上

VS2015配置OpenCV2.4.9 (win7系统)_第11张图片

添加库目录时,Release|Win32同上,Debug/Release|x64将x86改为x64

 

下面添加附加依赖项:

VS2015配置OpenCV2.4.9 (win7系统)_第12张图片

Debug附加依赖项:

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_ml249d.lib

opencv_nonfree249d.lib

opencv_objdetect249d.lib

opencv_ocl249d.lib

opencv_photo249d.lib

opencv_stitching249d.lib

opencv_superres249d.lib

opencv_ts249d.lib

opencv_video249d.lib

opencv_videostab249d.lib

 

Release附加依赖项:

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_ocl249.lib

opencv_photo249.lib

opencv_stitching249.lib

opencv_superres249.lib

opencv_ts249.lib

opencv_video249.lib

opencv_videostab249.lib

至此,配置完成。

3. 测试代码运行

打开配置管理器

VS2015配置OpenCV2.4.9 (win7系统)_第13张图片

 

X86和x64均选择win32

VS2015配置OpenCV2.4.9 (win7系统)_第14张图片

VS2015配置OpenCV2.4.9 (win7系统)_第15张图片 

运行时可能提示缺少msvcp120d.dll文件,下载,并将其添加到D:\Program File\opencv2.4.9\opencv\build\x86\vc12\bin

D:\Program File\opencv2.4.9\opencv\build\x64\vc12\bin

即可解决。

你可能感兴趣的:(VS2015配置OpenCV2.4.9 (win7系统))