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

Wednesday, June 8, 2011

How to create a Apache Tuscany SCA component for Apache PhotArk



Apache PhotArk is an open source rich photo gallery application where you can do many things what a typical photo gallery app can do as well as some additional features such as it contains a Google app engine to function in cloud. Apache Tuscany is what PhotArk uses for message passing bridge between front and and back end under Service Component Architecture. This is how you do $Title.

  • Step-1
In Tuscany way first you have to put and SCA component entry to the Tuscany composite, which is in photark, named as web.composite.xml.

 













  • Step2
In Photark web app, there is a sca-contribution.xml file for each of your PhotArk module. So There you have to define the packages you use externally as well as you own package name. So suppose I dont have any dependent external packages to import my service component implementation class. Then your sca-contribution.xml file can be something similar to this.









NOTE : If you are using a brand new PhotArk module, make sure you add the dependency of it not only to the parent pom, but also to the pom inside photark-webapp as well, because in deploying it on tomcat, maven can't find your dependency if you don't add it to this pom.
  • Step 3
Now everything is ready. Make sure you use proper annotations for your service component interface and its implementation. For instance, @Scope("COMPOSITE") for the impl and @Remotable for the interface.
  • Step 4

Call your service through JSON, in PhotArk we make JSON calls through DOJO. So to use the service use the absolute binding url (in composite you define the relative path only..visit constant.js file in PhotArk and you will find the absolute path..)

i.e add PhotArk context root to your tuscany binding url.

In this example it should be /photark/FaceRecognitionService?smd . NOTE : make sure you add "smd" param as well.


I think now its done :) Enjoy Apache products.