OpenCV+VS2013 屬性表配置
計(jì)算機(jī)視覺任務(wù)越來越多的依賴著名的開源計(jì)算機(jī)視覺庫(kù)OpenCV。OpenCV 2.0 包含了一系列精心設(shè)計(jì)數(shù)據(jù)結(jié)構(gòu)和經(jīng)過優(yōu)化的視覺算法,大家可以短時(shí)間內(nèi)開發(fā)一個(gè)不錯(cuò)的視覺應(yīng)用。OpenCV支持多種不同的硬件和軟件平臺(tái),這也是它被廣泛應(yīng)用的一個(gè)重要原因。使用C/C++開發(fā)OpenCV程序,需要告知編譯器、連接器相應(yīng)的頭文件目錄、庫(kù)文件以庫(kù)文件的目錄,在開發(fā)不同的項(xiàng)目的時(shí)候,每次都分別指定這三項(xiàng)內(nèi)容操作起來有些麻煩,本文針對(duì)OpenCV+VS2013介紹一種通過添加屬性表和合并調(diào)試環(huán)境變量的方式來簡(jiǎn)化配置過程。
本文測(cè)試過的具體情況有:
在OpenCV的官方網(wǎng)站下載相應(yīng)的版本(這里測(cè)試過2.4.10,2.4.11,2.4.12,3.0.0四個(gè)版本)。下載完成后,雙擊相應(yīng)的exe文件,它會(huì)自解壓到你指定的目錄下。在解壓后的目錄下找到build目錄,將此目錄下的所有內(nèi)容拷貝到某個(gè)固定的目錄下,以后的開發(fā)都會(huì)引用這個(gè)目錄,所以最好慎重選擇存放位置。例如我將OpenCV2.4.10的build目錄的所有內(nèi)容存放在K:OpenCV2.4.10
這個(gè)目錄下,(后面的配置過程都將以此目錄為例),
將x64和x86兩個(gè)目錄下的vc12、vc11和vc10分別改成vc12.0、vc11.0和vc10.0
屬性表以2.4.10為例。新建一個(gè)文本文件,將其重命名為”O(jiān)penCV_2.4.10.props”(不要帶引號(hào))。用記事本編輯,拷貝如下內(nèi)容:
K:OpenCV2.4.10includeopencv;K:OpenCV2.4.10include;$(IncludePath)
K:OpenCV2.4.10$(PlatformShortName)vc$(VisualStudioVersion)lib;$(LibraryPath)
opencv_calib3d2410d.lib;opencv_contrib2410d.lib;opencv_core2410d.lib;opencv_features2d2410d.lib;opencv_flann2410d.lib;opencv_gpu2410d.lib;opencv_highgui2410d.lib;opencv_imgproc2410d.lib;opencv_legacy2410d.lib;opencv_ml2410d.lib;opencv_nonfree2410d.lib;opencv_objdetect2410d.lib;opencv_ocl2410d.lib;opencv_photo2410d.lib;opencv_stitching2410d.lib;opencv_superres2410d.lib;opencv_ts2410d.lib;opencv_video2410d.lib;opencv_videostab2410d.lib;%(AdditionalDependencies)
opencv_calib3d2410.lib;opencv_contrib2410.lib;opencv_core2410.lib;opencv_features2d2410.lib;opencv_flann2410.lib;opencv_gpu2410.lib;opencv_highgui2410.lib;opencv_imgproc2410.lib;opencv_legacy2410.lib;opencv_ml2410.lib;opencv_nonfree2410.lib;opencv_objdetect2410.lib;opencv_ocl2410.lib;opencv_photo2410.lib;opencv_stitching2410.lib;opencv_superres2410.lib;opencv_ts2410.lib;opencv_video2410.lib;opencv_videostab2410.lib;%(AdditionalDependencies)
保存OpenCV_2.4.10.props之后,將文件關(guān)閉。
工程配置新建一個(gè)Win32 控制臺(tái)工程(Win32 Console Application)。在屬性管理器中添加剛才保存的屬性表。所有不同配置可以使用同一個(gè)屬性表,因?yàn)閷傩员韺?duì)所有情況做了處理。
注意:如果屬性表和工程在同一個(gè)分區(qū)下,那么工程文件會(huì)使用相對(duì)路徑。這樣一來,拷貝工程到不同的目錄后,工程就不能被正確加載了。所以,建議將屬性表放到某個(gè)特定的分區(qū),工程目錄最好跟屬性表不要在同一個(gè)分區(qū)。
執(zhí)行編譯后程序編譯成功后,可能會(huì)提示某某dll找不到。將下面的內(nèi)容拷貝到工程的“屬性–> 調(diào)試 –> 環(huán)境”。
PATH=K:OpenCV2.4.10$(PlatformShortName)vc$(VisualStudioVersion)bin;$(PATH) $(LocalDebuggerEnvironment)
附加:其他幾個(gè)版本的屬性表
K:OpenCV2.4.11includeopencv;K:OpenCV2.4.11include;$(IncludePath)
K:OpenCV2.4.11$(PlatformShortName)vc$(VisualStudioVersion)lib;$(LibraryPath)
opencv_calib3d2411d.lib;opencv_contrib2411d.lib;opencv_core2411d.lib;opencv_features2d2411d.lib;opencv_flann2411d.lib;opencv_gpu2411d.lib;opencv_highgui2411d.lib;opencv_imgproc2411d.lib;opencv_legacy2411d.lib;opencv_ml2411d.lib;opencv_nonfree2411d.lib;opencv_objdetect2411d.lib;opencv_ocl2411d.lib;opencv_photo2411d.lib;opencv_stitching2411d.lib;opencv_superres2411d.lib;opencv_ts2411d.lib;opencv_video2411d.lib;opencv_videostab2411d.lib;%(AdditionalDependencies)
opencv_calib3d2411.lib;opencv_contrib2411.lib;opencv_core2411.lib;opencv_features2d2411.lib;opencv_flann2411.lib;opencv_gpu2411.lib;opencv_highgui2411.lib;opencv_imgproc2411.lib;opencv_legacy2411.lib;opencv_ml2411.lib;opencv_nonfree2411.lib;opencv_objdetect2411.lib;opencv_ocl2411.lib;opencv_photo2411.lib;opencv_stitching2411.lib;opencv_superres2411.lib;opencv_ts2411.lib;opencv_video2411.lib;opencv_videostab2411.lib;%(AdditionalDependencies)
K:OpenCV2.4.12includeopencv;K:OpenCV2.4.12include;$(IncludePath)
K:OpenCV2.4.12$(PlatformShortName)vc$(VisualStudioVersion)lib;$(LibraryPath)
opencv_calib3d2412d.lib;opencv_contrib2412d.lib;opencv_core2412d.lib;opencv_features2d2412d.lib;opencv_flann2412d.lib;opencv_gpu2412d.lib;opencv_highgui2412d.lib;opencv_imgproc2412d.lib;opencv_legacy2412d.lib;opencv_ml2412d.lib;opencv_nonfree2412d.lib;opencv_objdetect2412d.lib;opencv_ocl2412d.lib;opencv_photo2412d.lib;opencv_stitching2412d.lib;opencv_superres2412d.lib;opencv_ts2412d.lib;opencv_video2412d.lib;opencv_videostab2412d.lib;%(AdditionalDependencies)
opencv_calib3d2412.lib;opencv_contrib2412.lib;opencv_core2412.lib;opencv_features2d2412.lib;opencv_flann2412.lib;opencv_gpu2412.lib;opencv_highgui2412.lib;opencv_imgproc2412.lib;opencv_legacy2412.lib;opencv_ml2412.lib;opencv_nonfree2412.lib;opencv_objdetect2412.lib;opencv_ocl2412.lib;opencv_photo2412.lib;opencv_stitching2412.lib;opencv_superres2412.lib;opencv_ts2412.lib;opencv_video2412.lib;opencv_videostab2412.lib;%(AdditionalDependencies)
K:OpenCV3.0.0includeopencv;K:OpenCV3.0.0include;$(IncludePath)
K:OpenCV3.0.0$(PlatformShortName)vc$(VisualStudioVersion)lib;$(LibraryPath)
opencv_ts300d.lib;opencv_world300d.lib;%(AdditionalDependencies)
opencv_ts300.lib;opencv_world300.lib;%(AdditionalDependencies)
測(cè)試程序工程及代碼
注意:必須修改相應(yīng)項(xiàng)目中的屬性表路徑,否則不能用!
注意:屬性表要換成你自己的,就是路徑要跟你自己的硬盤上相應(yīng)的路徑對(duì)應(yīng)好!否則不能用!
http://pan.baidu.com/s/1i43Pflr