欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

VS2015配置OpenCV2.4.9 (win7系统)

程序员文章站 2024-03-22 19:51:34
...

                                                                     VS2015配置OpenCV2.4.9 (win7系统)

  1. OpenCV

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

(2). 配置OpenCV环境变量

VS2015配置OpenCV2.4.9 (win7系统)

VS2015配置OpenCV2.4.9 (win7系统)

 

添加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系统)

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

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

2. VS2015

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

VS2015配置OpenCV2.4.9 (win7系统)

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

(2). 新建源文件

VS2015配置OpenCV2.4.9 (win7系统)

VS2015配置OpenCV2.4.9 (win7系统)

VS2015配置OpenCV2.4.9 (win7系统) 

测试代码:

#include <highgui.h>

#include <iostream>

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系统)

VS2015配置OpenCV2.4.9 (win7系统)

添加可执行文件

添加 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系统)

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

VS2015配置OpenCV2.4.9 (win7系统)

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

 

下面添加附加依赖项:

VS2015配置OpenCV2.4.9 (win7系统)

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系统)

 

X86和x64均选择win32

VS2015配置OpenCV2.4.9 (win7系统)

VS2015配置OpenCV2.4.9 (win7系统) 

运行时可能提示缺少msvcp120d.dll文件,下载VS2015配置OpenCV2.4.9 (win7系统),并将其添加到D:\Program File\opencv2.4.9\opencv\build\x86\vc12\bin

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

即可解决。

相关标签: OpenCV VS