标签:style blog http color strong os
<?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\lib;$(LibraryPath)</LibraryPath> <LibraryPath Condition="‘$(Platform)‘==‘X64‘">$(OPENCV)\x64\vc12\lib;$(LibraryPath)</LibraryPath> </PropertyGroup> <ItemDefinitionGroup> <Link Condition="‘$(Configuration)‘==‘Debug‘"> <AdditionalDependencies>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;%(AdditionalDependencies)</AdditionalDependencies> </Link> <Link Condition="‘$(Configuration)‘==‘Release‘"> <AdditionalDependencies>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;%(AdditionalDependencies)</AdditionalDependencies> </Link> </ItemDefinitionGroup> <ItemGroup /> </Project>
#include <opencv2\opencv.hpp> #include <iostream> #include <string> using namespace cv; using namespace std; int main() { Mat img = imread("123.jpg"); if (img.empty()) { cout << "error"; return -1; } imshow("照片显示", img); waitKey(); return 0; }注:把照片改名为123.jpg,然后放到工程项目放源文件的文件夹里面,也可以把opencv249.props放到该目录
通过界面新建的属性表要为不同的配置单独建立,导入的时候也要针对配置单独导入。
- 编辑 包含目录 一栏,添加opencv的include路径,例如我的是:$(OPENCV)\include
- 编辑 库目录 一栏,添加opencv的lib路径,例如我的是 :$(OPENCV)\x86\vc12\lib
- 在属性页面 -> 链接器 -> 输入 -> 附加依赖项 -> 编辑。添加下面的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_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
注:唯一的差别是Debug版用到的dll和lib文件都有后缀d,Release版应用的不带d。设备Release的附加依附项时别忘了把d删掉
<?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>$(OPENCV)\x86\vc12\lib;$(LibraryPath)</LibraryPath> </PropertyGroup> <ItemDefinitionGroup> <Link> <AdditionalDependencies>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;%(AdditionalDependencies)</AdditionalDependencies> </Link> </ItemDefinitionGroup> <ItemGroup /> </Project>
<?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>$(OPENCV)\x86\vc12\lib;$(LibraryPath)</LibraryPath> </PropertyGroup> <ItemDefinitionGroup> <Link> <AdditionalDependencies>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;%(AdditionalDependencies)</AdditionalDependencies> </Link> </ItemDefinitionGroup> <ItemGroup /> </Project>
设置64位方法:(上面全改成x64)
vs2013配置opencv2.4.9,布布扣,bubuko.com
标签:style blog http color strong os
原文地址:http://www.cnblogs.com/ggzone/p/3852688.html