1. 為方便稍後的設定與未來專案的移植性,在安裝完OpenCV 3.0後首先要設定OpenCV的環境目錄,使用管理員的權限開啟Command視窗輸入
1: setx -m OPENCV_DIR e:\sdk\opencv\build
2. 開啟VS2012,匯入我設定好的property setting (OpenCV300.zip),OpenCV300.props的內容如下:
1: <?xml version="1.0" encoding="utf-8"?>
2: <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
3: <ImportGroup Label="PropertySheets" />
4: <PropertyGroup Label="UserMacros" />
5: <PropertyGroup>
6: <IncludePath>$(OPENCV_DIR)\include;$(IncludePath)</IncludePath>
7: <LibraryPath Condition="'$(Platform)'=='Win32'">$(OPENCV_DIR)\x86\vc11\staticlib;$(LibraryPath)</LibraryPath>
8: <LibraryPath Condition="'$(Platform)'=='X64'">$(OPENCV_DIR)\x64\vc11\staticlib;$(LibraryPath)</LibraryPath>
9: </PropertyGroup>
10: <ItemDefinitionGroup>
11: <Link Condition="'$(Configuration)'=='Debug'">
12: <AdditionalDependencies>ippicvmt.lib;IlmImfd.lib;libjasperd.lib;libjpegd.lib;libpngd.lib;libtiffd.lib;libwebpd.lib;opencv_calib3d300d.lib;opencv_core300d.lib;opencv_features2d300d.lib;opencv_flann300d.lib;opencv_hal300d.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;zlibd.lib;%(AdditionalDependencies)</AdditionalDependencies>
13: </Link>
14: <Link Condition="'$(Configuration)'=='Release'">
15: <AdditionalDependencies>ippicvmt.lib;IlmImf.lib;libjasper.lib;libjpeg.lib;libpng.lib;libtiff.lib;libwebp.lib;opencv_calib3d300.lib;opencv_core300.lib;opencv_features2d300.lib;opencv_flann300.lib;opencv_hal300.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;zlib.lib;%(AdditionalDependencies)</AdditionalDependencies>
16: </Link>
17: </ItemDefinitionGroup>
18: <ItemGroup />
19: </Project>
若編譯的環境為VS2013則將上述的設定檔中的vc11改為vc12即可。
由於使用的是static lib所以原專案的runtime library也必需改為/MT或/MTd