Python Integration with OpenNI

OpenNI is a software development kit that works with Microsoft Kinect and Primesense.  It supports body and hand gesture recognition and tracking.  Python integration with OpenNI is done through PyOpenNI.

Download PyOpenNI

$ git clone https://github.com/jmendeth/PyOpenNI.git

Download NiTE

$ cd ~/Download
$ wget https://simple-openni.googlecode.com/files/OpenNI_NITE_Installer-Linux64-0.27.zip
$ cd lib/NITE-Bin-Dev-Linux-x64-v1.5.2.21/
$ chmod a+x install.sh
$ sudo ./install.sh

Build PyOpenNI

$ mkdir build; cd build
$ cmake ..
$ make

Install PyOpenNI

To install it, simply copying to one of the Python library locations, such as below:

$ sudo cp -fR lib/openni.so /usr/local/lib/python2.7/dist-packages

Make sure PYTHONPATH contains the above location.

Run PyOpenNI

$ python
Python 2.7.6 (default, Jun 22 2015, 17:58:13) 
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import openni
>>> 

If you run into any issue indicating missing openni-dev, it is likely cased by this bug. Simply edit pcl_io-1.7.pc and replace openni-dev with libopenni, like below:

Requires:  eigen3 libopenni pcl_common-1.7 pcl_octree-1.7

Demos

With PyOpenNI working, we can run some cool demos.  Cecila Cinta gave a talk and provided a set of demos.  However, the demo python files are in ipython notebook format.  To convert, first download ipython, and nbconvert:

$ sudo pip install ipython
$ sudo pip install "ipython[notbook]"

Then convert them like this:

$ ipython nbconvert --to python "Hand and Gesture Tracking.ipynb"

Run the hand and gesture tracking demo you will get the video below:

Run the body tracking demo you will get this:

References