Skip to content

Instantly share code, notes, and snippets.

@say2sankalp
Forked from iamgroot42/ocv.sh
Created November 21, 2018 09:20
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save say2sankalp/434f741950733881e95abaeef5c48594 to your computer and use it in GitHub Desktop.
Download and install openCV 3.1 on Ubuntu 16.04 for Python 2 (no virtualenv)
#!/bin/bash
sudo apt-get -y update
sudo apt-get -y upgrade
sudo apt-get install -y build-essential cmake pkg-config
sudo apt-get install -y libjpeg8-dev libtiff5-dev libjasper-dev libpng12-dev
sudo apt-get install -y libavcodec-dev libavformat-dev libswscale-dev libv4l-dev
sudo apt-get install -y libxvidcore-dev libx264-dev
sudo apt-get install -y libgtk-3-dev
sudo apt-get install -y libatlas-base-dev gfortran
sudo apt-get install -y python2.7-dev python3.5-dev
cd ~
git clone https://github.com/opencv/opencv.git
git clone https://github.com/opencv/opencv_contrib.git
sudo pip install numpy
cd ~/opencv
mkdir build
cd build
# CPU only:
cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D INSTALL_PYTHON_EXAMPLES=ON \
-D INSTALL_C_EXAMPLES=OFF \
-D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib/modules \
-D BUILD_EXAMPLES=ON ..
# For CUDA support:
# cmake -D CMAKE_BUILD_TYPE=RELEASE \
# -D WITH_TBB=ON \
# -D WITH_V4L=ON \
# -D WITH_QT=ON \
# -D WITH_OPENGL=ON \
# -D WITH_CUBLAS=ON \
# -D CUDA_NVCC_FLAGS="-D_FORCE_INLINES" \
# -D CMAKE_INSTALL_PREFIX=/usr/local \
# -D INSTALL_PYTHON_EXAMPLES=ON \
# -D INSTALL_C_EXAMPLES=OFF \
# -D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib/modules \
# -D BUILD_EXAMPLES=ON ..
make -j4
make clean
make
sudo make install
sudo ldconfig
python -c "import cv2; print cv2.__version__"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment