The first article of this series (in the February 2012 issue of LFY) gave an introduction to Kinect. In this second part, I cover the installation of libfreenect. Since these articles are also addressed to newbies, do pardon the inclusion of some of the b
For programming with Kinect, we need Opencv (Open Source Computer Vision), a library for real-time computer vision; so let me show you how to install this on Ubuntu 10.04, along with libfreenect. To install Opencv dependencies, use the following commands: sudo apt-get install build-essential libgtk2.0-dev libavcodec-dev libavformat-dev libjpeg62-dev libtiff4-dev cmake libswscale-dev libjasper-dev cd ~
Download Opencv-2.1.0 from http://bit.ly/czluzs and extract it. Change to the extracted folder. After the cmake step, check whether the ffmpeg value is 1. If not, run it again. cd Opencv-2.1.0/ cmake . make sudo make install sudo gedit /etc/ld.so.conf.d/opencv.conf
At the end of the le, add ‘/usr/local/lib’, then save it, and run the following: sudo gedit /etc/bash.bashrc
Add the following two lines at the end of the le (it should not be empty): export PKG_CONFIG_PATH
Now Opencv-2.1.0 has been installed. Open another terminal to check some of the samples: cd ~ cd Opencv-2.1.0/samples/c chmod +x build_all.sh ./build_all.sh
To check any sample, go to that folder, and run the sample. For example, in the c folder, we have contours2, so to run it: cd c ./contours2
To install libfreenect, we need to install some prerequisites for building it: essential libxmu-dev libxi-dev libusb-1.0-0-dev
Next, clone its source from Github, change into the ‘libfreenect’ directory, create a ‘build’ sub-directory and cd to it, then run cmake to generate native and workspaces that can be used in the compiler environment of your choice: git clone git://github.com/openkinect/libfreenect.git cd libfreenect
mkdir build cd build cmake ..
The make program uses the and the lastmodi cation times of binary les to decide which les need to be updated. Sudo lets us run commands as the superuser, which is required for two steps: make sudo make install
sudo adduser $user video
Run the sample project glview; the result is shown in Figure 1.
Now we are done with the complete environment set-up, and can program Opencv using libfreenect. To write your own code for Opencv, add the libfreenect.h header to your code. In case you have any dif culty, you can mail me (address given below).
 http://www.cmake.org/  http://openkinect.org/  http://opencv.willowgarage.com/wiki/
Figure 1: Running glview