[20160711][VS2012配置OpenCV2.4.9]

相关说明

    OpenCV是一套开源机器视觉库,用于简化机器视觉算法的开发与调试。

 

移植环境

操作系统:Win7 64位

 

移植软件:Visual Studio 2012

 

代码下载:

https://sourceforge.net/projects/opencvlibrary/files/opencv-win/2.4.9/opencv-2.4.9.exe/download

 

操作步骤

1.下载并且解压源代码

 

2.配置环境变量

计算机右键->属性->高级系统设置->环境变量->系统环境变量->Path中添加环境变量。注意vc111表示Visual Studio 2012。

C:\Program Files\opencv\build\x86\vc11\bin;

 

3.新建空的项目工程

 

4.配置OpenCV动态链接库

4.1.视图->属性管理器->右键Debug|Win32->属性

 

4.2.设置VC++目录中的包含目录,设置头文件路径

C:\Program Files\opencv\build\include
C:\Program Files\opencv\build\include\opencv
C:\Program Files\opencv\build\include\opencv2

 

4.3.设置VC++目录中的库目录,设置链接库路径

C:\Program Files\opencv\build\x86\vc11\lib

 

4.4.设置链接器中的输入,包含链接库,注意链接库名称与链接库目录中一一对应。设置完成后关闭并重启电脑。

opencv_ml249d.lib
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_objdetect249d.lib
opencv_ts249d.lib
opencv_video249d.lib
opencv_nonfree249d.lib
opencv_ocl249d.lib
opencv_photo249d.lib
opencv_stitching249d.lib
opencv_superres249d.lib
opencv_videostab249d.lib
opencv_objdetect249.lib
opencv_ts249.lib
opencv_video249.lib
opencv_nonfree249.lib
opencv_ocl249.lib
opencv_photo249.lib
opencv_stitching249.lib
opencv_superres249.lib
opencv_videostab249.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

 

5.新建main.cpp并测试OpenCV库。

#include <opencv2/opencv.hpp>

using namespace cv;

void main(){
    Mat img = imread("test.jpg");

    imshow("test", img);

    waitKey(0);
}

 

Congratulation! Let’s enjoy!

 

6.当出现在debug模式下可以运行,在release模式下不能运行的情况时,首先切换到到debug模式,修改链接器中的输入如下

opencv_ml249d.lib
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_objdetect249d.lib
opencv_ts249d.lib
opencv_video249d.lib
opencv_nonfree249d.lib
opencv_ocl249d.lib
opencv_photo249d.lib
opencv_stitching249d.lib
opencv_superres249d.lib
opencv_videostab249d.lib

然后切换到release模式下,修改链接器中的输入如下

opencv_objdetect249.lib
opencv_ts249.lib
opencv_video249.lib
opencv_nonfree249.lib
opencv_ocl249.lib
opencv_photo249.lib
opencv_stitching249.lib
opencv_superres249.lib
opencv_videostab249.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
posted @ 2016-07-11 13:58  盛夏夜  阅读(245)  评论(0编辑  收藏  举报