此方法配置简单,方便易行,解压opencv2.4.13后得到opencv文件夹,进行如下步骤:
1、添加环境变量
用户变量,新建,变量名opencv,值D:opencvuild
系统变量,Path中添加D:opencvuildx86vc12in
2、新建opencv2413_debug.txt,记事本打开复制粘贴如下内容:
注意将代码中路径D:opencvuildinclude;D:opencvuildincludeopencv;D:opencvuildincludeopencv2;和D:opencvuildx86vc12lib;改为自己的路径。(可以把除include、x86文件夹之外的所有文件删除,省去近2G空间)
<?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>D:opencvuildinclude;D:opencvuildincludeopencv;D:opencvuildincludeopencv2;$(IncludePath)</IncludePath> <LibraryPath>D:opencvuildx86vc12lib;$(LibraryPath)</LibraryPath> </PropertyGroup> <ItemDefinitionGroup> <Link> <AdditionalDependencies>opencv_ml2413d.lib;opencv_calib3d2413d.lib;opencv_contrib2413d.lib;opencv_core2413d.lib;opencv_features2d2413d.lib;opencv_flann2413d.lib;opencv_gpu2413d.lib;opencv_highgui2413d.lib;opencv_imgproc2413d.lib;opencv_legacy2413d.lib;opencv_objdetect2413d.lib;opencv_ts2413d.lib;opencv_video2413d.lib;opencv_nonfree2413d.lib;opencv_ocl2413d.lib;opencv_photo2413d.lib;opencv_stitching2413d.lib;opencv_superres2413d.lib;opencv_videostab2413d.lib;%(AdditionalDependencies)</AdditionalDependencies> </Link> </ItemDefinitionGroup> <ItemGroup /> </Project>
3、同理,新建opencv2413_release.txt,复制粘贴如下代码
<?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>D:opencvuildinclude;D:opencvuildincludeopencv;D:opencvuildincludeopencv2;$(IncludePath)</IncludePath> <LibraryPath>D:opencvuildx86vc12lib;$(LibraryPath)</LibraryPath> </PropertyGroup> <ItemDefinitionGroup> <Link> <AdditionalDependencies>opencv_calib3d2413.lib;opencv_contrib2413.lib;opencv_core2413.lib;opencv_features2d2413.lib;opencv_flann2413.lib;opencv_gpu2413.lib;opencv_highgui2413.lib;opencv_imgproc2413.lib;opencv_legacy2413.lib;opencv_ml2413.lib;opencv_nonfree2413.lib;opencv_objdetect2413.lib;opencv_ocl2413.lib;opencv_photo2413.lib;opencv_stitching2413.lib;opencv_superres2413.lib;opencv_ts2413.lib;opencv_video2413.lib;opencv_videostab2413.lib;%(AdditionalDependencies)</AdditionalDependencies> </Link> </ItemDefinitionGroup> <ItemGroup /> </Project>
4、将opencv2413_debug.txt和opencv2413_release.txt更名为opencv2413_debug.props和opencv2413_release.props
在以后的项目中,只需要添加这两个属性表即可。