Setting up Kinect-Assisted Java project in Eclipse – Part 2

In this second article on how to develop kinect assisted applications with java, we will be implementing OpenNI java wrapper into Eclipse and make a simple project for starters.

First add all libraries you use for graphics rendering. Lately I’m familiar with LibGDX for doing graphics in Java so i will be adding its jar files into my project then i will include them in Java Build Path -> Libraries. Anyway i will not go into detail in this part because everybody has their choice of graphics library.

Now, let’s show Eclipse where is our Kinect wrappers and native libraries.
In Eclipse:
1- Click Projects -> Java Build Path -> Libraries
2- Click Add External JARs add select org.OpenNI.jar which is located in “C:Program FilesOpenNISamplesBinRelease”
3- Click Arrow button near Jar file we have just added to expand menu.
4- Double-Click on Native library location and select Jar path which is “C:Program FilesOpenNISamplesBinRelease”

At this stage, we are done with implementing the wrapper. But we need some sample code to test it , right?

Earlier this summer, I started a project to develop a framework to ease kinect assisted development. In git repo of that project I also shared a simplified code for adding skeleton and hand tracking.

Download : http://github.com/ayildirim/bolt

After downloading project
1- Import kinect1 folder as a Java project into eclipse.
2- Click Projects -> Java Build Path -> Projects for your own project (not for the one we just imported)
3- Click Add and select kinect1 which we just imported.

Now, we are done with libraries and classes for basic data acquisition.
You can even run UserTrackerApplication located in kinect1 project to do some skeleton tracking.

Why did we add kinect1 into our own project if it could have worked alone?
We added it into our own project to use its UserTracker class because it does everything needed to be done for tracking

How I use it in my projects?
In following part of the article I will be referring Create and Render methods, These are both LibGDX methods but all graphic libraries methods similar to these ones.
Create : is called before scene or window loaded.
Render : is called every frame to render scene or window.

1- Initate each object and variable of UserTracker class in Create method just like it is done in the Main method of UserTrackerApplication.java
2- In Render method I call updateDepth and repaint methods of UserTracker class so it checks for user movements and show them in its own window.

You can check out a kinect assisted game I develop as a contractor earlier this semester.
Kinect Assisted Interactive Ad Stand : http://www.youtube.com/watch?v=CORwDsC60as
Me testing the game before : http://www.youtube.com/watch?v=_9qrwM2yoEI

Thank you very much for reading :)

2 thoughts on “Setting up Kinect-Assisted Java project in Eclipse – Part 2

  1. Marc-Andre Audet

    Thank you very much for all this precious information. OpenNi has a very poor documentation working with java.

    I get this error when testing UserTrackingApplication.java

    Exception in thread “main” java.lang.UnsatisfiedLinkError: no OpenNI.jni64 in java.library.path
    at java.lang.ClassLoader.loadLibrary(Unknown Source)
    at java.lang.Runtime.loadLibrary0(Unknown Source)
    at java.lang.System.loadLibrary(Unknown Source)
    at org.OpenNI.NativeMethods.(NativeMethods.java:32)
    at org.OpenNI.Context.initFromXmlEx(Context.java:317)
    at org.OpenNI.Context.createFromXmlFile(Context.java:36)
    at org.OpenNI.Samples.UserTracker.UserTracker.(UserTracker.java:147)
    at org.OpenNI.Samples.UserTracker.UserTrackerApplication.main(UserTrackerApplication.java:67)

    maybe you faced this issue and could solve this quite easily.

    Keep up the good work.

    Mark

    Reply
    1. Ahmet YILDIRIM Post author

      Hi,
      Sorry for the late response.
      Becareful, If you are going to using 32bit openni, everything else should be 32bit. Java, Eclipse & jar ( & native lib. location ) all of them must be in same arch. 32 or 64. Any arch. difference in these settings will cause that error.

      Reply

Leave a Reply to Marc-Andre Audet Cancel reply