Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I access the Kinect using Java?

I am currently in a Computer Vision course and for my final project I am going to make a small game that interacts with the Kinect.

Now I want to make this game in Java as I have never really ventured into making a game before and I am very comfortable with the Language. But I cannot seem to find a way to just access the Depth data (I just need to pack it into some Java Data structure) and the RGB data (same idea).

Right now, I have a way to 'talk' to the Kinect. I followed this tutorial and can detect the kinect using the command glview in terminal.

I have a thing called Processing which promised to be a Java library to let me use the Kinect but it is using it's own language which is 'built' using Java so it's not really Java which means I can't use all the GUI and normal Java features.

What I want to do is somehow call some import random.Kinect.code; at the top of the Java program that lets me use the most basic Kinect features, like getDepth() or getRGB() and do everything else in Java.

Does anyone know a way I can do this? (BTW I'm running MAC OSX Lion)

like image 266
Alex Avatar asked Jul 20 '12 08:07

Alex


2 Answers

If you're using Processing I recommend using one of the available wrappers:

  • Daniel Shiffman's OpenKinect Processing (using openkinect/libfreenect)
  • SimpleOpenNI - Processing OpenNI wrapper

Both are well documented and include plenty of helpful examples.

simpleOpenNI sample

like image 89
George Profenza Avatar answered Oct 01 '22 14:10

George Profenza


I had exactly the same problem. I wanted to use Kinect in Java for my Computer Vision research, and I had a Mac OSX Lion like you. The solution that I found is to run a virtual copy of Windows 7 in my Mac (using VMWare or Parallels or Microsoft HyperV) and then use the open source J4K Java for Kinect library, which is a Java binding for the Kinect SDK using the Java Native Interface (JNI). Of course you can also use this open source library directly in computers that run Windows.

The J4K Java library for Kinect also has a tutorial on how to write a kinect based application in just 10 lines of Java code.

There are also several source code examples that shows you how to read depth, video, and skeleton data from the Kinect and use them in Java classes. You can also use multiple Kinects, animate avatars, and other examples. The link to the source code examples is here .

A screenshot of the open source Kinect Viewer, which is useful for Computer Vision applications like yours is below:enter image description here

I hope that this information helped.

like image 26
Angelos B Avatar answered Oct 01 '22 16:10

Angelos B