how to use the libfreenect processing wrapper on ubuntu

Nikolaus Gradwohl2010-12-28T05:29:13+00:00

Yesterday I got a Kinect and it worked out of the box with the freenect libs on my linux box and my mac. But the processing-wrappers from daniel shiffman only worked on the mac. Since my linux box has a bit more power than my mac-mini, I started to fiddle around a bit with the source code and - TATAAAA - it run's on my ubuntu box.

To make it run check out the git-repository for libkinect by using 'git clone'

git clone git://github.com/shiffman/libfreenect.git

Then build the library using cmake like it's described in the readme

then change to the wrapper/java directory. There you find a small shellscript that compiles the jni- and processing-wrappers. I had to add some include-paths to make the c-compiler find my jni.h and I changed the target system to 32-Bit (by removing the -m64 flag).

On my ubuntu box using the sun jdk the jni.h include-path is this.

-I/usr/lib/jvm/java-6-sun-1.6.0.22/include -I/usr/lib/jvm/java-6-sun-1.6.0.22/include/linux

Then make sure the LIBFREENET_LIBRARY path points to the libfreenect.a file you compiled earlier. If you use a build directory like It's recommendet in the Readme file than don't forget to add it to the path (this took me some time :-/ )

after running the build script install the 'openkinect.zip' from the processing/distribution folder to your sketchbook/library folder and add the libOpenKinect.so file from the dist directory to sketchbook/libraries/openkinect/library

and than make a symlink from 'libOpenKinect.so' to 'libKinect.so'

ln -s libOpenKinect.so libKinect.so

freenect processing wrapper

Tweet This! submit to reddit Digg! Tags: | 17 comments | no trackbacks

See also:

3D mushrooms in processing
foggy wood with recursive trees
isometric labyrinth
mesh made from hexagonal prism - another toxiclib experiment
3D eyes with parametric texture

Trackbacks

Comments

Leave a response

  1. iPhone Development 2011-01-03T06:50:52+00:00

    Thanks for sharing the code, it was very helpful.

  2. Alessandro 2011-01-06T19:29:57+00:00

    using ubuntu 10.10 too and followed all steps, except that haven't removed -m64 as I'm on AMD64. It compiles fine but when running an example I'm getting:

    processing.app.debug.RunnerException: UnsatisfiedLinkError: no kinect in java.library.path

    Got Kinect working with OFX, Nite, OSCeleton, so i'm sure it works by itself... I just can't get this to work, any idea?

  3. Nikolaus Gradwohl 2011-01-07T11:00:35+00:00

    Check if the jvm processing is using isn't running in 32bit mode. I also got tis error when I tried to rename the shared-lib instead of making a symlink

  4. Don Blair 2011-01-07T20:45:39+00:00

    Thanks so much for this! So excited to to get it to work!

    I think I've followed all the steps for Ubuntu 10.10 ... but I can't find the 'libKinect.so' file you refer to in the "ln -s libOpenKinect.so libKinect.so" step?

    When I run the PointCloud example, I get: "UnsatisfiedLinkError: no kinect in java.library.path" ...

    Any ideas what I might be doing wrong?

    Cheers!

  5. Don Blair 2011-01-07T21:31:19+00:00

    Hah -- well, now I just learned what a symbolic link is. Sigh :)

    So I created the libKinect.so symbolic link to libOpenKinect.so ... but I'm still getting the "UnsatisfiedLinkError: no kinect in java.library.path" error ...

  6. Alessandro 2011-01-14T23:52:27+00:00

    Nikolaus, as far as I know my whole stack is running 64 bits, including jvm and processing, I've recently compiled opencv2 beta processing library @64 bits and that's running just fine.

    Any other clue?

  7. Shigeru Imai 2011-02-09T05:41:24+00:00

    Initially I also had an UnstatisfiedLinkError, but I got it work with the following tweaks.

    • Rename java/dist/OpenKinect.jar to java/dist/openkinect.jar
    • Copy the renamed openkinect.jar to sketchbook/libraries/openkinect/library/ (Replace openkinect.jar inflated from openkinect.zip)
  8. Corey 2011-03-07T01:22:18+00:00

    I'm getting an error message "The package "org.openkinect.processing" does not exist. You might be missing a library." It appears it's having issues with the import org.openkinect.processing.* line. I'm not entirely familiar with Java, but I think my problem is that the "processing" directory is not being included in the openkinect.jar compile but I don't see anyone mentioning how to do this.

    Anyone know how to correct this? I am positive I have the openkinect.jar in the correct sketchbook library location.

  9. simple 2011-03-16T15:06:15+00:00

    I can't for the life of me get rid of the "UnsatisfiedLinkError: no kinect in java.library.path". I tried renaming the openkinect.jar as suggested but this does not help.

    Do you have any other suggestions?

  10. simple 2011-03-17T03:38:04+00:00

    Please help! I need this for an urgent project. I am at a complete loss after many hours of searching.

    I am running Ubuntu 10.10 64 bit.

    The ./build.sh runs without any problems.

    Please let me know what else I can share that my help resolve my issue.

  11. naus3a 2011-03-31T16:31:58+00:00

    thanks man: you made my compiling really easy :)

  12. Tim Jones 2011-04-05T23:14:22+00:00

    Many thanks to the blogger for this workaround.

    I was able to resolve the no "kinect in java.library.path" by renaming the link:

    cp libKinect.so libkinect.so

    Or if you are install from scratch, try replacing the blogger's line:

    ln -s libOpenKinect.so libKinect.so

    with:

    ln -s libOpenKinect.so libkinect.so

  13. Alberto Alvares 2011-04-08T21:14:43+00:00

    I have two machines / PC, a 32-bit and a 64bit Ubuntu.

    On the PC with 32-bit works.

    On the PC with 64-bit does not work.

    Error: UnsatisfiedLinkError: no kinect in java.library.path

    How to solve the problem on the PC with 64 bit?

    I've done all the recommended steps.

  14. Alessandro 2011-05-15T11:31:55+00:00

    @Tim Jones: great, that solved the unsatisfied link error for me, thanks!

    @Alberto Alvares: try to not remove the -m64 flag when compiling, I'm on Ubuntu 10.10 64bit and the lib is now working fine.

  15. Frank 2011-05-29T21:49:54+00:00

    I have trouble running the build.sh without errors. This is what appears in the terminal:

    ~/libfreenect/wrappers/java$ sh build.sh OpenKinectJNI/org_openkinect_Context.cpp:27:25: fatal error: libfreenect.h: No such file or directory compilation terminated. OpenKinectJNI/org_openkinect_Device.cpp:27:25: fatal error: libfreenect.h: No such file or directory compilation terminated. /usr/lib/jvm/java-6-sun-1.6.0.24/include/jni.h:27:20: fatal error: jni_md.h: No such file or directory compilation terminated.

    I believe, I edited the build.sh the wrong way.

    I run Ubuntu 11.04 32bit with java jdk installed.

    However, I am new to to Ubuntu, so any help or a "example" build.sh would help a lot. Thanks!

  16. jujulot2002 2011-10-30T12:39:52+00:00

    hello ...i'am trying to make work kinect with processing i use the https://github.com/shiffman/libfreenect.git

    i have a problem with building the liblibOpenKinect.so... i change the build.sh to

    !/bin/sh

    LIBUSB_INCLUDE=-I/usr/include/libusb-1.0 LIBUSB_LIBRARY=-lusb-1.0

    LIBFREENET_INCLUDE=-I../../include/ LIBFREENET_LIBRARY=../../build/lib/libfreenect.a

    -- try to use installed as fallback

    if [ -z ${LIBFREENET_INCLUDE} ]; then LIBFREENET_INCLUDE="/usr/include/libfreenect/"; fi if [ -z ${LIBFREENET_LIBRARY} ]; then LIBFREENET_LIBRARY="/usr/lib/libfreenect.a"; fi

    -- if jdk home is not set try ubuntu default

    if [ -z ${JDK_HOME} ]; then JDK_HOME="/usr/lib/jvm/java-6-openjdk"; fi

    JNI_SRC_DIR=OpenKinectJNI JAVA_SRC_DIR=OpenKinect/src

    mkdir -p dist/javadoc

    g++ -shared -fPIC -Wall -o dist/libOpenKinect.so ${JNI_SRC_DIR}/org_openkinect_Context.cpp OpenKinectJNI/org_openkinect_Device.cpp ${LIBUSB_INCLUDE} ${LIBUSB_LIBRARY} ${LIBFREENET_INCLUDE} ${LIBFREENET_LIBRARY} -I${JDK_HOME}/include/ -I${JDK_HOME}/include/linux/ -L${JDK_HOME}/lib/

    mkdir -p build

    javac -d build -sourcepath ${JAVA_SRC_DIR} ${JAVA_SRC_DIR}/org/openkinect/.java javadoc -d dist/javadoc/ -sourcepath ${JAVA_SRC_DIR} ${JAVA_SRC_DIR}/org/openkinect/.java

    jar cvf dist/OpenKinect.jar -C build .

    rm -R build

    then i make the sh build.sh that give me

    biogene@biogene:~/projet/process/libfreenect/wrappers/java$ sh build.sh Loading source file OpenKinect/src/org/openkinect/Acceleration.java... Loading source file OpenKinect/src/org/openkinect/ColorFormat.java... Loading source file OpenKinect/src/org/openkinect/Context.java... Loading source file OpenKinect/src/org/openkinect/DepthFormat.java... Loading source file OpenKinect/src/org/openkinect/Device.java... Loading source file OpenKinect/src/org/openkinect/Image.java... Loading source file OpenKinect/src/org/openkinect/LEDStatus.java... Loading source file OpenKinect/src/org/openkinect/LogLevel.java... Loading source file OpenKinect/src/org/openkinect/Logger.java... Constructing Javadoc information... Standard Doclet version 1.6.0_23 Building tree for all the packages and classes... Generating dist/javadoc/org/openkinect/Acceleration.html... Generating dist/javadoc/org/openkinect/ColorFormat.html... Generating dist/javadoc/org/openkinect/Context.html... Generating dist/javadoc/org/openkinect/DepthFormat.html... Generating dist/javadoc/org/openkinect/Device.html... Generating dist/javadoc/org/openkinect/Image.html... Generating dist/javadoc/org/openkinect/LEDStatus.html... Generating dist/javadoc/org/openkinect/Logger.html... Generating dist/javadoc/org/openkinect/LogLevel.html... Generating dist/javadoc/org/openkinect/package-frame.html... Generating dist/javadoc/org/openkinect/package-summary.html... Generating dist/javadoc/org/openkinect/package-tree.html... Generating dist/javadoc/constant-values.html... Building index for all the packages and classes... Generating dist/javadoc/overview-tree.html... Generating dist/javadoc/index-all.html... Generating dist/javadoc/deprecated-list.html... Building index for all classes... Generating dist/javadoc/allclasses-frame.html... Generating dist/javadoc/allclasses-noframe.html... Generating dist/javadoc/index.html... Generating dist/javadoc/help-doc.html... Generating dist/javadoc/stylesheet.css... manifest ajouté ajout : org/ (entrée = 0) (sortie = 0) (0% stocké) ajout : org/openkinect/ (entrée = 0) (sortie = 0) (0% stocké) ajout : org/openkinect/Context.class (entrée = 2577) (sortie = 1265) (50% compressés) ajout : org/openkinect/Acceleration.class (entrée = 149) (sortie = 127) (14% compressés) ajout : org/openkinect/Image.class (entrée = 148) (sortie = 134) (9% compressés) ajout : org/openkinect/ColorFormat.class (entrée = 893) (sortie = 488) (45% compressés) ajout : org/openkinect/Device.class (entrée = 2813) (sortie = 1375) (51% compressés) ajout : org/openkinect/Context$1.class (entrée = 968) (sortie = 595) (38% compressés) ajout : org/openkinect/LEDStatus.class (entrée = 1187) (sortie = 630) (46% compressés) ajout : org/openkinect/DepthFormat.class (entrée = 1003) (sortie = 542) (45% compressés) ajout : org/openkinect/Logger.class (entrée = 146) (sortie = 125) (14% compressés) ajout : org/openkinect/LogLevel.class (entrée = 1186) (sortie = 654) (44% compressés)

    everything seems to be good at all..; but the ld give me

    biogene@biogene:~/projet/process/libfreenect/wrappers/java$ ld dist/libOpenKinect.so ld: warning: cannot find entry symbol _start; not setting start address dist/libOpenKinect.so: undefined reference to libusb_cancel_transfer' dist/libOpenKinect.so: undefined reference tolibusb_close' dist/libOpenKinect.so: undefined reference to libusb_open' dist/libOpenKinect.so: undefined reference tolibusb_claim_interface' dist/libOpenKinect.so: undefined reference to libusb_alloc_transfer' dist/libOpenKinect.so: undefined reference tolibusb_free_device_list' dist/libOpenKinect.so: undefined reference to libusb_get_device_list' dist/libOpenKinect.so: undefined reference tolibusb_control_transfer' dist/libOpenKinect.so: undefined reference to libusb_submit_transfer' dist/libOpenKinect.so: undefined reference tolibusb_exit' dist/libOpenKinect.so: undefined reference to libusb_init' dist/libOpenKinect.so: undefined reference tolibusb_free_transfer' dist/libOpenKinect.so: undefined reference to libusb_handle_events' dist/libOpenKinect.so: undefined reference tolibusb_get_device_descriptor' dist/libOpenKinect.so: undefined reference to `libusb_release_interface'

    for information: uname -a Linux biogene 3.0.0-12-generic-pae #20-Ubuntu SMP Fri Oct 7 16:37:17 UTC 2011 i686 i686 i386 GNU/Linux

    biogene@biogene:~/projet/process/libfreenect/wrappers/java$ ldconfig -p | grep usb libusbmuxd.so.1 (libc6) => /usr/lib/libusbmuxd.so.1 libusb-1.0.so.0 (libc6) => /lib/i386-linux-gnu/libusb-1.0.so.0 libusb-1.0.so.0 (libc6) => /usr/lib/i386-linux-gnu/libusb-1.0.so.0 libusb-1.0.so (libc6) => /usr/lib/i386-linux-gnu/libusb-1.0.so libusb-0.1.so.4 (libc6) => /lib/libusb-0.1.so.4 libusb-0.1.so.4 (libc6) => /usr/lib/libusb-0.1.so.4

    processing 1.5.1

    thanks to all personn that can save or help me

  17. Francesco D. 2011-12-10T12:07:53+00:00

    I hope you can help me I am a student at the University of Bergamo and I'm trying to utuilizzare the kinect with java. Using Linux Mint 12 but I have problems creating the JAR file: the compiler returns me the following error:

    In file included from / usr / include / stdint.h: 26:0, from / usr/lib/gcc/i686-linux-gnu/4.6.1/include/stdint.h: 3, from .. / .. / include / libfreenect.h: 30, from OpenKinectJNI / org_openkinect_Context.cpp: 27: / usr / include / features.h: 323:26: fatal error: bits / predefs.h: No such file or directory compilation terminated. In file included from / usr / include / stdint.h: 26:0, from / usr/lib/gcc/i686-linux-gnu/4.6.1/include/stdint.h: 3, from .. / .. / include / libfreenect.h: 30, from OpenKinectJNI / org_openkinect_Device.cpp: 27: / usr / include / features.h: 323:26: fatal error: bits / predefs.h: No such file or directory compilation terminated.

    I hope some of you can help me

Leave a comment