Skip to content

Instantly share code, notes, and snippets.

@andrepearce
Last active September 1, 2017 14:13
Show Gist options
  • Save andrepearce/4681da89a03b3836a08215e3ea30bc82 to your computer and use it in GitHub Desktop.
Save andrepearce/4681da89a03b3836a08215e3ea30bc82 to your computer and use it in GitHub Desktop.
Install OpenCV for Python3 on Debian (not tested)
# !/bin/bash -ex
OPENCV=3.3.0
OPENCV_CONTRIB=3.3.0
# Install Pre-requisites
sudo apt-get -y update
sudo apt-get -y upgrade
sudo apt-get -y install build-essential cmake git pkg-config wget \
libjpeg-dev libtiff5-dev libjasper-dev libpng12-dev \
libavcodec-dev libavformat-dev libswscale-dev libv4l-dev \
libatlas-base-dev gfortran python3.5-dev unzip
# Install Pip3
wget https://bootstrap.pypa.io/get-pip.py
sudo python3 get-pip.py
# Install NumPy
pip3 install numpy
# Install OpenCV
cd ~
wget https://github.com/opencv/opencv/archive/${OPENCV}.zip
unzip opencv-${OPENCV}.zip
wget https://github.com/opencv/opencv_contrib/archive/${OPENCV_CONTRIB}.zip
unzip opencv_contrib-${OPENCV_CONTRIB}.zip
cd ~/opencv-${OPENCV}
mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D INSTALL_C_EXAMPLES=OFF \
-D INSTALL_PYTHON_EXAMPLES=ON \
-D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib-${OPENCV_CONTRIB}/modules \
-D BUILD_EXAMPLES=ON
make
sudo make install
sudo ldconfig
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment