Kinect on Ubuntu with OpenNI

UPDATE October 2015: Verified working in Ubuntu 14.04 LTS and 15.04!

I’ve spent all this morning trying to talk to the Microsoft Kinect using OpenNI. As it turns out, the process is not exceptionally difficult, it’s just there doesn’t seem to be any up to date documentation on getting it all working. So, this post should fill the void. I describe how to get access to the Kinect working using Ubuntu 12.04 LTS, OpenNI 1.5.4, and NITE 1.5.2.

Please note that since writing this tutorial, we now have OpenNI and NITE 2.0, and PrimeSense have been bought by Apple. This tutorial does not work with versions 2 (though 1.5 works just fine), and there is talk of Apple stopping public access to NITE.

To talk to the Kinect, there are two basic parts: OpenNI itself, and a Sensor module that is actually responsible for communicating with the hardware. Then, if you need it, there is NITE, which is another module for OpenNI that does skeletal tracking, gestures, and stuff. Depending on how you plan on using the data from the Kinect, you may not need NITE at all.

Step 1: Prerequisites

We need to install a bunch of packages for all this to work. Thankfully, the readme file included with OpenNI lists all these. However, to make life easier, this is (as of writing) what you need to install, in addition to all the development packages you (hopefully) already have.

There are also some optional packages that you can install, depending on whether you want documentation, Mono bindings, etc. Note that on earlier versions the install failed if you didn’t have doxygen installed, even though it is listed as optional.

Step 2: OpenNI 1.5.4

OpenNI is a framework for working with what they are calling natural interaction devices.Anyway, this is how it is installed:

Check out from Git

OpenNI is hosted on Github, so checking it out is simple:

The first thing we will do is checkout the Unstable 1.5.4 tag. If you don’t do this, then the SensorKinect library won’t compile in Step 3. From there, change into the Platform/Linux-x86/CreateRedist directory, and run the RedistMaker script. Note that even though the directory is named x86, this same directory builds 64 bit versions just fine. So, don’t fret if you’re on 64bit Linux.

The RedistMaker script will compile everything for you. You then need to change into the Redist directory and run the install script to install the software on your system.

Step 3: Kinect Sensor Module

OpenNI doesn’t actually provide anything for talking to the hardware, it is more just a framework for working with different sensors and devices. You need to install a Sensor module for actually doing the hardware interfacing. Think of an OpenNI sensor module as a device driver for the hardware. You’ll also note on the OpenNI website that they have a Sensor module that you can download. Don’t do this though, because that sensor module doesn’t talk to the Kinect. I love how well documented all this is, don’t you?

The sensor module you want is also on GitHub, but from a different user. So, we can check out the code. We also need to get the kinect branch, not master.

The install process for the sensor is pretty much the same as for OpenNI itself:

On Ubuntu, regular users are only given read permission to unknown USB devices. The install script puts in some udev rules to fix this, but if you find that none of the samples work unless you run them as root, try unplugging and plugging the Kinect back in again, to make the new rules apply.

Step 4: Test the OpenNI Samples

At this point, you have enough installed to get data from the Kinect. The easiest way to verify this is to run one of the OpenNI samples.

You should see a yellow-black depth image. At this point, you’re left with (optionally) installing the higher level NITE module.

Step 5: Install NITE 1.5 (optional)

Firstly, you need to obtain NITE 1.5.2. Go to the following link and download NITE 1.5.2 for your platform..

http://www.openni.org/openni-sdk/openni-sdk-history-2/

Extract the archive, and run the installer:

At some point, you may be asked for a license key. A working license key can be found just about anywhere on the Internet. I don’t think PrimeSense care, or maybe this is a non-commercial license or something. But whatever, just copy that license into the console, including the equals sign at the end, and NITE will install just fine.

Conclusion

After following these steps, you will be able to write programs that use the Microsoft Kinect through OpenNI and NITE middleware. I hope this helps someone, because I spent a lot of time screwing around this morning trying to get it all to work. Like I said, the process is pretty straight forward, it just hasn’t been written down in one place (or I suck at google).

Published by

Michael Marner

My name is Michael, and this is my website. I am currently working as a Research Fellow at the University of South Australia's Wearable Computer Lab. I am also the chair of the board and an announcer at Adelaide based community radio station Three D Radio 93.7FM.

68 thoughts on “Kinect on Ubuntu with OpenNI”

  1. Hello,

    This page has been helpful to many, and I want to make good use of it as well. I am using Kinect xbox 360 model 1414, for my research on human robot interaction. I am a new kinect user. I am using ubuntu 14.04 LTS (64bit) and Ros indigo. I could not proceed with the step where i need to move to Platform/Linux(x86), as it says no such directory. It might a noob question, but can you please help me to get started with the kinect. Its been sometime I am struggling on it, browsing through various possible drivers.

    Thanks

  2. I am using Kinect 1414 xbox 360 model, with ubuntu 14.04 lts and ros indigo. I need to use this for my research of human robot interaction. I am new to kinect. I am unable to get started with kinect. I went through your steps. I am stuck at step 2, I can’t find this path Platform/Linux/CreateRedist

  3. Hi, i’m using ROS indigo, someone said that indigo doesn’t support openNI and reference me to libfreenect. But freenect doesn’t hv skeleton tracking algorithm. What do you think ? Is openNI really can’t match with indigo?

  4. when i run
    ./Sample-NiSimpleViewer

    then the result is :

    Device: PrimeSense/SensorV2/5.1.0.41: The device is not connected!

    hemmm… i don’t know what to do………

  5. a thousand thanks for the post!
    there is an error in the text: doxygen graphviz mono-complete are not optional: the documentation ends the redist process before it has actually created the files -> you should put theses packages in first apt-get line.

  6. Thanks a lot!! this is the only tutorial that works!
    However, I’m not able to connect with RVIZ, or even run this common command:
    rosrun image_view disparity_view image:=/camera/depth/disparity
    could you give me a hand please?

  7. hello ,i got asus xtion pro live,but when i have done it as you follow, there was a problem, like USB interferce not support. so , could you help me handle it?

  8. Thanks so much for your instructions. Worked like a charm for me. Looks like I’m the first to post the bad news, every which way I tried to find a NITE package to download I ended up at an Apple page. Entering PrimeSence, NITE etc. doesn’t produce any results. How important was/is the functionality in NITE. I’m new, slogging my way through getting my TurtleBot up and running. I’m within a few days of connecting a laptop to the TurtleBot as ROS Master. I’m curious, how bad is the loss of NITE? Or am I just looking in the wrong place? Thanks again for your instructions. Really excellent, doubt I could have done it alone. I was so psyched when I saw my fuzzy yellow head and hands moving in my laptop screen, no words can describe it, perhaps giddy. Yep, giddy.

  9. I manage to install everything but my samples said that the kinect is on safe mode so i cant access to it.

  10. I am using Ubuntu 14.04. When I tried to run the code in Step 4, this error appeared:

    bash: cd: OpenNI/Platform/Linux-x86/Bin/Release: No such file or directory

    How should I solve this? Do I really need to connect a turtlebot with kinect to run the code in Step 4?

Leave a Reply

Your email address will not be published. Required fields are marked *