Skip to content

Instantly share code, notes, and snippets.

@benjiao
Created November 29, 2015 09:37
Show Gist options
  • Save benjiao/02f19bf3ad49ae89b609 to your computer and use it in GitHub Desktop.
Save benjiao/02f19bf3ad49ae89b609 to your computer and use it in GitHub Desktop.
#!/bin/bash
set -e
# ----------------------------------------------------------------------------------------
# Installs OpenCV 2.4.11
# Note: Tested on Ubuntu 14.04
#
# Resources:
#
# http://www.pyimagesearch.com/2015/06/22/install-opencv-3-0-and-python-2-7-on-ubuntu/
# https://gist.github.com/dynamicguy/3d1fce8dae65e765f7c4
# http://stackoverflow.com/questions/15790501/why-cv2-so-missing-after-opencv-installed
#
# To install in virtualenv, run this script then add symlinks to cv2 inside your
# virtual env directory:
#
# cd env/lib/python2.7
# ln -s /usr/local/lib/python2.7/dist-packages/cv.py .
# ln -s /usr/local/lib/python2.7/dist-packages/cv2.so .
#
# ----------------------------------------------------------------------------------------
sudo apt-get install -y unzip
sudo apt-get build-dep -y python-numpy python-scipy
sudo apt-get install -y build-essential
sudo apt-get install -y cmake
sudo apt-get install -y libgtk2.0-dev
sudo apt-get install -y pkg-config
sudo apt-get install -y python-numpy python-dev
sudo apt-get install -y libavcodec-dev libavformat-dev libswscale-dev
sudo apt-get install -y libjpeg-dev libpng-dev libtiff-dev libjasper-dev
sudo apt-get install -y libopencv-dev build-essential checkinstall cmake pkg-config yasm libjpeg-dev libjasper-dev libavcodec-dev libavformat-dev libswscale-dev libdc1394-22-dev libxine-dev libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev libv4l-dev python-dev python-numpy libtbb-dev libqt4-dev libgtk2.0-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libtheora-dev libvorbis-dev libxvidcore-dev x264 v4l-utils
cd ~
wget http://downloads.sourceforge.net/project/opencvlibrary/opencv-unix/2.4.11/opencv-2.4.11.zip
unzip opencv-2.4.11.zip
cd opencv-2.4.11
mkdir release
cd release
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D BUILD_NEW_PYTHON_SUPPORT=ON -D BUILD_EXAMPLES=ON ..
make all -j4 # 4 cores
sudo make install
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment