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.





Sunday, May 29, 2011

How to obtain a Facebook access token to use face.com functionality

This is simple and here are the steps to follow.

1. Go to http://www.facebook.com/developers/apps.php/ page and create a new app and obtain your FB appID, api key and api secret.

2. If not, you have to create a face.com account and obtain a face.com API key, secret pair.

3. And register this FB api key and secret with your face.com API key. You can go to edit account settings in face.com and apply this.

Use app ID to fill client_id(i.e client_id=appID) to follows with redirect url and get the auth token. AND SKIP THE expire time variable also.
NOTE: Redirect_url should be in the same domian you specified your app in FB.

https://graph.facebook.com/oauth/authorize?
type=user_agent&
client_id=your_FB_APPID&
redirect_uri=http://abc.com/&
scope=user_photos,email,user_birthday,user_online_presence,offline_access

Out put of redirect url can be something like this and obtain the access token and use this to access the API.

http://face.com/about.php/#access_token=2242657575991sadasdasf1faf9%7C2.%7CYwds6rrGtfpOi7c&expires_in=0

Tuesday, July 6, 2010

Configuration to mount MySQL data sources on a standalone tomcat server

There are loads of google searches for $Title.So following steps will guide you ,how to do that with a sample testing web app.

1. Gather requirements :
  • Tomcat 5.5 or above
  • MySQL database server
  • Connector: mysql-connector-java-3.1.7-bin.jar
2. Place the mysql connector in CATALINA_HOME/common/lib

3. Create your own sample web app say "myApp".

4. Then place this XML Context tag entry in server.xml (CATALINA_HOME/conf/server.xml) inside .........



Note that ,the username ,password are your MySQL credentials.

5.Then we have to tell the server container where is our jdbc data source is , when running our web app.So for that we have to enter the following resource ref tag entry in your web.xml.


6. Then you only have to do is make a datasource and get a connection with a MySQL DB in your webapp ,say inside a jsp and call it.Here is the code

/**


*/

THATS IT.SIMPLE............ENJOY J2EE.......!


Wednesday, June 23, 2010

Webservices and Axis

These days web services are becoming so popular and used in a wide area.Putting up a web service is not something like rocket science. Basically what it does is exchanging data through the Internet in a XML based format which we call "SOAP" (Simple Object Access Protocol).SOAP is meant for exchanging data in a distributed environment, and SOAP is built on XML

So we can say SOAP is a mechanism for inter-application communication between systems written in arbitrary languages, across the Internet. SOAP usually exchanges messages over HTTP.These SOAP messages exchange structured information between SOAP systems and they consist of one or more SOAP elements inside an envelope, Headers and the SOAP Body.So here Axis is an Open Source SOAP server and client which is an Apache project.

Axis implements the JAX-RPC API, one of the standard ways to program Java services.Here we will be talking more about JWS which stands for Java Web Services.

For instance lets say ,a java class which has a method "adder" to add two supplied values.At the end of this article you will find it really easy to expose this adder as a web service.

Lets get in to the action :Now we are going to deploy a web service with Axis.

Step-1:

You need to download and install Axis.For this please follow the install.html under docs directory in your binary distribution of axis.In brief what you have to do is that , copy the axis directory inside your Axis downloaded distribution in to your current web server's webapp directory (it is recommended to have a Apache Tomcat web server)

Step-2:

Also you have to copy any XML parser in to the axis/WEB-INF/lib directory .It is also recommended that to use Apache Xerces parcer and you can download it from here.

Step-3:

Start your web server.And you can simply check whether the installation has succeeded by simply requesting for http://localhost:8080/axis .

Thats it for now.

Above steps are to setup the axis environment.But how we deploy our web service.

Lets take a look at this sample Adder class .

public class Adder {

public int adder(int a, int b) {

return a+b;
}
}

Only you have to do here is that , create this class and name it as Adder.java and copy it in to axis directory and rename it as Adder.jws.This is how your "adder" method becomes a web service under axis framework.

Lets implement a small client to connect to the web service and invoke it.Here is a simple client class for you to run and test how this works.


import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import javax.xml.namespace.QName;

import java.net.*;

public class AdderServiceClient {
public static void main(String [] args) throws Exception {

Service service = new Service();
Call call = (Call)service.createCall();

String endpoint = "http://localhost:8080/axis/Adder.jws";
call.setTargetEndpointAddress(new URL(endpoint));
call.setOperationName(new QName("getCount"));

int a = 12;
int b = 13;
int count = 0;

int total = (Integer)call.invoke(new Object [] {new Integer(a), new Integer(b)});

System.out.println("Got result : " + total);
}
}


Please note that ,what we need to specify is the URL of the jws-file and the name of the method to invoke. Of course we also need to give the two strings with the division and team names. The convention is that they must be given as an Object array.

Now you will see the result as "Got result : 25"

This is a very simple demonstration of how JWS works.

Regards
/subash

Thursday, May 20, 2010

Compiz keyboard short cuts

Desktop Effects1 Keyboard Shortcuts
Rotate Cube Mousewheel on Desktop
Switcher2 Alt + Tab
Shift Switcher3 Super + Tab (2 modes: flip and cover)
Ring Switcher Super + Tab – overrides Shift Switcher
Expo Super + E (toggle)
Film Effect Ctrl + Alt + Down Arrow4
Rotate Cube Manually Ctrl + Alt + Left Mouse Button
Scale Windows Alt + Shift + Up Arrow
Show/Clear Desktop Ctrl + Alt + D (toggle)
Snapping Windows Move a window across workspaces5
Screenshot Super + Left Mouse Button
Zoom In/Out Super + Mousewheel
Transparent Window Alt + Mousewheel
Resize Window Alt + F8
Move Window Alt + F7
Add Helper Super + P
Widget Layer F9 (toggle)
Water Effects Shift + F9 (toggle)
Fire Effects: On Super + Shift + Left Mouse Button
Fire Effects: Clear Super + Shift + C
Annotate: Draw Super + Left Mouse Button
Annotate: Start Super + 1
Annotate: End Super + 3
Group: Select Window(s) Super + S
Group: Group Windows Super + T
Group: Ungroup Windows Super + U
Group: Flip Windows Super + Right or Left Arrow

Friday, May 14, 2010

Problems in connecting with E1550 mobile BB in Ubuntu 10.04

Sometimes Mobile BB ,say E1550 mount it self but doesn't seems to connect or we even can't see it is there.
So the solution for this problem is...:
Do the following steps after plug in your mobile BB.

1. Create a new rule for udev:

$ sudo vi /etc/udev/rules.d/15-huawei-155x.rules

2. Then type the following:

SUBSYSTEM=="usb",
ATTRS{idProduct}=="1446",
ATTRS{idVendor}=="12d1",
RUN+="/lib/udev/modem-modeswitch --vendor 0x$attr{idVendor} --product 0x$attr{idProduct} --type option-zerocd"

And now go to System>Preference>Network Connections and configure your service provider settings.


And enjoy surfing through the WEB with Lucid Linux

Visit http://tinyurl.com/37gkkx4/index.php?u=2618288