1. 程式人生 > >Ubuntu16.04下安裝opencv3.2.0-python3

Ubuntu16.04下安裝opencv3.2.0-python3

搭建環境:Ubuntu16.04 CUDA8.0  Cudnn5.1  python3.5.0

1.在home下新建資料夾

mkdir opencv3.2
cd opencv3.2

2.將下載好的opencv3.2.0拷貝到該資料夾內

cd opencv-3.2.0
mkdir build
cd build

3.使用cmake編譯opencv原始碼,在編譯前請確認所有的依賴項已經正確安裝,可執行如下命令:

sudo apt-get install build-essential
sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev
sudo apt-get install python3-dev python3-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev

4.使用cmake執行編譯

cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local PYTHON3_EXECUTABLE = /usr/bin/python3 PYTHON3_INCLUDE_DIR = /usr/include/python3.5 PYTHON3_INCLUDE_DIR2 = /usr/include/x86_64-linux-gnu/python3.5m PYTHON3_LIBRARY = /usr/lib/x86_64-linux-gnu/libpython3.5m.so PYTHON3_NUMPY_INCLUDE_DIRS = /usr/local/lib/python3.5/dist-packages/numpy/core/include/ ..

出現問題:
-- ICV: Downloading ippicv_linux_20151201.tgz...
CMake Error at 3rdparty/ippicv/downloader.cmake:73 (file):
  file DOWNLOAD HASH mismatch for file: [/home/ubuntu/opencv3.2/opencv-3.2.0/3rdparty/ippicv/downloads/linux-808b791a6eac9ed78d32a7666804320e/ippicv_linux_20151201.tgz]
      expected hash: [808b791a6eac9ed78d32a7666804320e]
        actual hash: [25c44055a61b00cbda6e096f3e9b5c07]
             status: [28;"Timeout was reached"]
Call Stack (most recent call first):
  3rdparty/ippicv/downloader.cmake:110 (_icv_downloader)
  cmake/OpenCVFindIPP.cmake:243 (include)
  cmake/OpenCVFindLibsPerf.cmake:37 (include)
  CMakeLists.txt:558 (include)
CMake Error at 3rdparty/ippicv/downloader.cmake:77 (message):
  ICV: Failed to download ICV package: ippicv_linux_20151201.tgz.
  Status=28;"Timeout was reached"
Call Stack (most recent call first):
  3rdparty/ippicv/downloader.cmake:110 (_icv_downloader)
  cmake/OpenCVFindIPP.cmake:243 (include)
  cmake/OpenCVFindLibsPerf.cmake:37 (include)
  CMakeLists.txt:558 (include)
-- Configuring incomplete, errors occurred!
See also "/home/ubuntu/opencv3.2/opencv-3.2.0/build/CMakeFiles/CMakeOutput.log".
See also "/home/ubuntu/opencv3.2/opencv-3.2.0/build/CmakeFiles/CmakeError.log".
通過
https://www.jianshu.com/p/3b4445253607
,發現問題

將/home/ubuntu/opencv3.2/opencv-3.2.0/3rdparty/ippicv/downloads/linux-808b791a6eac9ed78d32a7666804320e/ippicv_linux_20151201.tgz更換
再次cmake
-- ICV: Unpacking ippicv_linux_20151201.tgz to /home/ubuntu/opencv3.2/opencv-3.2.0/build/3rdparty/ippicv...
-- ICV: Package successfully downloaded

.........(最後微笑

-- Configuring done
-- Generating done
-- Build files have been written to: /home/ubuntu/opencv3.2/opencv-3.2.0/build

5.然後進行編譯

make -j400
sudo make install

6.測試

cd
python3
import cv2