The first ar­ti­cle of this se­ries (in the Fe­bru­ary 2012 is­sue of LFY) gave an in­tro­duc­tion to Kinect. In this sec­ond part, I cover the in­stal­la­tion of libfreenect. Since these ar­ti­cles are also ad­dressed to new­bies, do par­don the in­clu­sion of some of the b

OpenSource For You - - LET'S TRY DEVELOPERS - By: Sa­marth Shah The au­thor is a FOSS ad­vo­cate and loves to learn new tech­nolo­gies. His ar­eas of in­ter­est in­clude Kinect, Linux, Ar­duino and Im­age Pro­cess­ing us­ing Opencv. In his spare time he writes mo­ti­va­tional thoughts and shares them on his blog shahs

For pro­gram­ming with Kinect, we need Opencv (Open Source Com­puter Vi­sion), a li­brary for real-time com­puter vi­sion; so let me show you how to in­stall this on Ubuntu 10.04, along with libfreenect. To in­stall Opencv de­pen­den­cies, use the fol­low­ing com­mands: sudo apt-get in­stall build-es­sen­tial libgtk2.0-dev libav­codec-dev libav­for­mat-dev lib­jpeg62-dev libtiff4-dev cmake lib­sws­cale-dev lib­jasper-dev cd ~

Down­load Opencv-2.1.0 from and ex­tract it. Change to the extracted folder. Af­ter the cmake step, check whether the ffm­peg value is 1. If not, run it again. cd Opencv-2.1.0/ cmake . make sudo make in­stall sudo gedit /etc/

At the end of the le, add ‘/usr/lo­cal/lib’, then save it, and run the fol­low­ing: sudo gedit /etc/bash.bashrc

Add the fol­low­ing two lines at the end of the le (it should not be empty): ex­port PKG_CONFIG_PATH

Now Opencv-2.1.0 has been in­stalled. Open an­other ter­mi­nal to check some of the sam­ples: cd ~ cd Opencv-2.1.0/sam­ples/c chmod +x ./

To check any sam­ple, go to that folder, and run the sam­ple. For ex­am­ple, in the c folder, we have con­tours2, so to run it: cd c ./con­tours2


To in­stall libfreenect, we need to in­stall some pre­req­ui­sites for build­ing it: es­sen­tial libxmu-dev libxi-dev libusb-1.0-0-dev

Next, clone its source from Github, change into the ‘libfreenect’ di­rec­tory, cre­ate a ‘build’ sub-di­rec­tory and cd to it, then run cmake to gen­er­ate na­tive and workspaces that can be used in the com­piler en­vi­ron­ment of your choice: git clone git:// cd libfreenect

mkdir build cd build cmake ..

The make pro­gram uses the and the last­modi cation times of bi­nary les to de­cide which les need to be up­dated. Sudo lets us run com­mands as the su­pe­ruser, which is re­quired for two steps: make sudo make in­stall

sudo ad­duser $user video

Run the sam­ple project glview; the re­sult is shown in Fig­ure 1.

sudo glview

Now we are done with the com­plete en­vi­ron­ment set-up, and can pro­gram Opencv us­ing 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 (ad­dress given be­low).


[1] [2] [3] http://opencv.wil­low­


Fig­ure 1: Run­ning glview

Newspapers in English

Newspapers from India

© PressReader. All rights reserved.