Windows環境下編譯OpenCV3.0和OpenCV_contrib【原創】

1、下載安裝

下載以上內容並安裝opencv和cmake-gui,個人OpenCV安裝路徑爲D:\opencv3ide

2、使用cmake生成OpenCV.sln

  1. 打開cmake-guivisual-studio

  2. 在where is the source code選擇opencv的安裝目錄,個人是D:\opencv3\opencv\sourcesui

  3. 在where to build the binaries裏面選擇要將opencv編譯到的目錄下面,個人是:D:\opencv3\opencv\mybuild.net

  4. 點擊configure,在彈出的對話框內選擇 Visual Studio 2013和default參數,點擊finish。debug

  5. 這個時候cmake會開始編譯不知道什麼東西,而後會在屏幕中間出現一堆參數包括Name和Value,在其中找到Name爲OPENCVEXTRAMODULESPATH的參數,而後把它的Value設置爲opencvcontrib的路徑,個人是D:/Files/Codes/Tracking/Exp/opencvcontrib-master/opencvcontrib-master/modules3d

  6. 而後點擊Generate,等待。中間報了兩次錯,我去掉了BUILDopencvadas和WITH_CUDA等一系列看起來沒用的東西,而後就完成了。code

3、用VS編譯生成debug和release庫

  1. 打開D:\opencv3\opencv\mybuild目錄下的OpenCV.sln

  2. 編譯debug版本庫:在「解決方案'OpenCV'(141個項目)」上面點擊右鍵-->從新生成解決方案。

  3. 找到CMakeTargets中的INSTALL,而後右鍵選擇「僅限於項目」-->「僅生成INSTALL」,而後就在D:\opencv3\opencv\mybuild\install中發現了許多東東。

4、從新配置本身的項目

  1. VC++目錄-->包含目錄,添加:
    D:\opencv3\opencv\mybuild\install\include

  2. VC++目錄-->庫目錄,添加:
    D:\opencv3\opencv\mybuild\install\x86\vc12\lib
    D:\opencv3\opencv\mybuild\install\x86\vc12\staticlib

  3. 連接器-->輸入-->附加依賴項,添加:

opencv_bgsegm300d.lib
opencv_bioinspired300d.lib
opencv_calib3d300d.lib
opencv_ccalib300d.lib
opencv_core300d.lib
opencv_datasets300d.lib
opencv_face300d.lib
opencv_features2d300d.lib
opencv_flann300d.lib
opencv_hal300d.lib
opencv_highgui300d.lib
opencv_imgcodecs300d.lib
opencv_imgproc300d.lib
opencv_latentsvm300d.lib
opencvlinedescriptor300d.lib
opencv_ml300d.lib
opencv_objdetect300d.lib
opencv_optflow300d.lib
opencv_photo300d.lib
opencv_reg300d.lib
opencv_rgbd300d.lib
opencv_saliency300d.lib
opencv_shape300d.lib
opencv_stereo300d.lib
opencv_stitching300d.lib
opencv_superres300d.lib
opencvsurfacematching300d.lib
opencv_text300d.lib
opencv_tracking300d.lib
opencv_ts300d.lib
opencv_video300d.lib
opencv_videoio300d.lib
opencv_videostab300d.lib
opencv_xfeatures2d300d.lib
opencv_ximgproc300d.lib
opencv_xobjdetect300d.lib
opencv_xphoto300d.lib
ippicvmt.lib

5、參考文獻

【1】https://github.com/Itseez/opencv_contrib/blob/master/README.md
【2】http://www.huqiwen.com/2012/11/27/compile-opencv-243-in-visual-studio-2012/

相關文章
相關標籤/搜索