ubuntu安裝opencv的方法主要有兩種:python
第一種方式安裝的opencv版本通常較低,且不包含ffmpeg解碼等高級功能,若要用到ffmpeg必需要從源碼進行安裝。c++
第一種方式直接輸入命令git
sudo apt-get update sudo apt-get install libcv-dev
第二種方式從源代碼進行安裝,輸入如下指令github
sudo apt-get install cmake sudo apt-get install python-devel numpy sudo apt-get install gcc gcc-c++ sudo apt-get install gtk2-devel sudo apt-get install libv4l-devel sudo apt-get install ffmpeg-devel sudo apt-get install gstreamer-plugins-base-devel sudo apt-get install libpng-devel sudo apt-get install libjpeg-turbo-devel sudo apt-get install jasper-devel sudo apt-get install openexr-devel sudo apt-get install libtiff-devel sudo apt-get install libwebp-devel sudo apt-get install git git clone https://github.com/opencv/opencv.git mkdir build cd build cmake ../ make sudo make install import cv2 as cv print(cv.__version__)
若出現編譯報錯,通常能夠在opencv的github倉庫issue中找到解決方案。web