Skip to content

Instantly share code, notes, and snippets.

@anakaiti
Last active September 25, 2018 17:32
Show Gist options
  • Save anakaiti/d3443c6430a66e7f0da2b635c3413e65 to your computer and use it in GitHub Desktop.
Save anakaiti/d3443c6430a66e7f0da2b635c3413e65 to your computer and use it in GitHub Desktop.
OpenCV 3.4.2 Raspberry Pi Python build
#!/bin/bash
set -ex
# Adapted from https://raspberrypi.stackexchange.com/a/69176
version=3.4.2
mkdir build
cd build
# Install dependencies
sudo apt-get update
sudo apt-get -y upgrade
sudo apt-get -y install build-essential git cmake pkg-config libjpeg-dev libtiff5-dev \
libjasper-dev libavcodec-dev libavformat-dev \
libswscale-dev libv4l-dev libxvidcore-dev libx264-dev \
libgtk2.0-dev libatlas-base-dev gfortran python3-dev
git clone https://github.com/opencv/opencv.git
cd opencv
git checkout $version
cd ..
git clone https://github.com/opencv/opencv_contrib.git
cd opencv_contrib
git checkout $version
cd ..
wget https://bootstrap.pypa.io/get-pip.py
sudo python3 get-pip.py
pip install numpy
cd 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/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