Skip to content

Instantly share code, notes, and snippets.

@ajonnet
Forked from willprice/README.md
Created March 27, 2019 07:14
Show Gist options
  • Save ajonnet/3fe476d1c9dbccd741b23e5e2c5e2484 to your computer and use it in GitHub Desktop.
Save ajonnet/3fe476d1c9dbccd741b23e5e2c5e2484 to your computer and use it in GitHub Desktop.
Install OpenCV 3.4.2 on Raspberry Pi Raspbian Stretch
#!/usr/bin/env bash
pushd ~/opencv/opencv-3.4.2
mkdir -p build
pushd build
cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D CMAKE_BUILD_TYPE=RELEASE \
-D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib-3.4.2/modules \
-D OPENCV_ENABLE_NONFREE=ON \
-D BUILD_PERF_TESTS=OFF \
-D BUILD_TESTS=OFF \
-D BUILD_DOCS=ON \
-D BUILD_EXAMPLES=ON \
-D WITH_TBB=ON \
-D WITH_OPENMP=ON \
-D PYTHON3_EXECUTABLE=$(which python2) \
-D PYTHON_EXECUTABLE=$(which python3) \
..
make -j "$(nproc)"
popd; popd
#!/usr/bin/env bash
OPENCV_VERSION=3.4.2
cd ~
mkdir -p opencv && pushd opencv
wget -O "opencv-${OPENCV_VERSION}.tar.gz" "https://github.com/opencv/opencv/archive/${OPENCV_VERSION}.tar.gz"
wget -O "opencv_contrib-${OPENCV_VERSION}.tar.gz" "https://github.com/opencv/opencv_contrib/archive/${OPENCV_VERSION}.tar.gz"
tar -xvf "opencv-${OPENCV_VERSION}.tar.gz"
tar -xvf "opencv_contrib-${OPENCV_VERSION}.tar.gz"
popd
#!/usr/bin/env bash
sudo apt-get purge -y wolfram-engine libreoffice*
sudo apt-get clean
sudo apt-get update
sudo apt-get upgrade -y
sudo apt-get dist-upgrade -y
sudo apt-get autoremove -y
# For some reason I couldn't install libgtk2.0-dev or libgtk-3-dev without running the
# following line
# See https://www.raspberrypi.org/forums/viewtopic.php?p=1254646#p1254665 for issue and resolution
sudo apt-get install -y devscripts debhelper cmake libldap2-dev libgtkmm-3.0-dev libarchive-dev \
libcurl4-openssl-dev intltool
sudo apt-get install -y build-essential cmake pkg-config libjpeg-dev libtiff5-dev libjasper-dev \
libpng12-dev libavcodec-dev libavformat-dev libswscale-dev libv4l-dev \
libxvidcore-dev libx264-dev libgtk2.0-dev libgtk-3-dev \
libatlas-base-dev libblas-dev libeigen3-dev liblapack-dev \
gfortran python2.7-dev python3-dev
sudo pip2 install -U pip
sudo pip3 install -U pip
sudo pip2 install numpy
sudo pip3 install numpy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment