Notice: MediaWiki has been updated. Report any rough edges to

Getting Started

From OpenKinect
Revision as of 07:59, 3 March 2011 by BankP (talk | contribs) (Getting the source files: @ Master vs unstable: removed link to Win32 post from January and replaced with reference to high resolution implementation of Feb 15.)
Jump to: navigation, search
Language: English  • français • italiano • português do Brasil

Please read this before you start

This page documents how to get started using OpenKinect. The libraries are very much in flux and this won't be the final process. This also means these instructions might be out of date with the latest commits. You may also want to take a look at the following for more information:

  • the github project top README (don't forget other readme files in the project tree for specific components)
  • the Wrappers section
  • the OpenKinect mailing list
  • the FAQ


For support requests in the OpenKinect irc channel or in the mailing list, please specify the platform you are using, the version of the software you are trying to build or install, and information about the context etc. as explained here.

The adapter

The Kinect needs its own power source which is independent from the USB connection to work on a computer. The latest Xbox360 can power the Kinect directly but the older Xbox requires an adapter for that purpose. Therefore, the Kinect which is bundled with the Xbox360 doesn't include an adapter whereas the Kinect which is sold separately does. The adapter is sold here. This adapter is required to use the Kinect hardware on your computer with libfreenect.


It is also possible to use the Fakenect utility which is a libfreenect simulator/mock interface to run the Kinect demos without having a Kinect.

Thank you!


Binary Packages

Already compiled rpm and deb packages are available here:

Please note, that there are not udev generated devices for now, so you need to execute your programs as root (use sudo).

These packages were last updated on Nov,19,2010


An Ubuntu launchpad ppa for Lucid(10.04) and Maverick (10.10) is available at:

to use it, open a console and execute:

$ sudo add-apt-repository ppa:arne-alamut/freenect

Resynchronize the list of packages from the repository:

$ sudo apt-get update

After that, you can use:

$ sudo apt-get install freenect

This will install libfreenect0.0, libfreenect-demos and libfreenect-dev.

After that, you need to add yourself to the 'video' group and log back in. The package already includes the necessary rules for the udev daemon so that accessing the device will be possible for users in the group video.

$ sudo adduser YOURNAME video

be sure to log out and back in. You don't need to reboot, just plug in the kinect device right now (if it was already connected, unplug and plug back in).

To start the demo applications use:

$ freenect-glview

You find all demo applications starting with the freenect- prefix.

Ubuntu Manual Install

Quick copy-paste instructions to get up-and-running instantly:

sudo apt-get install git-core cmake libglut3-dev pkg-config build-essential libxmu-dev libxi-dev libusb-1.0-0-dev
git clone
cd libfreenect
mkdir build
cd build
cmake ..
sudo make install
sudo ldconfig /usr/local/lib64/
sudo glview

This should be one of the faster ways to get the Kinect going on Ubuntu at least. Recommended of course is this step:

sudo adduser YOURNAME video
cat << EOF >> /etc/udev/rules.d/51-kinect.rules
# ATTR{product}=="Xbox NUI Motor"
SUBSYSTEM=="usb", ATTR{idVendor}=="045e", ATTR{idProduct}=="02b0", MODE="0666"
# ATTR{product}=="Xbox NUI Audio"
SUBSYSTEM=="usb", ATTR{idVendor}=="045e", ATTR{idProduct}=="02ad", MODE="0666"
# ATTR{product}=="Xbox NUI Camera"
SUBSYSTEM=="usb", ATTR{idVendor}=="045e", ATTR{idProduct}=="02ae", MODE="0666"

Manual build under linux

these instruction need more work, mostly taken from README.asciidoc

Install dependencies

For compiling, you need to have the following libs/programs installed:

* cmake
* libusb-1.0-0
* libusb-1.0-0-dev
* pkg-config
* libglut3
* libglut3-dev

Note that the above package names seem to be geared toward Ubuntu/Debian. For a non-developer install of RedHat/Fedora using yum/rpms, the following command should install all packages needed to retrieve, compile, & run the glview demo:

$ yum install git cmake gcc gcc-c++ libusb1 libusb1-devel libXi libXi-devel libXmu libXmu-devel freeglut freeglut-devel

APT users: (Works on Ubuntu 10.10)

$ sudo apt-get install cmake libglut3-dev pkg-config build-essential libxmu-dev libxi-dev libusb-1.0-0-dev

clone the repo

$ git clone
$ cd libfreenect


$ mkdir build
$ cd build
$ cmake ..
$ make
$ sudo make install
$ sudo ldconfig /usr/local/lib64/


If you run into into the following cmake error:

$ CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
$ Please set them or make sure they are set and tested correctly in the CMake files:
$    linked by target "glview" in directory /home/user/libfreenect/examples
$    linked by target "glview" in directory /home/user/libfreenect/examples

Then you need to install libxi-dev and libxmu-dev/libxmu-headers If you are using ubuntu 10.04, type the command: sudo apt-get install libusb-1.0-0-dev libxmu-dev libxi-dev

In case glview gives a shared library error:

$ glview 
glview: error while loading shared libraries: cannot open shared object file: No such file or directory

You need to refresh your ldconfig cache:

$ sudo ldconfig /usr/local/lib64/

this depends of course where you have installed your shared libraries.


To compile the Python wrappers you'll need the package "python-dev" and cython. The cython package included in Ubuntu 10.10 seems to be broken (see this), get it here or try

 $ easy_install cython

For more information about the Python wrappers see this page.

Use as normal user

To be able to access the Kinect you need to add yourself to the video group and change the permission on the created device.

create a file: /etc/udev/rules.d/66-kinect.rules

#Rules for Kinect ####################################################
SYSFS{idVendor}=="045e", SYSFS{idProduct}=="02ae", MODE="0660",GROUP="video"
SYSFS{idVendor}=="045e", SYSFS{idProduct}=="02ad", MODE="0660",GROUP="video"
SYSFS{idVendor}=="045e", SYSFS{idProduct}=="02b0", MODE="0660",GROUP="video"
### END #############################################################

and add yourself to the video group:

$ sudo adduser YOURNAME video

Testing the Kinect

You need to do this as root (or use sudo) if you did not follow the "Use as normal user" steps.

$ bin/glview


$ sudo bin/glview


It is best to install (at least the prerequisites) via a package manager. If you're not already using macports or fink, try Homebrew as we actually have a full package created for this.


Current versions of MacPorts need to support several different versions of libusb. We have added a special libusb-devel port that builds the patched libusb library required by the Kinect.

After installing MacPorts, issue the commands:

 sudo port install git-core
 sudo port install libtool
 sudo port install libusb-devel

Then change to a working directory, and you're ready to:

git clone

and continue as per the Manual Build under OSX section. The libusb found by cmake will be correct and already-patched, greatly simplifying the build process!


If you dont have Homebrew already, it is quite simple to install.

Note: Even if you already have homebrew, make sure to update your formulas (run `brew update`), before trying to install libfreenect as there has been a lot of bugfixing to cmake lately.

Get the formulas

Since the project is still so much in flux the packages are not yet in the official homebrew directory, so you will need to manually fetch them:

cd /usr/local/Library/Formula
curl --insecure -O ""
curl --insecure -O ""


brew install libfreenect

And thats it, you are done! A copy of glview demo should now be in your PATH so you can simply run:


to confirm everything worked out ok.

Manual Build under OSX


Next create fetch the OpenKinect repository and libusb:

git clone
git clone git://

You don't need to fetch and patch libusb if you already installed libusb-devel via MacPorts (see above)! If you cloned libusb via github you will need to patch it for OpenKinect like so:

cd libusb
patch -p1 < ../libfreenect/platform/osx/libusb-osx-kinect.diff
./configure LDFLAGS='-framework IOKit -framework CoreFoundation'
sudo make install

and configure OpenKinect:

cd ../libfreenect/
mkdir build
cd build
ccmake ..

Don't worry if it shows you an 'Empty Cache' at startup. Now press 'c' in ccmake to configure it. If you already installed libusb via MacPorts or Homebrew, it will work fine. Otherwise it will likely fail, because it cannot find libusb. Press 'e' to exit help and manually edit the path to libusb in the following screen to point to /usr/local/include/libusb-1.0/ and continue.

When you're done, build OpenKinect:

cmake ..

If you want to build OpenKinect as an Xcode project, instead do:

cmake -G Xcode ..

And you're done! There now should be a program called 'glview' in libfreenect/build/bin. Connect your Kinect and start it! If you run into 'ld: warning: in /usr/local/lib/libusb-1.0.dylib, missing required architecture x86_64' when using make, you have to correct the paths with cmake: They have to point to /opt ... when libusb was installed via MacPorts.

To have the files globally available on your Mac and to use them with your own projects, you may install them:

sudo make install

Parallel usage with pyusb

If you also want to use pyusb to play with the Kinect, you will need libusb-1.0.8 (it seems). Install it via homebrew and then define the _lib variable before finding the usb device:

from ctypes import *
import usb.core
import usb.utils

_lib = CDLL('/usr/local/Cellar/libusb/1.0.8/lib/libusb-1.0.dylib') # That's the location homebrew puts the libusb libraries
dev = usb.core.find(idVendor=0x045e, idProduct=0x02B0)


If you are looking for a showcase of the project's features before compiling, you could take a look at this precompiled demo (source is available as well) which uses libfreenect and opencv.

Manual build from source


Building from source shouldn't require any specific expertise but may yet be challenging for some. This introduction will serve to give those who need it a bit of background as to what we're trying to do here. To summarize, you will be downloading the latest libfreenect source and separate dependencies. The dependencies will be used twofold. First, you will copy .dll files to your system where they can be accessed. Secondly, you will link .lib and header files to the source code using the cmake-gui program in order to configure the project and generate the makefiles required for compiling. Finally, you will bring the configured project to your integrated development environment (ex. Visual Studio 2010) for compiling proper or to start your own development. So you should understand from this that your system needs some libraries to run the project demos just like any other piece of software usually does (and .dll files are used for this) and that before this can happen the project itself needs links to libraries and headers to build properly. Note that the resulting compiled libfreenect is itself a dll library which your computer will need to access in order to run the glview.exe demo for example. All of this should become quite clear as you go through the steps.

Getting the source files

There are 2 ways to get the latest source:

  1. Go to the OpenKinect project github, select the branch you want (master or unstable for instance - see below) and click the "Download" button (then extract the files to a convenient location) or
  2. Use Git to create and keep an up to date project folder and access any branch locally:

Using Git

  • Download and install Git with these settings:
    • Accept the license etc.
    • Choose the level of shell integration you want
    • Choose "Run git from the Windows Command prompt"
    • Choose "Check out WIndows style, commit Unix-style line endings"
  • Open a Command Prompt, cd to the directory where you want the source folder (/libfreenect) created and type:
$ git clone //downloads the project, creates local master
$ cd libfreenect                                            //cd to source directory
$ git branch --track unstable origin/unstable        //creates a local unstable branch for remote unstable
$ git checkout master                                //check out the master or unstable branch
$ or
$ git checkout unstable
$ git pull                                           //updates the contents of the selected branch
  • The contents of the libfreenect folder will interactively change as you checkout a specific branch (magic!) so you don't need to search for a specific "branch" folder inside the libfreenect directory. Just checkout the branch you want to configure and proceed using the libfreenect folder as source in cmake. This setup allows you to easily switch between the master and unstable branch, update the source files and then configure the branch you want to build.
  • The "git branch" command will show you the different branches (here master and unstable) and which one is currently selected. You can also view the development logs for the branch you're checking out with the "git log" command (use shift-Q to exit the log).

Master vs. unstable branch

If you plan on changing libfreenect, writing wrappers, or trying the latest developments you might want to check out the unstable branch. Unstable has the latest commits that have not been fully tested yet. Otherwise just try the 'master' branch.

  • Take note that the master and unstable branches were synced on Jan. 6, 2011; see this update for more information.
  • On February the 15th, support for multiple resolutions was added to the unstable branch and the 1280x1024 RGB and IR mode was enabled as explained here.

After you have the source files, you should download the dependencies required to configure and build the library and then install the hardware driver...


For each required dependency, first download and install the libraries (.dll) on your system and then identify the paths to the libraries (.lib or .a) and header (.h) files which you will need later on to configure the source project using cmake:

Dependency Install Library/includes to be used with cmake (see this printscreen)
libusb-win32 - download and extract the latest This will be taken care of when we install the driver in the next section The /lib and /include folders contain the libraries and header files required to configure the project; depending on the compiler you choose, you may have to specify a different library file:
  • For instance, to configure for MS Visual Studio 2010, use /lib/msvc/libusb.lib or if you plan to use mingw, use /lib/gcc/libusb.a as the libusb library path in cmake (LIBUSB_1_LIBRARY)
  • Select the path to the libusb header folder /include as libusb include path in cmake (LIBUSB_1_INCLUDE_DIR)

For more info see the libusb-win32 readme and their wiki

pthreads-win32 - download and extract the latest pthreads-w32-x-x-x-release.exe Find the /lib folder and copy the appropriate .dll library to /windows or /windows/system32 (see Library/includes to the right to figure out which one to use) The /lib and /include contain the libraries and header files required to configure the project; depending on the compiler you choose, you may have to specify a different library file:
  • For instance, to configure for MS Visual Studio 2010, use /lib/pthreadVC2.lib or if you plan to use mingw, use /lib/pthreadGC2.a as the pthread library path in cmake (THREADS_PTHREADS_WIN32_LIBRARY)
  • In both cases you will need to install the corresponding library .dll file to /windows/system32 i.e. phtreadVC2.dll or pthreadGC2.dll
  • Select the path to the pthread header folder /include as pthread include path in cmake (THREADS_PTHREADS_INCLUDE_DIR)

For more info see the pthreads-win32 readme and their FAQ

Glut - download and extract the latest Find the glut32.dll file and copy it to /windows/system or any directory included in your PATH system variable (see this explanation)
  • With MSVC, you should copy the glut.h header file to the /include/GL folder and the glut32.lib library to the /lib folder of your VC tree(for instance /Program Files/Microsoft Visual Studio 10.0/VC/) - if the GL folder is not there, create it and put the glut.h file there. If you built glut from source, the files should already be there.
  • In cmake-gui, supply the path to the header up to the /include folder (NOT ../include/GL) and the path to the library itself (../lib/glut32.lib) in cmake (GLUT_INCLUDE_DIR and GLUT_glut_LIBRARY respectively)

For more info see the glut readme

Driver installation

There are two parts to libfreenect -- the low-level libusb-based device driver and libfreenect itself, the library that talks to the driver. You only need to install the driver once.

Windows 7: step-by-step walkthrough (should also work with Windows XP!)

  • Plug in your Kinect. Windows will warn that no device driver was found for the plugged device (the LED of Kinect will not turn on). If Windows presents a dialog asking to search for drivers, simply cancel it.
  • Open the Device Manager: Start >> Control Panel >> System and Security >> System >> Device Manager
  • A device called "Xbox NUI Motor" should be somewhere there (most probably be under "Other devices") with a small yellow warning symbol "!" on top of its icon. Right click on it, and select "Update Driver Software...", then click on "Browse my computer for driver software".
  • "Browse" and select the folder where the "XBox_NUI_Motor.inf" is located (/platform/windows/inf inside your libfreenect source folder). Click "Next" and if warned by Windows that a non-certified driver is about to be installed, just order it to install it anyway.
  • After that, the Kinect LED should start blinking green. Now there will be two additional devices in the Device Manager list: "Xbox NUI Camera" and "Xbox NUI Audio". Repeat the above instructions for them as well.

You are now ready to configure libfreenect before building...

Configuring with cmake-gui

Windows cmakegui.png

Follow these steps to configure libfreenect for compiling:

  1. Download Cmake (Cross-Platform Make) and make sure you have a working C compiler (Visual Studio 2010 or MinGW)
  2. Launch Cmake-GUI and select your /libfreenect folder as source, select an output folder, check the "advanced" and "grouped" checkboxes to display more variables and categorize them and then click on the "Configure" button
  3. Select the C compiler you want to use
  4. Select the BUILD options you want, taking into consideration the following:
    1. For now only select the EXAMPLES and C_SYNC options in BUILD. The other build options such as FAKENECT have not been updated for Visual Studio yet
    2. But take a look at the following notes if you're interested in compiling the PYTHON wrapper
  5. Unresolved dependencies will show up as red in the CMake GUI. Supply the missing paths to the dependencies by following these guidelines, and click the "Configure" button again:
    1. The *_LIBRARY variables need to point to actual .lib files not a folder
    2. INCLUDE variables need to point to the appropriate include directories
  6. When all errors have been resolved, click on the "Generate" button to create the makefiles for your compiler.


Now that the project is configured, open libfreenect.sln from your output folder and build it with Visual Studio. Then look for your compiled files in /bin and /lib

  • The freenect libraries in /lib are compiled but not installed at this point. To use them you should:
    • Add the path to the /lib folder to your system PATH environment variable or
    • Copy the libraries to a folder already in the system PATH like /windows/system32 or
    • Copy libraries to the folder of the program you want to run

If you're having issues compiling check out the readme in the /libfreenect/platform/windows folder for more information.


To do a quick test run /bin/glview.exe

  • It's also a good idea to check the wrappers section and the mailing list for more ideas and solutions...

User contributions