Notice: MediaWiki has been updated. Report any rough edges to marcan@marcan.st
Java JNI Wrapper: Difference between revisions
mNo edit summary |
mNo edit summary |
||
Line 19: | Line 19: | ||
<br>2. Move to the Java wrapper directory: | <br>2. Move to the Java wrapper directory: | ||
$ cd ./libfreenect/wrappers/java/ | $ cd ./libfreenect/wrappers/java/ | ||
3. Tweak build.sh as needed. | <br>3. Tweak build.sh as needed. For one FC12 install 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: | <br>4. Build the jar: | ||
$ sh build.sh | $ sh build.sh | ||
Revision as of 19:30, 3 December 2010
Effort to create a Java JNI wrapper for libfreenect.
About
TODO
Who is involved
Coordinator/Development: Michael Nischt
Current Status
TODO
Compilation
RedHat/Fedora Linux
1. Install libfreenect based RedHat/Fedora instructions here:
http://openkinect.org/wiki/Installation/
Until JNI code has been merged into https://github.com/OpenKinect/libfreenect.git use https://github.com/michael-nischt/libfreenect.git
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 one FC12 install 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
Demo
RedHat/Fedora Linux
1. Compile the demo:
$ javac -d ./ -classpath .:./dist/OpenKinect.jar ./OpenKinect/src/Example.java
2. Move to the executable directory:
$ cd dist
3. Change to root:
$ su
4. 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 may not see it without the "-D" option. This results in "Exception in thread "main" java.lang.UnsatisfiedLinkError: no OpenKinect in java.library.path"
The demo creates two jpg files, "kinect.color.jpg" & "kinect.depth.jpg" in the current user's home directory (e.g "/root/"). If you have those files, you've succeeded.
Sample Code
TODO