ubuntu安装opencv-python

到opencv官网下载对应pkg:https://opencv.org/releases/ ,下载 sources file。

这里以opencv-3.4.1.zip为例。

依赖安装

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

编译

unzip opencv-3.4.1.zip
cd opencv-3.4.1
mkdir release
cd release
cmake -DCMAKE_BUILD_TYPE=Release -DOPENCV_GENERATE_PKGCONFIG=ON -DCMAKE_INSTALL_PREFIX=/usr/local ..
make -j7
sudo make install

编译成功

$ python 
>>> import cv2
>>> cv2.__version__
'3.4.1'
>>>

则编译成功。

你可能感兴趣的:(平台搭建)