Kinect support for Raspberry Pi using libfreenect

Developing apps for the Raspberry Pi that utilize the Xbox 360 Kinect is best accomplished with libfreenect. Libfreenect is an open-source library that provides access to the sensors and motors on the Kinect.

Raspbian’s apt repository has version 0.2 of libfreenect, which is quite old and seems to be missing a lot of the features that the latest code has. I’ve documented the steps for building the latest LibFreenect source code and dependencies, below (0.5.3 as of this post).

Libfreenect v0.2 seems to have a fairly incomplete set of sample apps (at least compared to version v0.5.3). I’m not sure if this is an indicator that the library itself is missing many of the features, but the samples in v0.5.3 do a far better job of showcasing the capabilities of the Kinect.

I’m using the Raspberry Pi 2B with Raspbian Jessie, but these steps will likely work with other versions.

Step 1: Update Sources

To get started, open a shell in Raspian and update your sources and installed apps:

Step 2: Install prerequisites for libusb and libfreenect

Now make sure you have the necessary core apps and libraries that we’ll need to build libfreenect and libusb.

Note, do not install libusb from the apt repository, we will need to build the latest version in the next step.

Step 3: Download and build libusb

Next we will build libusb, which is required by libfreenect. You may want to change the download URL to the latest version. As of this post, v1.0.20 was the latest. You can find the libusb releases here.

Step 4: Download and build libfreenect

And finally, let’s download and build libfreenect. I suggest checking for the latest version. Below I have steps for v0.5.3, but you can check for a newer version at the libfreenect Github page.

Done

If everything goes well, you should see several sample apps in /usr/local/bin/ (starting with “freenect-” and “fakenect-“):

2016-01-01_00h40_46

18 thoughts on “Kinect support for Raspberry Pi using libfreenect”

  1. It may be helpful to add that, when trying to run the sample apps but run into error while loading shared libraries: ... cannot open shared object file: No such file or directory, typing sudo ldconfig -v would solve the problem.

    Other than that, thanks a lot for the instructions! The web is full of outdated stuff. This is the most applicable to the current state of affairs. Thank you very much.

  2. Thanks for that.
    I’ve just got a RPi3 and your guide worked on the 2016-02-26-raspbian-jessie image.
    I’m hoping that I can use my Kinect with OpenCV but appears to be a massive learning curve for a noob like me.
    I have another smaller project using SimpleCV which i’ll probably try and get to grips with first.

  3. Hi,
    have you tried running the kinect on the Raspberry Pi 3? I got a R Pi 3 a few weeks back and wanted to see what frame rate it could I could get with Kinect. It works but I’m getting a random number of connection errors each time I restart my capture program. It runs great once connected and I guess I’m getting about double the frame rate over the R pi 2B. But at this point I’m not sure if I have a faulty USB chip or a code bug from the hardware upgrade. I’m using Freenect installed from the raspbian repository, but I’ve also compiled on the rpi 3 along with libusb (as above).

    Thanks for any help here.

  4. Hi,
    firstly thanks for the great info you provide here. I’m pretty desperate confirm if anyone else is getting the same bug mentioned above on the Raspberry Pi 3 or if the code is running the same as on the Raspberry Pi 2B with no bugs. So I can confirm if my hardware is faulty or not.

    Thanks again for any help.

    1. Sorry about that, I hadn’t logged in to approve comments in quite some time. I actually just picked up a Pi 3 myself the other day. I’ll try it out tonight or tomorrow when I get an hour or so to play around with it.

      1. Hi,
        thanks so much for the response. I’ve had a bit of a development; I thought the problem might be related to a timing issue given the random nature of the error(i.e. how many errors before connection). So I decided to try loading the USB bus a bit by adding a 2nd wifi dongle. This fixed the problem for me, the test program starts every time and no more connection errors. I guess then it has to be a timing bug. Thanks again, I can’t wait to hear your results with the R-Pi3.

  5. I followed your instruction here to install Libfreenect on my Pi2 running Jessie, apparently successfully. When attempting glview & glpcview, Ii get: “Open GLX extension not supported by display ‘:0’0′”‘. On ccpview, a runtime error.

    Is this likely because I’m using a VGA monitor through an adapter?

    1. I am getting a similar error :” freeglut (./freenect-glview): OpenGL GLX extension not supported by display ‘:1.0’ ”
      Did you happen to solve this yet? Thanks

  6. Hi, this is a great and simple tutorial.

    but i’m trying to install but the last make (libfreenect) doesn’t work.
    i have done make command in the build folder…. => no target and no makefile found.
    i’m going to find solutions but if someone help will be apreciate.

    Thanks

    1. i found this error when execute cmake:
      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 “freenect-chunkview” in directory /home/pi/src/libfreenect-0.5.3/examples
      ….. and a lot of other.

  7. i ve solved the probleme by doing commands:
    sudo apt-get install xorg-dev build-essential libglu1-mesa-dev libc6-dev
    sudo apt-get install g++ libboost-dev cmake make git doxygen

    Hope this help other

  8. I had some issues with “connecting” to the subsystems. This can be solved by:

    Error message:
    Number of devices found: 1
    Could not open device: -3
    […] something with subsystem.

    This is in most cases some right problem that can be solved with

    sudo chmod 777 /dev/bus/usb/001/*

    until the next reboot. Useful to test if any other stuff is interfering.

    To have a permantent fix execute

    sudo nano /etc/udev/rules.d/99-kinect.rules

    this creates and opens a rule file with priority 99, meaning its the last one applied on the Kinect sensor. The 99 can be replaced with any two digit number.

    After that add the followingf conetent to the file:

    # 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″
    # ATTR{product}==”Xbox NUI Motor”
    SUBSYSTEM==”usb”, ATTR{idVendor}==”045e”, ATTR{idProduct}==”02b0″, MODE=”0666″

    and then execute
    sudo /etc/init.d/udev restart
    or
    sudo shutdown -r now

    Afterwards you should be able to use the examples.

    Product and vendor id can be found with lsusb
    Bus {XXX} Device {XXX}: ID {idVendor}:{idProduct}

  9. Hi thanks for your site , i have a problem with use freenect-glview command.
    error ::::: Internal error in function fgOpenWindow

  10. Hi, We are new to Raspberry PI and we have a requirement to connect Kinect to Raspberry Pi 2 to record audio in .wav file. We have followed all the steps you have mention above and we have reached the stage where we can see all the sample app as show in the last step above. We need the assistance on how to run the sample app.

  11. Hi, thanks for the tutorial!
    I am getting a problem every time I try to run freeglview… the error message is :
    Kinect camera test
    Number of devices found: 1
    GL thread
    freeglut (freenect-glview): failed to open display ”
    Can you help me please?

Leave a Reply