Ubuntu + Kinect + OpenNI + PrimeSense
Getting the OpenNI and PrimeSense drivers working on Ubuntu
Here’s an overview of the process to get the OpenNI and PrimeSense drivers working with the Kinect and Ubuntu. Begin by installing some dependencies:
sudo apt-get install git-core cmake freeglut3-dev pkg-config build-essential libxmu-dev libxi-dev libusb-1.0-0-dev doxygen graphviz mono-complete
Make a directory to store the build, then clone the OpenNI source from Github.
mkdir ~/kinect
cd ~/kinect
git clone https://github.com/OpenNI/OpenNI.git
Run the RedistMaker script in the Platform/Linux folder and install the output binaries
cd OpenNI/Platform/Linux/CreateRedist/
chmod +x RedistMaker
./RedistMaker
cd ../Redist/OpenNI-Bin-Dev-Linux-x64-v1.5.2.23/
sudo ./install.sh
Next, clone the Avin2 SensorKinect source from Github.
cd ~/kinect/
git clone git://github.com/avin2/SensorKinect.git
Run the RedistMaker script in the Platform/Linux folder and install the output binaries.
cd SensorKinect/Platform/Linux/CreateRedist/
chmod +x RedistMaker
./RedistMaker
cd ../Redist/Sensor-Bin-Linux-x64-v5.1.0.25/
chmod +x install.sh
sudo ./install.sh
Then download the OpenNI Compliant Middleware Binaries to ~/kinect
Select these options from the dropdown menus:
Unstable
PrimeSense NITE Unstable Build for Ubuntu 10.10 x64 v 1.5.2.21
Extract the contents of the archive and switch to the Data directory contained within.
cd ~/kinect
tar -xvjpf nite-bin-linux-x64-v1.5.2.21.tar.bz2
cd NITE-Bin-Dev-Linux-x64-v1.5.2.21/Data
Now modify the license in the files: Sample-Scene.xml, Sample-Tracking.xml, and Sample-User.xml. Change
<License vendor=”PrimeSense” key=””/>
to:
<License vendor=”PrimeSense” key=”0KOIk2JeIBYClPWVnMoRKn5cdY4=”/>
Change back to the NITE directory and run the install script.
cd ..
sudo ./install.sh
That’s it! If you followed steps through to here you should be able to run the sample applications. The OpenNI samples are here:
~/kinect/OpenNI/Platform/Linux/Bin/x64-Release
and the PrimeSense samples are here:
~/kinect/NITE-Bin-Dev-Linux-x64-v1.5.2.21/Samples/Bin/x64-Release
Note: if you get the error:
InitFromXml failed: Failed to set USB interface!
the solution is to remove the gspca_linect kernel module:
sudo rmmod gspca_kinect
Ubuntu + OpenKinect + Mouse Control
Mouse control with OpenKinect on Ubuntu Linux
Here is a quick tutorial to get use your hand as a mouse in a Minority Report-esque interface using the Kinect and Ubuntu. Credit to Ooblik (Tim Flaman) for the awesome project. Before you begin, ensure that you have installed the OpenKinect drivers and they are functioning correctly.
Quickstart
sudo apt-get install libncurses5-dev freeglut3-dev libX11-dev libxtst-dev libxmu-dev cmake git
git clone https://github.com/Ooblik/Kinect-Mouse.git
cd Kinect-Mouse
mkdir build
cd build
cmake ..
make
sudo ./kmouse
Steps explained:
Install a few dependencies for the Kinect mouse:
sudo apt-get install libncurses5-dev freeglut3-dev libX11-dev libxtst-dev libxmu-dev cmake git
Use git to clone the source from Ooblik’s repo on Github:
git clone https://github.com/Ooblik/Kinect-Mouse.git
Then make yourself a build directory within the repo, use cmake to configure, and make to build.
cd Kinect-Mouse
mkdir build
cd build
cmake ..
make
Ensure that your Kinect is plugged in (USB and power), and run kmouse. It needs to be run as root unless you have followed the steps here to add your user to the ‘video’ group.
sudo ./kmouse
You will likely need to reposition the Kinect (or yourself) to get it working accurately… The mouse only works at a very specific distance from the Kinect. This is the red area in the video viewer. To click the mouse, remain still over the target and the mouse will left click. Interaction is little more than a proof of concept at present… but it works!
Ubuntu + OpenKinect
Getting started with OpenKinect on Ubuntu Linux
There are two ways you can get OpenKinect (freenect) working on Ubuntu: either by installing the prebuilt PPA package, or compiling from source. I’ve confirmed at both of these methods are functional, the package based method is slightly more straightforward, and allows updates from the apt package manager. This article will demonstrate installation via this method, for details on the manual compilation method, check out the official OpenKinect Getting Started Guide
Quickstart
sudo add-apt-repository ppa:floe/libtisch
sudo apt-get update
sudo apt-get install libfreenect libfreenect-dev libfreenect-demos
sudo freenect-glview
Steps Explained
For those unfamiliar, Ubuntu allows developers to create and distribute their own software packages, called Launchpad Personal Package Archives (PPA). To use one, the package needs to be added to the apt repository list, in this case:
sudo add-apt-repository ppa:floe/libtisch
This adds the repo, but doesn’t update the apt package list. Thus, we must resynch it:
sudo apt-get update
Then, install libfreenect, the development headers, and the demo apps:
sudo apt-get install libfreenect libfreenect-dev libfreenect-demos
You can run it as root:
sudo freenect-glview
To run in user mode, you need to add yourself to the UNIX ‘video’ group and log back in (The package includes udev daemon rules allowing access to the group video).
sudo adduser $USER video
Then log out and back in. Reboot is not necessary, just plug cycle the Kinect (if already connected, unplug and plug back in). Then run the demo app:
freenect-glview
How the Kinect is actually working
Here’s another video, this one taken under infrared of my IP camera. It demonstrates how the infrared projector of the Kinect works.