TODO:windows下vs2013+cmake原始碼安裝opencv3.2.0
最近開始折騰opencv了,先用它來做一些簡單的功能實現,然後再深入演算法一探究竟。
當然,天才第一步,環境最先布。
準備:
1、下載opencv3.2.0原始碼,我們可以在opencv官網上下載,或者直接百度搜索opencv3.2.0,我都給各位準備好了
2、下載cmake工具,下載地址,下載最新版3.12就可以
第一步:
1、cmake安裝
將下載好的壓縮包直接解壓到你想放的路徑下面
然後將bin目錄加入到系統環境變數
控制面板-->系統和安全-->高階設定-->設定環境變數-->系統變數
找到PATH後雙擊,選擇新增 D:\cmake-3.12.0-win32-x86\bin(以D盤為例,新增的是你的對應資料夾的路徑,用英文分號;和前面的內容隔開。)
這裡不需要重啟生效,直接新增完成之後就可以用哦。
2、opencv安裝
2.1 原始碼安裝方式:
上面第一步將Cmake的bin資料夾加入到環境變數生效以後,直接在cmd裡面輸入cmake-gui然後回車就可以直接開啟cmake了。(這裡我使用的是Cmder,介面會比windows自帶的cmd介面友好一些,而且可以加入右鍵選單直接開啟,類似於Ubuntu的Terminal,很方便,推薦大家使用,具體安裝方法參見
cmder安裝 提醒:按照上面的方式將D:\cmder_mini新增到環境變數。
Cmder 加入右鍵選單:win+r開啟執行之後輸入cmder,進入cmder後命令行執行Cmder.exe /REGISTER ALL即成功新增到右鍵選單)
如上圖步驟:
1)首先選擇source code的路徑,就是上面的opencv-3.2.0、
2)手動在opencv-3.2.0裡面建一個名字為 build 的資料夾,把 build 資料夾的路徑加到這步
3)點選 Configue
4)就會彈出一個選擇編譯器的介面,選擇自己對應的VS版本就行了。
5)點選Finish
檔案就開始編譯了,第一次編譯的話會下載一些依賴的東西,所以需要多等一會。會有如下生成:
CMake Deprecation Warning at CMakeLists.txt:72 (cmake_policy): The OLD behavior for policy CMP0020 will be removed from a future version of CMake. The cmake-policies(7) manual explains that the OLD behaviors of all policies are deprecated and that a policy should be set to OLD only under specific short-term circumstances. Projects should be ported to the NEW behavior and not rely on setting a policy to OLD. CMake Deprecation Warning at CMakeLists.txt:76 (cmake_policy): The OLD behavior for policy CMP0022 will be removed from a future version of CMake. The cmake-policies(7) manual explains that the OLD behaviors of all policies are deprecated and that a policy should be set to OLD only under specific short-term circumstances. Projects should be ported to the NEW behavior and not rely on setting a policy to OLD. CMake Deprecation Warning at CMakeLists.txt:81 (cmake_policy): The OLD behavior for policy CMP0026 will be removed from a future version of CMake. The cmake-policies(7) manual explains that the OLD behaviors of all policies are deprecated and that a policy should be set to OLD only under specific short-term circumstances. Projects should be ported to the NEW behavior and not rely on setting a policy to OLD. The CXX compiler identification is MSVC 18.0.21005.1 The C compiler identification is MSVC 18.0.21005.1 Check for working CXX compiler: D:/VS2013/VC/bin/cl.exe Check for working CXX compiler: D:/VS2013/VC/bin/cl.exe -- works Detecting CXX compiler ABI info Detecting CXX compiler ABI info - done Detecting CXX compile features Detecting CXX compile features - done Check for working C compiler: D:/VS2013/VC/bin/cl.exe Check for working C compiler: D:/VS2013/VC/bin/cl.exe -- works Detecting C compiler ABI info Detecting C compiler ABI info - done Detecting C compile features Detecting C compile features - done Performing Test HAVE_CXX_FSIGNED_CHAR Performing Test HAVE_CXX_FSIGNED_CHAR - Failed Performing Test HAVE_C_FSIGNED_CHAR Performing Test HAVE_C_FSIGNED_CHAR - Failed FP16: Compiler support is available Check if the system is big endian Searching 16 bit integer Looking for sys/types.h Looking for sys/types.h - found Looking for stdint.h Looking for stdint.h - found Looking for stddef.h Looking for stddef.h - found Check size of unsigned short Check size of unsigned short - done Using unsigned short Check if the system is big endian - little endian Looking for fseeko Looking for fseeko - not found Looking for unistd.h Looking for unistd.h - not found Check size of off64_t Check size of off64_t - failed Looking for assert.h Looking for assert.h - found Looking for fcntl.h Looking for fcntl.h - found Looking for io.h Looking for io.h - found Looking for jbg_newlen Looking for jbg_newlen - not found Looking for mmap Looking for mmap - not found Looking for search.h Looking for search.h - found Looking for string.h Looking for string.h - found Looking for unistd.h Looking for unistd.h - not found Downloading opencv_ffmpeg.dll... Downloading opencv_ffmpeg.dll... Done Downloading opencv_ffmpeg_64.dll... Downloading opencv_ffmpeg_64.dll... Done Downloading ffmpeg_version.cmake... Downloading ffmpeg_version.cmake... Done ICV: Downloading ippicv_windows_20151201.zip...
然後就會得到下面的介面:
這裡根據自己的需求勾選自己需要的選項或者消去自己不需要的選項就可以了,選擇完成後點選 Configure 旁邊的 Generate ,這個過程很快,最後會得到: