Opencv Java Web Integration on eclipse ubuntu

Using opencv java , you can develop web application which uses opencv image processing libraries on the server.
Prerequisite:
1.) Eclipse Java J2EE version.
2.) Install opencv using configure and download opencv

Now, we will define OpenCV as a user library in Eclipse, so we can reuse the configuration for any project. Launch Eclipse and selectWindow –> Preferences from the menu.


Navigate under Java –> Build Path –> User Libraries and click New....


Enter a name, e.g. OpenCV-2.4.9, for your new library.
Now select your new user library and click Add External JARs....
Browse through /home/anish/opencv-2.4.9/build/lib and select opencv-249.jar. After adding the jar, extend the opencv-249.jar and select Native library location and press Edit....
Select External Folder... and browse to select the folder /home/anish/opencv-2.4.9. If you have a 32-bit system you need to select the x86 folder instead of x64.
Your user library configuration should look like this:

You have successfully configure opencv on eclipse. 
Now start creating a new Java project.

On the Java Settings step, under Libraries tab, select Add Library... and select OpenCV-2.4.9, then click Finish.

Libraries should look like this:
Now you have created and configured a new Java project it is time to test it. Create a new java file. Here is a starter code for your convenience:
import org.opencv.core.Core;
import org.opencv.core.CvType;
import org.opencv.core.Mat;

public class Hello
{
   public static void main( String[] args )
   {
      System.loadLibrary( Core.NATIVE_LIBRARY_NAME );
      Mat mat = Mat.eye( 3, 3, CvType.CV_8UC1 );
      System.out.println( "mat = " + mat.dump() );
   }
}

When you run the code you should see 3x3 identity matrix as output.
mat=[1,0,0;
0,1,0;
0,0,1]

Now ,you have done with basic configuration with project.You are ready to use a powerful opencv with web applications. You can easily apply servlets/jsp and can use this codes in the server scripting.

Comments