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
wget http://dl.google.com/android/ndk/android-ndk-r8e-darwin-x86_64.tar.bz2
tar -jxvf android-ndk-r8e-darwin-x86_64.tar.bz2
# Download OpenNI 2.2 from git
cd $HOME/work
git clone https://github.com/OpenNI/OpenNI2.git
cd OpenNI2
# change PS1080.ini file path
vi ./Source/Drivers/PS1080/Sensor/XnSensor.cpp
#define XN_GLOBAL_CONFIG_FILE_NAME “PS1080.ini”
to
#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”;
to
static const char* ONI_CONFIGURATION_FILE = “/system/lib/OpenNI.ini”;
static const char* ONI_DEFAULT_DRIVERS_REPOSITORY = “OpenNI2” XN_FILE_DIR_SEP “Drivers”;
to
static const char* ONI_DEFAULT_DRIVERS_REPOSITORY = “/system/lib/”;
# build OpenNI 2.2
cd Packaging
python ReleaseVersion.py android
cd Final
tar -xvf OpenNI-android-2.2.tar
cd OpenNI-android-2.2
ls
EventBasedRead OpenNI.ini SimpleRead libOpenNI2.so libPSLink.so
MultipleStreamRead PS1080.ini libOniFile.so libPS1080.so libusb.so
# copy shard library and ini file to Android
adb push OpenNI.ini /system/lib/
adb push PS1080.ini /system/lib/
adb push libOpenNI2.so /system/lib/
adb push libPS1080.so /system/lib/
adb push libusb.so /system/lib/
adb push libOniFile.so /system/lib/
adb push libPSLink.so /system/lib/
adb push SimpleRead /system/lib/
# check OpenNI running.
adb shell
cd /system/lib/
SimpleRead
./SimpleRead
[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
wget http://dl.google.com/android/ndk/android-ndk-r9d-darwin-x86_64.tar.bz2
tar -jxvf android-ndk-r8d-darwin-x86_64.tar.bz2
# set paths.make. following is my example.
vi libs/openFrameworksCompiled/project/android/paths.make
SDK_ROOT=$HOME/work/android-sdk-macosx
NDK_ROOT=$HOME/work/android-sdk-macosx/android-ndk-r9d
# set OpenNI include files, shard library file oF make file.
“libs/openFrameworksCompiled/project/android/config.android.default.mk” changes diff is following.
36c36
< ABIS_TO_COMPILE_RELEASE = armv5 armv7 neon — > ABIS_TO_COMPILE_RELEASE = armv5 armv7 neon x86
193c193
< 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)”
311d310
< PLATFORM_HEADER_SEARCH_PATHS += “$HOME/work/OpenNI2/Include”
343,345d341
< PLATFORM_LIBRARIES += OpenNI2
< PLATFORM_LIBRARIES += OniFile
< PLATFORM_LIBRARIES += PS1080
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.