感謝這位部落客:https://blog.csdn.net/love666666shen/article/details/76449155
鏡像網站和安裝包都很齊全。
這裡我用的是百度雲連結:https://pan.baidu.com/s/1hsKMr8g
接下來記錄一下安裝的過程及遇到的問題。
1.安裝依賴檔案
sudo apt-get install build-essential
sudo apt-get install libgtk2.0-dev libavcodec-dev libavformat-dev libtiff4-dev libswscale-dev libjasper-dev
2.解壓opencv檔案,在解壓後的檔案夾中建立檔案夾 build ,進入build檔案夾,打開終端
輸入:
cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local -D OPENCV_EXTRA_MODULES_PATH= /(build所在的檔案夾)/ ..
或者:cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local/..
在這個過程中會出現如下情況:
ICV: Downloading ippicv_linux_20151201.tgz...
可以在如下網址中手動下載下傳:
https://raw.githubusercontent.com/Itseez/opencv_3rdparty/81a676001ca8075ada498583e4166079e5744668/ippicv/ippicv_linux_20151201.tgz
将下載下傳後的 檔案ippicv_linux_20151201.tgz替換
opencv-3.2.0/3rdparty/ippicv/downloads/linux-808b791a6eac9ed78d32a7666804320e
檔案下
重新運作如下指令
cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local -D OPENCV_EXTRA_MODULES_PATH= /(build所在的檔案夾)/ ..
或者:cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local/..
3.終端輸入
make
sudo make install
在終端輸入python ,import cv2.出現問題的話,需要下載下傳opencv-python
pip install opencv-python
就可以成功 import cv2