1. 程式人生 > >Windows Compile 編譯 OpenCV build_opencv_python 以便使用sift surf

Windows Compile 編譯 OpenCV build_opencv_python 以便使用sift surf

1. 安裝Visual Studio

安裝Visual Studio選件如下:

2.下載安裝Cmake

根據電腦位數選擇32位或64位 https://cmake.org/download/.

3.下載並解壓OpenCV 和OpenCV Contribute

https://github.com/opencv/opencv/releases https://github.com/opencv/opencv_contrib/releases

不要下載master版本,選擇成熟的release tag 版本,例如3.4.3,OpenCV 和OpenCV Contribute需要版本一致

4.下載安裝numpy

選擇跟python對應的版本,由於我是用python3.5 64 位版本,因此我選擇如下版本numpy:

5.編譯OpenCV

在OpenCV資料夾中建立build資料夾,開啟Cmake,根據下圖選擇目錄,然後單擊Configure按鈕,在生成的列表中確認BUILD_opencv_python3或2已經選擇。

如果想使用sift和surf等非免費特徵檢測演算法,需要啟用如下選項,建議勾選:

選擇完後再點選Configure按鈕,結束後點擊Generate按鈕。等待完成後會出現以下標誌

此時關閉Cmake

開啟cmd命令列,跳轉到build目錄,輸入以下命令:

cmake.exe --build . --config Release --target INSTALL

6.新增環境變數,複製pyd檔案到指定目錄

使用者變數新增OPENCV_DIR,值為build資料夾中install資料夾

系統變數新增Path,值為build\install\x64\vc15\bin

源目錄

指定目錄

完成~