Skip to content

Instantly share code, notes, and snippets.

@dapperfu
Last active November 28, 2019 09:49
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 6 You must be signed in to fork a gist
  • Save dapperfu/d01e2d5b39ef33207efda6e170b8788c to your computer and use it in GitHub Desktop.
Save dapperfu/d01e2d5b39ef33207efda6e170b8788c 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