Code Yarns ‍👨‍💻
Tech BlogPersonal Blog

How to get started with Kinect for Windows on Ubuntu using OpenNI

📅 2013-Jul-23 ⬩ ✍️ Ashwin Nanjappa ⬩ 📚 Archive

The Kinect can be connected to a computer and used for a lot of fun projects. OpenNI is a popular library that is used by many applications and libraries to use the Kinect. You can also use the OpenNI API in your programs to access the output of the Kinect. This post describes the steps I used to get OpenNI working with the Kinect for Windows sensor on Ubuntu:

Preliminary checks

  1. This post is about the Kinect for Windows sensor. It is not about the Kinect for Xbox 360 sensor. If you don't know which type of Kinect you are using, read about the difference between the two types of Kinect.

  2. Plug the power plug of the Kinect to a power source. Plug the USB plug of the Kinect into your computer running Ubuntu. You should see the light on the Kinect blink slowly in green color.

  3. Ensure that the Kinect has been identified by the Linux kernel. You can check this by listing all the USB devices as described in this post. Check if the 3 devices described in that post are listed with the correct product and vendor IDs.

Install unstable branch of OpenNI 1.x

By default, OpenNI does not ship with the drivers for Kinect. Also, OpenNI 2.x does not seem to work with Kinect for Windows. To use the Kinect for Windows sensor on Ubuntu, it seems that the unstable version of OpenNI 1.x should be used.

Get the unstable branch of OpenNI 1.x code:

$ git clone https://github.com/OpenNI/OpenNI.git
$ cd OpenNI/
$ git checkout -b unstable origin/unstable

Compile the OpenNI code:

$ cd Platform/Linux/CreateRedist/
$ ./RedistMaker

Install the OpenNI headers, libraries and binaries on the system:

$ cd ../Redist/
$ cd OpenNI-Bin-Dev-Linux-x64-v1.5.4.0/
$ sudo ./install.sh

You now have OpenNI installed. However, it cannot yet communicate with your Kinect for Windows sensor. To get that working, we need to install the Kinect drivers.

Install SensorKinect drivers

These are drivers that have been modified to work with OpenNI 1.x (not OpenNI 2.x) on Linux. We need to compile and install this to use the Kinect. Compilation of these drivers needs OpenNI to be installed, which is why we did that step first.

Get the code of SensorKinect:

$ git clone https://github.com/avin2/SensorKinect.git
$ cd SensorKinect/

Compile the SensorKinect driver code:

$ cd Platform/Linux/CreateRedist/
$ ./RedistMaker

Install the SensorKinect drivers:

$ cd ../Redist/
$ cd Sensor-Bin-Linux-x64-v5.1.2.1/
$ sudo ./install.sh

You now have the drivers installed on your system.

Start playing with Kinect

It is time to check out if your Kinect for Windows sensor works on Ubuntu. The OpenNI directory has some tools that can be used to start playing with your Kinect. Go to OpenNI/Platform/Linux/Bin/x64-Release and try them out. For example, the NiViewer tool displays both the RGB and depth output from your Kinect.

Tried with: Kinect for Windows, SensorKinect 5.1.0.25, OpenNI unstable 1.5.4.0, Linux 3.2.0-48-generic and Ubuntu 12.04 LTS