1、OpenCV 2.4.9 +VS2013 开发环境配置OpenCV 的全称是:Open Source Computer Vision Library。OpenCV 是一个基于(开源)发行的跨平台计算机视觉库,可以运行在 Linux、Windows 和Mac OS 操作系统上。它轻量级而且高效由一系列 C 函数和少量 C+ 类构成,同时提供了 Python、Ruby、MATLAB 等语言的接口,实现了图像处理和计算机视觉方面的很多通用算法。现本教程,是在 windows 平台下使用 visual studio2013 和 opencv2.4.9 配置一个开发环境。工具/原料opencv2.4.9
2、 vs2013方法/步骤1 安装 opencv2.4.9,解压,请务必记住自己解压的路径。宜家以我自己的路径为例D:Program Files2配置环境变量1、系统变量 Path:添加 D:Program Filesopencvbuildx86vc12bin2、用户变量:添加 opencv 变量,值 D:Program Filesopencvbuild,添加PATH 变 量 ( 有 就 不 需 要 添 加 , 但 是 值 需 要 添 加 ) 值 D:ProgramFilesopencvbuildx86vc12bin说明:不管你系统是32位还是64位,路径目录均选择X86,因为编译都是使用32位
3、编译;如果选用X64,则程序运行时候会出错。3新建 visual C 项目新建 visual C+项目,如下图所示,项目选项注意:如下图。4工程目录的配置(Debug)找到属性管理器,如果找不到,请安装下图方法找到。双击 Debug|Win32 打开如下窗口,设置如下:(下图红框项为设置项)1、包含目录:(VC+目录)D:Program FilesopencvbuildincludeD:Program FilesopencvbuildincludeopencvD:Program Filesopencvbuildincludeopencv22、库目录:(VC+目录)D:Program Files
4、opencvbuildx86vc12lib3、连接器-输入-附加依赖项:opencv_ml249d.libopencv_calib3d249d.libopencv_contrib249d.libopencv_core249d.libopencv_features2d249d.libopencv_flann249d.libopencv_gpu249d.libopencv_highgui249d.libopencv_imgproc249d.libopencv_legacy249d.libopencv_objdetect249d.libopencv_ts249d.libopencv_video249
5、d.libopencv_nonfree249d.libopencv_ocl249d.libopencv_photo249d.libopencv_stitching249d.libopencv_superres249d.libopencv_videostab249d.lib其实以上都是 D:Program Filesopencvbuildx86vc12lib 下所有的 lib 文件,你会发现,有的后面带上 d,有的没有 d,这是因为 Debug 的就有 d,Release则没有 d。工程目录的配置(Release)其他与 Debug 一样,只是连接器-输入-附加依赖项不一样,设置如下:openc
6、v_objdetect249.libopencv_ts249.libopencv_video249.libopencv_nonfree249.libopencv_ocl249.libopencv_photo249.libopencv_stitching249.libopencv_superres249.libopencv_videostab249.libopencv_calib3d249.libopencv_contrib249.libopencv_core249.libopencv_features2d249.libopencv_flann249.libopencv_gpu249.libop
7、encv_highgui249.libopencv_imgproc249.libopencv_legacy249.libopencv_ml249.lib最终的测试1、新建一个 cpp 文件,如下图:在 cpp 文件上输入以下代码:#include #include using namespace std;int main()IplImage * test;test = cvLoadImage(“D:Sample_8.bmp“);/图片路径cvNamedWindow(“test_demo“, 1);cvShowImage(“test_demo“, test);cvWaitKey(0);cvDestroyWindow(“test_demo“);cvReleaseImage(return 0;