Monday, June 27, 2011

Configuring Eclipse to use OpenCV



This is how I figured out and which was succeeded in getting eclipse to work with Eclipse. This is a bit tedious, but can do this in 15 min :).





1. If you are not already installed Eclipse, first you have to install Eclipse. If you installing eclipse for the first time, better to install a version which supports C++. Instead, if you already have eclipse, only need to do is install the CDT C/C++ plugin for eclipse.

To install CDT plugin use the name as CDT and give an available source repository link. But I could only found "http://download.eclipse.org/releases/ganymede/" available as most of them are not available.

2. Now you have to install OpenCV if not yet installed. So there are few steps to follow to accomplish this.

Because Prebuilt binaries for Linux are not included with the Linux version of OpenCV owing to the large variety of versions of GCC and GLIBC in different distributions (SuSE,Debian, Ubuntu, etc.). If your distribution doesn’t offer OpenCV, you’ll have to build it from sources.

Follow these steps to download the source and build OpenCV.
There are some prerequisite packages to be installed

a) GCC 4.x or later.. you can install it from the following command
sudo apt-get install build-essential
b) And things like pkgconfig , subversion, cmake and etc.

2.1 First download the source. Go to http://sourceforge.net/projects/opencvlibrary and download the tar ball and unzip it to build. Else easiest way is to checkout the src from opencv svn repo .You can do it by simply following command, or choose a latest tag from the svn.

svn co https://code.ros.org/svn/opencv/trunk

2.2 Now have to build this by cmake. So go to your opencv source directory and make a directory to put generated make files.
i.e
mkdir binary
cd binary
cmake ../

2.3 Now go to that binary directory
make
sudo make install

3. Now everything is fine and you can create a C++ project and use opencv.
But before that there is one other thing to do. We have to tell our project where opencv headers and libraries are located in.

3.1 For that purpose, go to Project > Properties goto C/C++ Build and goto Settings > Tool Setting tab.
3.2 There in GCC C++ Compiler in "Includes" or "Directories" you will find an option "-l" to fill. 3.3 Add the path where you installed the opencv in above steps.
3.4 Now go to GCC C++ Linker and set the opencv distribution lib to "Library Search path -L".
3.5 Also in the Libraries -l , add the libraries you want to use. Following are useful set of libraries.
  • opencv_core
  • opencv_imgproc
  • opencv_highgui
  • opencv_ml
  • opencv_video
  • opencv_features2d
  • opencv_calib3d
  • opencv_objdetect
  • opencv_contrib
  • opencv_legacy
  • opencv_flann
4. And now ITS ALL FINE....:-) Happy coding with OpenCV..

For more information please visit

No comments:

Post a Comment