Sunday, June 26, 2011

Installing OpenCV 2.2.0 in Ubuntu 10.10


Here are the detailed steps required to install OpenCV-2.2.0 in Ubuntu 10.10.
1. Download OpenCV from http://sourceforge.net/projects/opencvlibrary/file/opencvunix/2.2/
2. Extract the files in a folder preferably in home folder eg: 'home/jai/OpenCV'.
3. Install the pre-requisites by typing the following in the terminal
$ sudo apt-get install build-essential libgtk2.0-dev libavcodec-dev libavformat-dev libjpeg62-dev libtiff4-dev cmake libswscale-dev libjasper-dev
$ sudo apt-get install cmake-gui
$ sudo apt-get install cmake
4. create a folder 'build' in 'home/OpenCV'
5. start cmake by typing the following in terminal
$ cmake-gui
give “where the source code is” path as 'home/jai/OpenCV'
give “where to build the binaries” path as 'home/jai/OpenCV/build'
configure it till no more red tab appears. Click on generate. This generates the binaries required to install OpenCV in 'home/jai/OpenCV/build'.
6. Go to the build directory in and install OpenCV by typing as follows in the terminal
$ cd ~/jai/OpenCV/build
$ make
$ sudo make install
7. Now to configure the library. First, open the opencv.conf file with the following code:
$ sudo gedit /etc/ld.so.conf.d/opncv.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
8. Run the following code to configure the library:
$ sudo ldconfig
9. Now, Open another file:
$ sudo gedit /etc/bash.bashrc
Add the following two lines and save it.
PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig
export PKG_CONFIG_PATH
10. Restart the computer. OpenCV is installed now.


Compiling any OpenCV programs eg- test.cpp:
go to the working directory by using cd in terminal and type the following
$ gcc `pkg-config --libs --cflags opencv` -o test test.cpp
This creates a binary file with name test. To execute it, just type
$ ./test <arguments_if_any>

References:
1. http://opencv.willowgarage.com/wiki/InstallGuide
2. http://www.samontab.com/web/2010/04/installing-opencv-2-1-in-ubuntu/

No comments:

Post a Comment