openFrameworks 8.1 and OpenNI 2.2 on Android tutorial

This tutorial is “How to use oF 8.1 with OpenNI 2.2 on Android”, using Xtion. If want to use Kinect, use OpenNI 1.x and Sensor Kinect driver. And my build envrionment, I use Mac OS 10.8.5, Android 4.2.2 (device is MK 802 IV HDMI dongle type Android, root user needed) on this tutorial. May be other Android devices OpenNI 2.2 works well(OpenNI ran on Nexus7 in my test).

1. Built OpenNI 2.2
# Download Android NDK
cd $HOME
mkdir work
cd work
tar -jxvf android-ndk-r8e-darwin-x86_64.tar.bz2

# Download OpenNI 2.2 from git
cd $HOME/work
git clone
cd OpenNI2
# change PS1080.ini file path
vi ./Source/Drivers/PS1080/Sensor/XnSensor.cpp
#define XN_GLOBAL_CONFIG_FILE_NAME “/system/lib/PS1080.ini”

# change OpenNI.ini file path
vi ./Source/Core/OniContext.cpp
static const char* ONI_CONFIGURATION_FILE = “OpenNI.ini”;
static const char* ONI_CONFIGURATION_FILE = “/system/lib/OpenNI.ini”;

static const char* ONI_DEFAULT_DRIVERS_REPOSITORY = “OpenNI2” XN_FILE_DIR_SEP “Drivers”;
static const char* ONI_DEFAULT_DRIVERS_REPOSITORY = “/system/lib/”;

# build OpenNI 2.2
cd Packaging
python android
cd Final
tar -xvf OpenNI-android-2.2.tar
cd OpenNI-android-2.2
EventBasedRead OpenNI.ini SimpleRead
MultipleStreamRead PS1080.ini

# copy shard library and ini file to Android
adb push OpenNI.ini /system/lib/
adb push PS1080.ini /system/lib/
adb push /system/lib/
adb push /system/lib/
adb push /system/lib/
adb push /system/lib/
adb push /system/lib/
adb push SimpleRead /system/lib/

# check OpenNI running.
adb shell
cd /system/lib/
[00000000] 585
[00033369] 585
[00066738] 584
[00100107] 584
[00133477] 584
[00166846] 584
[00200215] 584
[00233584] 583
[00266954] 583

2. oepnFrameworks 8.1 for Android
Download openFrameworks 8.1 for Android from official site, of course Android SDK, Eclipse, JDK is needed. openFrameworks for Android tutorials is here.

# download Android NDK
cd $HOME/work
tar -jxvf android-ndk-r8d-darwin-x86_64.tar.bz2

# set paths.make. following is my example.
vi libs/openFrameworksCompiled/project/android/paths.make

# set OpenNI include files, shard library file oF make file.
“libs/openFrameworksCompiled/project/android/” changes diff is following.

< ABIS_TO_COMPILE_RELEASE = armv5 armv7 neon — > ABIS_TO_COMPILE_RELEASE = armv5 armv7 neon x86
< PLATFORM_LDFLAGS += –sysroot=$(SYSROOT) -nostdlib -L”$(NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/$(GCC_VERSION)/libs/$(ABI_PATH)” -L$HOME/work/OpenNI2/Packaging/Final/OpenNI-android-2.2 — > PLATFORM_LDFLAGS += –sysroot=$(SYSROOT) -nostdlib -L”$(NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/$(GCC_VERSION)/libs/$(ABI_PATH)”

3. Sample android application
Eclipse project androidOpenNIExample.tar.gz.
APK androidOpenNIExample.apk

MK 802 IV is HDMI dongle type android device(just like a Chromecast by google), easy to use with LED TV. About 60,000 point cloud is drawing in 30fps in this application.

「openFrameworks 8.1 and OpenNI 2.2 on Android tutorial」への24件のフィードバック

  1. When I input “tar -xvf OpenNI-android-2.2.tar” to the terminal on OSX, then the error ”tar: Error opening archive: Failed to open ‘OpenNI-android-2.2.tar’” is coming out.
    What should I do?

    1. Hi, check your “python android” build is successful. If it was fail, “Final/OpenNI-android-2.2.tar” file is not created.

  2. First of all, thanks for the tutorial! I have a problem at checking OpenNI running. When I type “./SimpleReader”, I receive following message:
    “Couldn’t open device
    Could not open “1d27/0601@1/23″: Failed to open the USB device!”
    Do you have any idea?

    1. Hi, try “mount -o devmode=0666 -t usbfs none /proc/bus/usb” command as root and run “./SimpleReader”.

  3. Unfortunately, I have another problem. When I try to run your androidOpenNIExample, I get following error:
    “Fatal signal 11 (SIGSEGV) at 0x00000000 (code=1), thread 8714 (Thread-522)”
    Do you have any idea, what might be the problem? Thanks in advance!

    1. Sorry for my imprecise error description. Finally, after getting more familiar with ofx, I was able to get more information about the error. But still, I am not sure, how to solve it. Here is the output I get after doing openni::initialize():

      LibraryHandler: Couldn’t load library
      DeviceDriver: library handle is invalid for file
      Couldn’t understand file ‘’ as a device driver
      LibraryHandler: Couldn’t load library
      DeviceDriver: library handle is invalid for file
      Couldn’t understand file ‘’ as a device driver
      LibraryHandler: Couldn’t load library
      DeviceDriver: library handle is invalid for file
      Couldn’t understand file ‘’ as a device driver
      Found no valid drivers in ‘./OpenNI2/Drivers’

      Do you have any idea how to solve this? Thanks again!

      1. Hi Ian,

        the problem was that I was using Android 4.3. Downgrading the Android version to 4.2.2 was the solution to my problem!

        Hope this helps!


        1. Hi,

          so I have the same problem as you describe. Did you downgrade the android version one your device to 4.2.2 or just changed the build target of the project?
          I get the error on my Nexus 10 with Android 4.4.4 and on a Galaxy Nexus with Android 4.2.2.

          Maybe you can give me an answer to two additional questions. How did you debug the project to get the output from above? And did you give special admin rights to the app, though I am not sure if this is even possible?

          It would be really nice if you could help me.


          1. Hi,

            I finally got it to work on my Phone.

            I added following lines of code in the onCreate method of the app.

            Process su = Runtime.getRuntime().exec(“su”);
            DataOutputStream outputStream = new DataOutputStream(su.getOutputStream());

            outputStream.writeBytes(“mount -o devmode=0666 -t usbfs none /proc/bus/usb\n”);


            It still is not working on my tablet with Android 4.4.4 though, I think I have to compile the kernel with usb support to get it to work.

            Thanks for the tutorial though, helped me a lot.

  4. Thanks for the tutorial!
    I use the Xtion Pro live at android 4.2.2.
    I can successfully run ./SimpleRead under adb shell.
    But when i run androidOpenNIExample.apk, i found that it failed at “”. the error is “Could not open “1d27/0601@3/4″: Failed to open the USB device!”
    Is it a problem of access permission? how can i solve it?
    btw: there is no “usb” dir under /proc/bus.
    thanks in advance!

    1. Hi kaijie,
      What’s device do you use now? If you don’t check “/proc/bus/usb” when you connect Xtion to the Android, next command will be fail and you don’t use Xtion on Android (may be needed kernel compile).

      1. Thanks you very much!
        I compiled the kernel with usbfs option(marked as DEPRECATED), and now the androidOpenNIExample works OK!
        I use Arndale Octa Board(Exynos 5420).

  5. Hi,
    Thank you very much for this tutorial.
    Do you use to connect Xtion ssensor any USB hub with external power supply?
    I tryed to connect it to Nexus 7 (2013) with Android 4.4.4 directly, but in that case OTG port does not supply enough current to power up sensor. So I used external usb hub to power it up.
    Is there any way to supply up to 500mA from Nexus 7 without external power supply?
    Maybe there is some list with supported USB devices for Android kernel?
    I noticed that on reboot Nexus shortly power up Xtion sensor when it connected directly, but then supply only limited current to it.

    1. Hi,
      I don’t use external power supply. I use Nexus 7(2012) with Android 4.4.4(rooted). Probably, do you use USB Host Adapter Cable(not a usb A-micro connector)? OTG USB Host Adapter Cable is needed in Xtion and Nexus7.

  6. Hi,

    I have two questions and of them is not specificaly about your example. I use Ubuntu 14.10 with newest SDK and NDK r9d. I use openFrameworks 8.1 like you do. My tablet is a Nexus 10 with Android 4.4.4.

    So I followed your tutorial and the SimpleRead works on my tablet. I am also able to run openFrameworks examples and your example shows no errors when compiling. When I try to run your example the app crashes. When debugging the code, it crashes in the method OFAndroid.setup(w,h); and the error says Fatal signal 11 (SIGSEGV) So the first question is, do you know why?

    Next I tried to debug the native code. And their is my second problem. Whenever I try to set a breakpoint I get: “no symbol table is loaded. use the file command.” I work with eclipse kepler and it seems my gdb is not working correctly. Do you use eclipse too and maybe have a tipp for me?


    1. Hi,

      I still have the same problem, but my description is not correct. I think my error is the same, as the one Vic discribes.


  7. Hi All,

    If anyone can help, please give me some instructions:

    I use DS325, plug to my Snapdragon 800 running Android 4.4.2. All builds seem success. But the DS325Sample cannot run. Error messages are:


    1. On Android LCD: Unfortunately, DS325Sample has stopped. The LCD show the first frame, then exit abnormally.

    2. On Snapdragon console, 2 kinds of error messaages:
    a. Always shows when plug the DS325 to USB port of Snapdragon
    [ 519.800001] msm_pcm_playback_close: CMD_EOS failed, cmd_pending 0x8
    [ 519.818824] afe_callback: cmd = 0x100e6 returned error = 0x1

    b. Only shows when Sample app is run
    10|shell@msm8974:/ # [ 244.013995] type=1400 audit(1423023366.155:12): avc: denied { getattr } for pid=3438 comm=”op.openni.ds325″ path=”/data/apr
    [ 244.068678] type=1400 audit(1423023366.205:13): avc: denied { read } for pid=3438 comm=”op.openni.ds325″ name=”usb” dev=”tmpfs” ino=2824 sconter
    [ 244.086767] type=1400 audit(1423023366.235:14): avc: denied { open } for pid=3438

    3. On ADT
    org.siprop.openni.ds325 libc Fatal signal 11 (SIGSEGV) at 0x5ee0e001 (code=2), thread 3453 (o.. penni.ds325)

    So any people know about this, please share your instructions.

    Best regards,


  8. Hello everyone,
    I would like to know if it was possible to connect the Xtion Pro Live to a tablet using a USB -micro USB adapter ? and whether there is an software for use on the tablet.

      1. Thank you for your reply,
        I was unsuccessful while trying to build OpenNI ( on Windows using Cygwin.
        But it worked on Mac OS. I have successfully obtained shared libraries and ini files!

        Right now I am stuck in trying to get Point Cloud in Android application (x_x)
        If possible, can you make tutorial of Android Depth Map OpenNI Example Application?
        Thank youuuu~



このサイトはスパムを低減するために Akismet を使っています。コメントデータの処理方法の詳細はこちらをご覧ください