From Wiki for iCub and Friends
Revision as of 17:54, 15 November 2013 by Gsaponaro (talk | contribs) (OpenNI2 YARP driver)
Jump to: navigation, search

The OpenNI2 device driver for YARP works with PrimeSense compatible RGB-D sensors, including Asus Xtion Pro. Tested on Debian Jessie (testing), Ubuntu 12.04+ and Mac OS X 10.8.4+.

Debian Wheezy (stable) is not supported by OpenNI2, due to glibc version being < 2.14.

Note: Microsoft Kinect sensors are not supported by this driver. However, they are supported by the old Kinect YARP driver, which was based on OpenNI version 1.



For Debian and Ubuntu, install the following dependencies:

sudo apt-get install g++ python libusb-1.0-0-dev libudev-dev freeglut3-dev doxygen graphviz

Also, you must have installed a Java SDK.

Next, install OpenNI2 and NiTE2 according to the latest official instructions at

Environment variables

Source the environment files (obtained from the previous step) by copying their content permanently into your .bashrc. From your OpenNI2 directory:

cat OpenNIDevEnvironment >> ~/.bashrc

And from your NiTE2 directory:

cat NiTEDevEnvironment >> ~/.bashrc

Source the variables to make the change effective (or logout and login again):

source ~/.bashrc

At the end of this process, you should have four new environment variables defined in your system:


OpenNI2 YARP driver

In the CMake configuration for YARP, set the following:

ENABLE_yarpmod_OpenNI2DeviceServer ON
ENABLE_yarpmod_OpenNI2DeviceClient ON

If your environment variables were defined correctly in the previous step, the following settings will be automatically taken care of by CMake:

NITE2_INCLUDE_LOCAL: full path to NiTE-2.x.x/Include directory
NITE2_LIBRARY: full path to
OPENNI2_INCLUDE_LOCAL: full path to OpenNI-2.1.0-x64/Include directory
OPENNI2_LIBRARY: full path to

Finalize the installation

Important note: presently, the OpenNI2 YARP driver must always be called from a directory that contains a copy (or symbolic link) of the official OpenNI2 and NiTE2 directories. To prepare such a setup, do something along these lines:

mkdir ~/yarp_openni2_root
cd ~/yarp_openni2_root
cp -R $NITE2_REDIST64/OpenNI2 .
// or if you have the 32-bit version:
// cp -R $NITE2_REDIST/OpenNI2 .

and always call the yarpdev command from the yarp_openni2_root directory. This is necessary to not incur in runtime errors like Couldn't create user tracker.


To print a list of available options (help):

yarpdev --device OpenNI2DeviceServer --verbose

In detail:


--playback filename.oni

   Playbacks the specified oni file.


   Forces the playback to loop. If not used, the playback will stop after one run.

--record filename.oni

   records to the specified oni file


   chenge default port prefix (default=/OpenNI2)


   use only user tracker


   disable mirroring


--minConfidence x (double)

   set minimum confidence required. Default is 0.6

Doesn't start the user tracker.


The driver opens three ports: imageFrame:o depthFrame:o userTracker:o

imageFrame and depthFrame stream YARP images, and if connectd to a yarpview, the video is available. UserTracker outputs bottles in the format:

To use the driver in an application: