Skip to content

Instantly share code, notes, and snippets.

@DavidToca
Created November 5, 2014 15:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DavidToca/393da1eaeb32c93d8a62 to your computer and use it in GitHub Desktop.
Save DavidToca/393da1eaeb32c93d8a62 to your computer and use it in GitHub Desktop.
Install opencv 2.9.4 with python support

upgrate

sudo apt-get update sudo apt-get upgrade

install dependencies

sudo apt-get install build-essential libgtk2.0-dev libjpeg-dev libtiff4-dev libjasper-dev libopenexr-dev cmake python-dev python-numpy python-tk libtbb-dev libeigen3-dev yasm libfaac-dev libopencore-amrnb-dev libopencore-amrwb-dev libtheora-dev libvorbis-dev libxvidcore-dev libx264-dev libqt4-dev libqt4-opengl-dev sphinx-common texlive-latex-extra libv4l-dev libdc1394-22-dev libavcodec-dev libavformat-dev libswscale-dev default-jdk ant libvtk5-qt4-dev

download opencv from source

cd ~ wget http://sourceforge.net/projects/opencvlibrary/files/opencv-unix/2.4.9/opencv-2.4.9.zip unzip opencv-2.4.9.zip cd opencv-2.4.9

build

mkdir build cd build cmake -D WITH_TBB=ON -D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_V4L=ON -D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON -D BUILD_EXAMPLES=ON -D WITH_QT=ON -D WITH_OPENGL=ON -D WITH_VTK=ON ..

install

make sudo make install

edit configuration.

sudo gedit /etc/ld.so.conf.d/opencv.conf

Add the following line at the end of the file(it may be an empty file, that is ok) and then save it:

/usr/local/lib

configurate lib

sudo ldconfig

configure path

sudo gedit /etc/bash.bashrc # or /etc/zshrc if its zsh

Add these two lines at the end of the file and save it:

PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig export PKG_CONFIG_PATH

if you're using virtualenv, copy from your python dist directory

cd /usr/local/lib/python2.7/dist-packages/ sudo cp cv2.so ~/.virtualenvs/the_virtualenv_name/lib/python2.7/site-packages/ sudo cp cv.py ~/.virtualenvs/the_virtualenv_name/lib/python2.7/site-packages/ sudo cp cv.pyc ~/.virtualenvs/the_virtualenv_name/lib/python2.7/site-packages/

test everything works

python ~/opencv-2.4.9/samples/python2/turing.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment