My First Java Application

Top  Previous  Next

You will need to install JDK 1.7.0_11 or later. Set the environment variable JAVA_HOME to point to the installation directory for easy reference.

1.Create a directory called Java1.

2.Launch any editor and enter the Java code Java1.java as illustrated in Example 137.

import intel.pcsdk.*;

import java.lang.System.*;

public class Java1 {

   public static void main(String s[]) {

       PXCUPipeline pp=new PXCUPipeline();

       if (!pp.Init(PXCUPipeline.GESTURE)) {

           System.out.print("Failed to initialize PXCUPipeline\n");

           System.exit(3);

       }

       for (;;) {

           if (!pp.AcquireFrame(true)) break;

           PXCMGesture.GeoNode[] nodes=new PXCMGesture.GeoNode[5];

           if (pp.QueryGeoNode(PXCMGesture.GeoNode.LABEL_BODY_HAND_PRIMARY,nodes))

               System.out.print("GeoNode primary-palm ("+nodes[0].positionImage.x+","+nodes[0].positionImage.y+")\n");

           pp.ReleaseFrame();

       }

       pp.Close();

       System.exit(0);

   }

}

Example 137: Java Application Code

3.Build and run the Java application as illustrated in Example 138.

"%JAVA_HOME%\bin\javac" -classpath PXCUPipeline.jar *.java

"%JAVA_HOME%\bin\java"  -classpath PXCUPipeline.jar;. Java1

Example 138: Java Build Script

The Java application prints out palm position if detected.