Monday, April 16, 2012

Install OpenCV 2.3 with Python support

http://www.youtube.com/watch?v=b3IQyhJXK78


/* Installing OpenCV 2.3 in Ubuntu.I had a lot of problems initially to install and port the OpenCV library to Python. But after reading a lot of blogs I finally found a solution which I have posted below. */


//jayneil.dalal@gmail.com

//28-10-11

1)Install all pre requisites

sudo apt-get install build-essential

sudo apt-get install cmake

sudo apt-get install pkg-config

sudo apt-get install libpng12-0 libpng12-dev libpng++-dev libpng3

sudo apt-get install libpnglite-dev libpngwriter0-dev libpngwriter0c2

sudo apt-get install zlib1g-dbg zlib1g zlib1g-dev

sudo apt-get install libjasper-dev libjasper-runtime libjasper1

sudo apt-get install pngtools libtiff4-dev libtiff4 libtiffxx0c2 libtiff-tools

sudo apt-get install libjpeg8 libjpeg8-dev libjpeg8-dbg libjpeg-prog

sudo apt-get install ffmpeg libavcodec-dev libavcodec52 libavformat52 libavformat-dev

sudo apt-get install libgstreamer0.10-0-dbg libgstreamer0.10-0  libgstreamer0.10-dev

sudo apt-get install libxine1-ffmpeg  libxine-dev libxine1-bin

sudo apt-get install libunicap2 libunicap2-dev

sudo apt-get install libdc1394-22-dev libdc1394-22 libdc1394-utils

sudo apt-get install swig

sudo apt-get install libv4l-0 libv4l-dev

sudo apt-get install python-numpy

sudo apt-get install build-essential libgtk2.0-dev libjpeg62-dev libtiff4-dev libjasper-dev libopenexr-dev cmake python-dev python-numpy libtbb-dev libeigen2-dev yasm libfaac-dev libopencore-amrnb-dev libopencore-amrwb-dev libtheora-dev libvorbis-dev libxvidcore-dev

2)Install the python development headers

sudo apt-get install python-dev

3)Download the source code: 
http://sourceforge.net/projects/opencvlibrary/files/opencv-unix/2.3/

4)Go to the directory where OpenCV is downloaded via the terminal only and then un zip the package:
(note:- It is recommended that you move the downloaded OpenCV package to the home/<user> directory

tar -xvf OpenCV-2.3.1a.tar.bz2

cd OpenCV-2.3.1/
 
5)Now make a new directory called build and go in to it
mkdir build
cd build

6)Run Cmake

cmake -D WITH_TBB=ON -D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_V4L=OFF -D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON -D BUILD_EXAMPLES=ON ..

7)Now make

make

8) Make it permanent

sudo make install


9)Configuring OpenCV for using shared libraries:

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

Close the file and run the following command to configure the library:

sudo ldconfig

OR RUN : export LD_LIBRARY_PATH=/usr/local/lib
10)Open your .bashrc file and add the following:
gedit .bashrc

sudo gedit /etc/bash.bashrc


add the following at the end of the file -
 

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

Save and close the file

11) Reboot the system

http://ubuntuone.com/0qwnXh8VoufDMHGiu5kLIK (Link to download this text file)


No comments:

Post a Comment