How can I access the Kinect using Java?

前端 未结 3 1204
梦如初夏
梦如初夏 2021-02-14 07:13

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

相关标签:
3条回答
  • 2021-02-14 07:39

    I will give you some ideas, but I admit - I did no try them with Kinect.
    You question can be categorized under questions of "How to access some hardware via Java". The tutorial you presented us presents libraries for accessing Kinect, and even wrappers for Python.
    What you can do is see how the Python code implemented the wrappers, and use either JNI/JNA to build your own wrappers.
    In addition, I looked into the JNect project, mentioned here in another answer, posted by @npinti.
    The eclipse plugin has two parts of it -
    the JNI code, which wraps theo riginal SDK code, and the Ecipse RCP code for the eclipse plugin itself.
    I would recommend you to ignore the Eclipse RCP part, and focus on their JNI implementation as a reference to what you need to develop your own JNI wrapper.
    Even if this is windows-based implementation (i.e - Kinect SDK works on windows, and you need to do run your code on mac, for example) - I think that by reading their code + some JNI tutorials + the python wrappers at the link you provided you will understand how to create a JNI wrapper to the library presented in the link you provided.
    In addition, consider using JNA and not JNI as a way to communicate with hardware, I find it easier.
    One last option is maybe to use the Java Script Engine and to invoke Python code (the python wrappers) from your java vode - not sure how much it will help you, but you can give it a shot.

    0 讨论(0)
  • 2021-02-14 07:42

    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.

    0 讨论(0)
  • 2021-02-14 07:56

    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

    0 讨论(0)
提交回复
热议问题