Compile OpenKinect on Ubuntu 10.10 Maverick | Kinect / libfreenect

UPDATED: 12-6-2010

Since the Kinect has been "free'd" you can find a driver in the github repository - currently the driver is under heavy construction {1}. There's also a Wiki {2}, a high frequency mailing list at google.groups {3} and a couple of weblogs dealing with the Kinect e.g., gilotopia.
The drive of all these guys (and prop. girls) is awesome (Thank you all)!

I like to add my two cents (for now)...How to compile libfreenect on Ubuntu 10.10:

At first, install some dependencies - these should be fine - If I'm missing something please let me know/comment. (Thank you anonymous ^^)

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

Create a folder where you want to clone the repos and build the driver. NOTE: You don't need any root privileges, you can totally do this in your $home directory.

cd ~/
mkdir Kinect
cd Kinect
mkdir repos
cd repos

Now clone the git repository

git clone https://github.com/OpenKinect/libfreenect.git .

You should read something like that:

Initialized empty Git repository in /home/fl0/kinect/repos/.git/
remote: Counting objects: 451, done.
remote: Compressing objects: 100% (361/361), done.
remote: Total 451 (delta 237), reused 165 (delta 74)
Receiving objects: 100% (451/451), 434.71 KiB | 330 KiB/s, done.
Resolving deltas: 100% (237/237), done.

Now we're going to create a build folder - side note: Just because we're going to use cmake it's always a good idea to accumulate the cmake files in a "build folder". If something goes wrong e.g., some dependencies are not found, you can always "rm -rf ./*" in the build folder, install the missing deps and repeat the process (see below). This way you won't be confused by cached cmake files. Okay let's move on.

mkdir build
cd build
cmake ..

If everything's fine (watch out for "not found" errors) go on - if not install the missing dependencies. For beginners it's always a good idea to google the "not found" message. Almost certainly google will find you the right package... Now: "make"

make

You should see sth. like the following:

fl0@fl0-m0thership:~/kinect/repos/c/build$ make
[ 16%] Generating inits.c
Scanning dependencies of target freenect
[ 33%] Building C object lib/CMakeFiles/freenect.dir/core.c.o
[ 50%] Building C object lib/CMakeFiles/freenect.dir/cameras.c.o
[ 66%] Building C object lib/CMakeFiles/freenect.dir/usb_libusb10.c.o
/home/fl0/kinect/repos/c/lib/usb_libusb10.c: In function ‘fnusb_shutdown’:
/home/fl0/kinect/repos/c/lib/usb_libusb10.c:54: warning: unused variable ‘res’
[ 83%] Building C object lib/CMakeFiles/freenect.dir/inits.c.o
Linking C static library libfreenect.a
[ 83%] Built target freenect
Scanning dependencies of target glview
[100%] Building C object examples/CMakeFiles/glview.dir/glview.c.o
Linking C executable glview
[100%] Built target glview

sudo make install

Now you need to addyourself to the 'video' group, log-out and back in.

sudo adduser YOURNAME video

You need to add following udev rules to allow non sudo users to access the kinect.

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

Add the following to this file, save and reboot.

# 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"

Now you're done. Chdir to examples and exec the glview application

Hope this helps.

References:
{0} http://openkinect.org/wiki/Getting_Started
{1} https://github.com/OpenKinect/libfreenect
{2} https://github.com/OpenKinect/libfreenect/wiki
{3} http://groups.google.com/group/openkinect/

Comments

Dependencies

I also needed to install pkg-config, otherwise cmake wasn't able to find the usb-header files from the libusb-1.0-0-dev package (error message: "USB_INCLUDE_DIR=USB_INCLUDE_DIR-NOTFOUND"). Now it works like charm.

Thanks

I'll add that!

Cheers, flo

1337!!111!

launchpad ppa for libfreenect

You can find precompiled packages for Ubuntu 10.04 and 10.10 at

https://launchpad.net/~arne-alamut/+archive/freenect/+packages

follow the instructions at

http://openkinect.org/wiki/Getting_Started#Ubuntu

Yep

Yes, since like 2 or 3 days now ?

1337!!111!

Compilation errors

Hello there... I get errors following the installation instructions above?? Any ideas on how to fix it?

.....
Scanning dependencies of target as3-server
[ 92%] Building C object examples/CMakeFiles/as3-server.dir/as3-server.c.o
/home/tbp/Documents/work/uni/master/kinect/libfreenect/c/examples/as3-server.c: In function ‘main’:
/home/tbp/Documents/work/uni/master/kinect/libfreenect/c/examples/as3-server.c:418: warning: implicit declaration of function ‘atoi’
Linking C executable as3-server
/usr/bin/ld: cannot find -lJPEG
collect2: ld returned 1 exit status
make[2]: *** [examples/as3-server] Error 1
make[1]: *** [examples/CMakeFiles/as3-server.dir/all] Error 2
make: *** [all] Error 2

Hey there

First things first: You are trying to build the "experimental" as3server for libfreenect. If you don't need it try to edit this line in the CMakeLists.txt

OPTION(BUILD_AS3_SERVER "Build the Actionscript 3 Server Example" OFF)

OFF sounds right for you :)

In the current git head this is the default, so so may try a "git pull" in your linbfreenect folder first.

Hope this helps.

1337!!111!

Help: Kinect camera test Number of devices found: 0

Hi

I installed everything as indicated and I had no errors but when I run glview I have the following lines:
Kinect camera test
Number of devices found: 0

Anyone knows why I cannot see the device?
The Kinect is connected to my useb port and the kinect has a green light blinking so I have no idea why is not founding it.

Can anyone help me?
Thanks
Best

udev rules

Hey there,

you need to add the udev rules for the kinect...I'll add that to the howto...

1337!!111!

PLug in the kinect

Did you plug in the power of the kinect? On the pc, only plugging in the USB-port aint gonna work :)

u'll need the ...

powersupply ... without it the Kinect won't work!

cheers!

1337!!111!

I'm getting stuck at this

I'm getting stuck at this point, any help would be appreciated!

seanq@ubuntu ~/Kinect/repos/build $ cmake ..
-- Operating system is Linux
-- Got System Processor i686
-- libfreenect will be installed to /usr/local
-- Headers will be installed to /usr/local/include/libfreenect
-- Libraries will be installed to /usr/local/lib
-- Found libusb-1.0:
-- - Includes: /usr/include
-- - Libraries: /usr/lib/libusb-1.0.so
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:
GLUT_Xi_LIBRARY (ADVANCED)
linked by target "cppview" in directory /home/sean/Kinect/repos/examples
linked by target "glpclview" in directory /home/sean/Kinect/repos/examples
linked by target "glview" in directory /home/sean/Kinect/repos/examples

-- Configuring incomplete, errors occurred!

dependencies

Did you install all dependencies like glut/freeglut?

1337!!111!

libfreenect compile with:

hi,
after your instructions all run is ok thanks
i have a questions:
it's possible to compile the glview.c in a old-style manner:
clone the glview.c into glview_2.c and with
-------------
cc -fPIC -g -Wall glview_2.c -o glview_2 -I/usr/X121R6/include -I../libusb/libusb/libusb-1.0 -I/usr/local/include/libfreenect -L/usr/X121R6/lib -L/usr/local/lib64 -lfreenect -lglut -lGLU -lGL -lm
-----------------------------
yes i make a big jump into the water:
compile OK,run with ./glview_2 OOOK
thank you for your good instructions, i have working on this stuff for
2 days
regards nomad

Hey Nomad

Yeah that should work - Do you mind ... WHY? Cmake does all the magic for you... If you need more advice you can joint the OpenKinect group @google goups: http://groups.google.com/group/openkinect

1337!!111!

hi fl0 my old-style compile

hi fl0
my old-style compile is done all stuff running
cc -fPIC -g -Wall glview_2.c -o glview_2 -I/usr/X121R6/include -I../libusb/libusb/libusb-1.0 -I/usr/local/include/libfreenect -L/usr/X121R6/lib -L/usr/local/lib64 -lfreenect -lglut -lGLU -lGL -lm

thanks
regards nomad

using Pure Dyne distro

For some reason, all the libraries and dependencies install but not in the usual places in Pure Dyne. I had to manually copy libfreenect.pc into libfreenect/bin/src because the original git clone process didn't put it in the right place. i had to run cmake in the build folder as sudo and after moving the file into the proper place make ran successfully. the original message was that it couldn't find libfreenect.pc
I may have also had trouble installing some of the dependencies but running everything as sudo a second time around did the trick. i may just re-image my hard drive and document my steps so that other people can benefit. Salute!

using Pure Dyne distro

For some reason, all the libraries and dependencies install but not in the usual places in Pure Dyne. I had to manually copy libfreenect.pc into libfreenect/bin/src because the original git clone process didn't put it in the right place. i had to run cmake in the build folder as sudo and after moving the file into the proper place make ran successfully. the original message was that it couldn't find libfreenect.pc
I may have also had trouble installing some of the dependencies but running everything as sudo a second time around did the trick. I may just re-image my hard drive and document my steps so that other people can benefit. Salute!

install under PureDyne

hi
if "PureDyne" a new release of Ubuntu????
the above install instruction are running under Ubuntu-10.10
i think download a new libfreenect.tar.gz
und following the install-instructions
regards nomad

OpenNI

fyi: a description how to use the Kinect with the OpenNI drivers can be found at
http://www.andreas-und-barbara.de/blog/2011/01/kinect-on-ubuntu-10-10-ma...

exporting frames/video

Finally got the Kinect to work and display images with some of the apps out there. The easiest to work are the Processing apps. Anyone know how to export the Kinect capture frames to video? I can't find any references to this. Either n Linux or OSX. Thanks!

Help required

Hi,
I have installed kinect drivers successfully following your instruction.Moreover,I have also run demos such as tiltdemo,glpclview (black and white video demo)and glview (turning on sensor) they are working well too but problem is that i am unable to see the output of hiview which shows colored video and depth video.It is only showing streaming on terminal but giving blank output where video is suppose to come.Kindly help me out and tell me what the problem is.
Thanks

k

I will have a look at that ... I didnt use the driver for a while :)

1337!!111!

It happend to me Try this, It

It happend to me

Try this, It worked.

sudo apt-get install libxmu-dev libxi-dev

Can't compile my C Program

I installed freenect correctly (i guess), but can't compile my C program!! it says that can't find the freenect's libraries :S... so i know that i should link the libraries, but i don't know how!!!

please help!!!

Try..

echo $LD_LIBRARY_PATH in a shell. If the path you installed freenect in isn't printed you need to expand the LD_.. Path like the following:

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/new/path

Be advised, this only works for the currently opened shell if you need to expand it permanently config. your .bashrc (ask google). The proper way is to install freenect (with sudo) in /usr/local/lib or /usr/lib.

cheers.

1337!!111!

thanks works great!

thanks works great!

try

try this
root@ubuntu:~/Kinect/repos/libfreenect/build$ cmake ..

libfreenect contains cmakefile.txt so cmake .. should be used in its subdirectory

Yes, BUT...

never compile as ROOT!

1337!!111!

try this command sudo rmmod

try this command

sudo rmmod gspca_kinect

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code>
  • Lines and paragraphs break automatically.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.