Skip to content

Instantly share code, notes, and snippets.

@tejashah88
Last active November 16, 2018 11:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tejashah88/12751d41a5213c024b6814fe856e37f0 to your computer and use it in GitHub Desktop.
Save tejashah88/12751d41a5213c024b6814fe856e37f0 to your computer and use it in GitHub Desktop.
Quick & dirty script to install Python 3 OpenCV libraries with main & contrib modules
# Get latest packages
sudo apt-get update && sudo apt-get dist-upgrade -y
sudo apt-get update && sudo apt-get upgrade -y
# Install needed packages to perform common I/O image/video operations and/or math calculations
sudo apt-get update
sudo apt-get install libhdf5-dev libhdf5-serial-dev libharfbuzz-dev liblapack-dev libcblas-dev libwebp-dev \
libilmbase-dev libopenexr-dev libgstreamer1.0-dev libjpeg-dev libtiff5-dev libjasper-dev libpng12-dev \
libavcodec-dev libavformat-dev libswscale-dev libv4l-dev libxvidcore-dev libx264-dev libatlas-base-dev \
gfortran libgstreamer1.0-dev libgtk-3-0 -y
# Install Python 3 and pip
sudo apt-get install python3 python3-pip -y
# Install pre-built OpenCV python bindings with contrib modules
pip3 install opencv-contrib-python-headless # Use this line if you don't want GUI functionality
# pip3 install opencv-contrib-python # Use this line if you want GUI functionality
# Helpful links:
# - Python pre-built binaries for OpenCV: https://github.com/skvark/opencv-python
# - How to install missing packages: https://qiita.com/atuyosi/items/5f73baa08c3408f248e8
# - More missing packages: https://www.pyimagesearch.com/2017/09/04/raspbian-stretch-install-opencv-3-python-on-your-raspberry-pi/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment