本文主要是介绍vs2013中opencv的配置,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
VS2013中 openCV 的配置
下面开始介绍如何配置,我用的系统是win8.1 64位系统,vs用的是vs3013 ultimate,先到官网下载opencv 我用的的版本是最新的版本3.0 ALPHA,下载下来直接执行即可,实际上就是解压,我解压到D:\Program Files文件夹下。
配置环境变量,右击我的电脑选择属性,在左侧选择高级系统设置,会弹出系统属性对话框,
点击环境变量,点击新建环境变量,变量名可以任意,我在这起的是OPENCV,将变量值设为opencv/build的路径
添加路径,点击编辑path,在path中添加;%OPENCV%\x86\vc12\bin,其中vc12对应的是vs2013,vc11对应的是vs2012,vc10对应的是vs2010,根据自己的版本进行选择
新建opencv的工程属性表,在opencv目录下新建opencv300. props,可以新建一个txt文档,将后缀名改为.props即可,下面是我的属性工程表,第7,8行分别是32位和64位平台,如果没有定义系统变量,里面的$(OPENCV)可以换成绝对路径,我的是D:\Program Files\opencv\build,在vc12下面有3个文件夹bin,lib,staticlib,将lib和staticlib添加到LibraryPath中,可能版本不同需要添加的也不同,主要是查看vc12有哪些文件夹,并且文件夹里包含文件名含有300的lib文件添加到LibraryPath中,300是指opencv的版本为opencv3.0.0,vc12根据vs版本不同也不同,第12行和第15行开始的是包含的lib文件,其中第12开始包含的是文件名含有300但不以d结尾的lib文件,其中第15开始包含的是文件名含有300以d结尾的lib文件,你可以根据自己的opencv版本进行修改。
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"><ImportGroup Label="PropertySheets" /><PropertyGroup Label="UserMacros" /><PropertyGroup><IncludePath>$(OPENCV)\include;$(IncludePath)</IncludePath><LibraryPath Condition="'$(Platform)'=='Win32'">$(OPENCV)\x86\vc12\staticlib;$(OPENCV)\x86\vc12\lib;$(LibraryPath)</LibraryPath><LibraryPath Condition="'$(Platform)'=='X64'">$(OPENCV)\x64\vc12\staticlib;$(OPENCV)\x64\vc12\lib;$(LibraryPath)</LibraryPath></PropertyGroup><ItemDefinitionGroup><Link Condition="'$(Configuration)'=='Debug'"><AdditionalDependencies>opencv_ts300.lib;opencv_world300.lib;opencv_calib3d300.lib;opencv_core300.lib;opencv_features2d300.lib;opencv_flann300.lib;opencv_highgui300.lib;opencv_imgcodecs300.lib;opencv_imgproc300.lib;opencv_ml300.lib;opencv_objdetect300.lib;opencv_photo300.lib;opencv_shape300.lib;opencv_stitching300.lib;opencv_superres300.lib;opencv_ts300.lib;opencv_video300.lib;opencv_videoio300.lib;opencv_videostab300.lib;%(AdditionalDependencies)</AdditionalDependencies></Link><Link Condition="'$(Configuration)'=='Release'"><AdditionalDependencies>opencv_ts300d.lib;opencv_world300d.lib;opencv_calib3d300d.lib;opencv_core300d.lib;opencv_features2d300d.lib;opencv_flann300d.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_ts300d.lib;opencv_video300d.lib;opencv_videoio300d.lib;opencv_videostab300d.lib;%(AdditionalDependencies)</AdditionalDependencies></Link></ItemDefinitionGroup><ItemGroup />
</Project>
编辑完项目属性表后,在vs中新建空项目test, 打开视图->其他窗口->属性管理器,
在属性管理器中添加写好的opencv300. props属性文件,在右侧边栏中选择属性管理器,右击test,选择添加现有属性表,
找到opencv300.props添加就可以了,
至此环境就配好了,运行一个实例程序吧,还有要说的是每次新建项目都需要添加opencv300.props,要将图片放进项目里面的test文件中,是里面的test文件夹,即test\test下。
结显示出的图片是这样的
本文参考《vs2010+Opencv-2.4.0的配置攻略》 ,《Opencv 完美配置攻略 2014 (Win8.1 + Opencv 2.4.8 + VS 2013)》和《opencv教程》
本文转载自http://www.cnblogs.com/sdxk/p/4033667.html
这篇关于vs2013中opencv的配置的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!