Skip to content

Instantly share code, notes, and snippets.

@ajonnet
Forked from dapperfu/opencv320.sh
Created December 14, 2017 13:50
Show Gist options
  • Save ajonnet/82eab87f66e5c465decf143457e0935b to your computer and use it in GitHub Desktop.
Save ajonnet/82eab87f66e5c465decf143457e0935b to your computer and use it in GitHub Desktop.
Build .deb package for OpenCV 3 w/Python3 bindings.
#!/usr/bin/env bash
# Config
MAINTAINER="Jed Frey"
VERSION=3.2.0
# Adapted from http://www.pyimagesearch.com/2016/10/24/ubuntu-16-04-how-to-install-opencv/
apt-get install --yes libjpeg-dev libtiff5-dev libjasper-dev libpng12-dev libavcodec-dev libavformat-dev \
libswscale-dev libxvidcore-dev libx264-dev libv4l-dev liblapacke-dev libgtk-3-dev \
libopenblas-dev libhdf5-dev libtesseract-dev libleptonica-dev \
python3-numpy python3-dev checkinstall cmake gfortran curl
# Make a new directory
rm -rf ~/opencv-build
mkdir ~/opencv-build
cd ~/opencv-build
# Download OpenCV
curl -L https://github.com/opencv/opencv/archive/${VERSION}.tar.gz | tar xz
curl -L https://github.com/opencv/opencv_contrib/archive/${VERSION}.tar.gz | tar xz
cd opencv-${VERSION}
# Make build directory.
mkdir build
# Change to
cd build
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D BUILD_SHARED_LIBS=ON\
-D INSTALL_PYTHON_EXAMPLES=ON -D INSTALL_C_EXAMPLES=ON \
-D OPENCV_EXTRA_MODULES_PATH=~/opencv-build/opencv_contrib-${VERSION}/modules \
-D PYTHON_DEFAULT_EXECUTABLE=$(which python3) -D PYTHON_EXECUTABLE=$(which python3) \
-D WITH_CUBLAS=ON -D WITH_NVCUVID=ON -D BUILD_EXAMPLES=ON ..
make -j8
make
checkinstall --default \
--type debian --install=no \
--pkgname opencv3 \
--pkgversion "${VERSION}" \
--pkglicense BSD \
--deldoc --deldesc --delspec \
--requires "libtesseract3,ffmpeg,libjasper1" \
--pakdir ~ --maintainer "${MAINTAINER}" --provides opevcv3 \
--addso --autodoinst \
make install
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment