Tuesday, February 21, 2012

Install Openkinect on Ubuntu

1. Follow the link: http://acberg.com/kinect/
2. After step 1, almost everything has been down. But we are not so lucky enough. If you want to run the test.m written by Alex, some changes must be made.

      First, Alex's code is based on the old version of libfreenect(libfreenect.0.0.1), not the one you just installed(libfreenect.1.0.0), so you need to install the old version although there existed some bugs. Otherwise,  you will have to modify Alex's code which would be a great job. The old version can be download from here:
    https://launchpad.net/ubuntu/+source/libfreenect/1:0.0.1+20101211+2-1

Also, you need to make some changes to Alex text.m to mex matlab function.
mex  -I/usr/local/include/libfreenect ...
      -I/usr/local/include /usr/local/lib/libfreenect.a ...
      /usr/lib/libusb-1.0.a ...
      kinect_mex.cc -lpthread -lrt
 if you encounter the following error:
/usr/local/lib/libusb-1.0.a(libusb_1_0_la-io.o): In function `libusb_try_lock_events':/home/tpair/libusb-1.0.2/libusb/io.c:1254: undefined reference to `pthread_mutex_trylock'
/usr/local/lib/libusb-1.0.a(libusb_1_0_la-linux_usbfs.o): In function `op_clock_gettime':os/linux_usbfs.c:2011: undefined reference to `clock_gettime'
:os/linux_usbfs.c:2013: undefined reference to `clock_gettime'

solution: Try using the option "-lpthread" to get the pthread stuff, and "-lrt" to get clock_gettime().

    Second, if you encounter the error like this: Failed to claim the usb interface. You need to run the command in the terminal.
           $>rmmod gspca_kinect
You need to do this whenever you restart your system.

    Third, you also need to do the following:(http://openkinect.org/wiki/Getting_Started)
Also make a file with rules for the Linux device manager:
sudo nano /etc/udev/rules.d/51-kinect.rules
Copy and paste:
# 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"
Be sure to log out and back in. 
Be sure the created file begins with number which is larger than existing and not violating with others.

No comments:

Post a Comment