Java/JNI wrapper

463 views
Skip to first unread message

Michael Nischt

unread,
Nov 29, 2010, 5:52:50 AM11/29/10
to OpenKinect
Hi everyone,

I'd like to contribute the Java/JNI wrapper I wrote recently and hope
it's helpful.

I only tested it on Ubuntu 64bit but in principle it should compile on
any platform. It only comes with a minimal build script which has some
hard-coded paths (for now). Unfortunately, I'm not familiar with
writing cmake scritps and I'm not sure if this would even work with
the Java side.

Anyway, please give it a try and let me know if it works for you:
https://github.com/michael-nischt/libfreenect

Best,
Micha

P.S. Thanks for the great work you all have done!

whatnick

unread,
Nov 29, 2010, 8:24:37 AM11/29/10
to OpenKinect
CMake should support the JNI wrapper. Here is someone using CMake with
a JNI wrapper and the CMakeLists looks simple enough ->
http://forum.kde.org/viewtopic.php?f=64&t=39486. I am sure qDot will
appreciate more wrappers, the more accessible kinect is to all
developers the better.

Cheers,

Tisham.

lucas

unread,
Nov 29, 2010, 10:57:48 AM11/29/10
to openk...@googlegroups.com
I'm really interresting in making it Eclipse fragments from it so that it could make OKinect available to Eclipse/Java people.

(Linux/OSX/Win32 on x86 intel would be fantastic).

cheers,
--
-- Lucas

http://www.ubqt.tv
http://www.vimeo.com/musitable
http://www.ohloh.net/accounts/8371
http://pixfx.free.fr
http://techsparked.com/project/fmurf
http://code.google.com/a/eclipselabs.org/p/ubqt/

Jean-Philippe Encausse

unread,
Nov 29, 2010, 11:18:38 AM11/29/10
to OpenKinect
Great Thanks !

I'm really exiting to be able to use Kinect On Win32/Eclipse.
I hope it will be simple to put in eclipse( I had so many headache
with DLL error when combining Java + Kinect + Processing + OpenCV :( )



On Nov 29, 4:57 pm, lucas <lucas.bigear...@gmail.com> wrote:
> I'm really interresting in making it Eclipse fragments from it so that it
> could make OKinect available to Eclipse/Java people.
>
> (Linux/OSX/Win32 on x86 intel would be fantastic).
>
> cheers,
>

Michael Nischt

unread,
Nov 30, 2010, 4:46:08 AM11/30/10
to OpenKinect
Hi all,

As it seems there is great interest in a win(32) version, I will try
to compile ready to use libraries for Java. However, I had spent some
hours compiling libfreenect on windows without success so far. It
would be great if anyone can share how to this, preferred using mingw
compilers.

Best,
Michael

mslinn

unread,
Nov 30, 2010, 2:05:36 PM11/30/10
to OpenKinect
I also had a frustrating time with Windows before giving up. Proper
docs and even a downloadable binary would be so nice!

Mike

Eidur Arnason

unread,
Nov 30, 2010, 2:22:31 PM11/30/10
to openk...@googlegroups.com
I second that - any good documentation of  something that works on windows would be much appriciated :)

Best regards. Eiður

Nink

unread,
Nov 30, 2010, 3:01:38 PM11/30/10
to openk...@googlegroups.com
Yeah docs are a little lacking I have tried to install most of the demos where someone has released source on lin win and mac with various degrees of success. The dependancies and versions of code all seem to be interdependant on other apps.

Until you start with a fresh install of OS you don't realise that demo code for project a is dependant on something used for prokect b.

Sent from my BlackBerry


From: Eidur Arnason <sprot...@googlemail.com>
Date: Tue, 30 Nov 2010 19:22:31 +0000
Subject: Re: Java/JNI wrapper

johncalgary

unread,
Nov 30, 2010, 4:22:12 PM11/30/10
to OpenKinect
reseconded.
What took 20 minutes on Ubuntu, (including installing the OS and
prerequisites) wasn't fruitful after many hours on windows 7. I got
one of the precompiled version running, but I think that just caused
more problems with having to uninstall drivers.

Shaun Husain

unread,
Nov 30, 2010, 4:30:07 PM11/30/10
to openk...@googlegroups.com
I haven't gone down this route yet, I'm mostly interested in using AS3 to do my simple object/blob detection but have been using the as3-server running on a linux box hooked up to the kinect and consuming the TCP stream over my local network on a windows machine (albeit far from speedy) this way I can use Flash Builder (flex) on my Windows box and don't have to mess with trying to get libfreenect or as3-server (consequently libusb) working in Windows.  Have you all been trying the code posted along with the comment in the video below?
http://www.youtube.com/watch?v=KsvQpUnlp-Y
or is there a newer method I missed along the way?
Thanks everyone, great work,
Shaun

yoda

unread,
Dec 3, 2010, 11:22:03 AM12/3/10
to OpenKinect
Michael,

Thank you very much for the JNI wrapper. I'm running Fedora 12 (32-
bit) so I thought I'd share what was needed to run your Example.java
for that setup. I believe this would be helpful for anyone trying to
run the example who has not worked much with JNI. The only assumption
I make in these instructions is that the user has a proper JDK
installed.

1. Install libfreenect based on your repository. See the RedHat/
Fedora instructions here (http://openkinect.org/wiki/Installation/
Compilation_Guides), but substitute https://github.com/michael-nischt/libfreenect.git
for https://github.com/OpenKinect/libfreenect.git (until your code has
been merged into the main repository). Note that you probably don't
have to go beyond the "clone the repository" step, but probably a good
idea to make sure that glview is working before proceeding.
2. Move to the Java wrapper directory: cd ./libfreenect/wrappers/java/
3. Tweak build.sh as needed. For me this involved removing the "-m64"
g++ option, changing the line "LIBFREENET_LIBRARY=../../lib/
libfreenect.a" to "LIBFREENET_LIBRARY=../../build/lib/libfreenect.a",
and changing "JDK_HOME" to "JAVA_HOME" (just added "JDK_HOME=$
{JAVA_HOME}" before "JNI_SRC_DIR=OpenKinectJNI"
4. Build the jar: "sh build.sh"
5. Compile the demo: "javac -d ./ -classpath .:./dist/OpenKinect.jar ./
OpenKinect/src/Example.java"
6. Move to the executable directory: "cd dist"
7. Change to root: "su"
8. Run the demo: "java -Djava.library.path=. -classpath .:./
OpenKinect.jar Example" Note that the -Djava tells Java where to look
for the native library. Even though libOpenKinect.so is in the
"dist" (current) directory, Java won't see it without the "-D" option
(at least it wouldn't for me - I was getting "Exception in thread
"main" java.lang.UnsatisfiedLinkError: no OpenKinect in
java.library.path")

The demo created two jpg files in the current user's directory ("/
root" for me): "kinect.color.jpg" & "kinect.depth.jpg" If you have
those files, you've succeeded.

Regards.
-Brian

Dave Pentecost

unread,
Dec 3, 2010, 1:40:40 PM12/3/10
to openk...@googlegroups.com
I'd suggest that any detailed how-to's (or additions to them, as this appears to be) get posted to the page on the wiki.

Cheers
Dave
--
Director, Technology
Center for Community
http://www.girlsclub.org/building

@dpentecost
Cell 646 704 2021


yoda

unread,
Dec 3, 2010, 2:24:16 PM12/3/10
to OpenKinect

Kristiyan Georgiev

unread,
Jan 12, 2011, 4:17:19 PM1/12/11
to OpenKinect
Hey I am running NetBeans 6.9 on Ubuntu 10.10 x64

I added the jar to the library/class path, but I get a runtime error

//=================================
package king.kinect;
public class Main { public static void main( final String[] args ) {
if( NativeKinect.init() ) { int[] buf = NativeKinect.getVideo();
System.out.println( buf.length );
System.out.println( "All good" ); } } }
//==========================

Exception in thread "main" java.lang.UnsatisfiedLinkError: no kinect
in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1681)
at java.lang.Runtime.loadLibrary0(Runtime.java:840)
at java.lang.System.loadLibrary(System.java:1047)
at king.kinect.NativeKinect.<clinit>(NativeKinect.java:8)
at king.kinect.Main.main(Main.java:5)
Java Result: 1


Any Ideas ?


On Nov 29 2010, 5:52 am, Michael Nischt <michael.nis...@gmail.com>
wrote:

Jean-Philippe Encausse

unread,
Jan 14, 2011, 11:49:13 AM1/14/11
to OpenKinect
Bump,

Can anybody provides a Win32/Win64 .dll to work with the wrapper under
windows ?
For poor Java Windows developers :)

Reply all
Reply to author
Forward
0 new messages