Programming with Kinect - Up and running

Swami Gulagulaananda said:
"If you a lot of potential, convert it to Kinectic"

After recently messing around with OpenCV and Python, I thought the next thing to mess around should be Kinect.

Today I played around a tad bit, but was happy that the stuff I was trying out worked fine. So if you are interested to play around with Kinect and don't know how to proceed, read on...

First of all, Kinect as most of you would already be knowing is a Microsoft product. So, programming it with MS Visual Studio (C# and VB) is probably way easier... I haven't tried that out yet since I don't have a good machine with Windows at the moment. So this post mainly is how to install it on Linux and see an output to show that "My kinect is up and running". The language is Python.

Do you have a Kinect (with power supply)?
You first need to have a Kinect. If you don't own an XBox with Kinect, you should buy one :-) It's awesome for playing games. But instead if you want to just program with Kinect, you can purchase a Kinect. I think it costs somewhere around Rs. 9500 (up to 11K depending on the store) and Flipkart sells it for Rs. 10990. When you purchase a Kinect separately (instead of with an XBox), it comes with an external power cable of its own.

However, if you already own an XBox with Kinect, you are fortunate enough to have a Kinect, but you don't have the power cable. You'll have to separately purchase that. Ebay sells it for around Rs. 1500.

Next step - Install stuff on your machine
Next, as the title says, we need to have some stuff installed. The problem is that there are a lot of incomplete resources all over the internet and you can face a bit of trouble if you follow them.

The project that is being used most often is called OpenKinect and you will find that there are quite a few resources, tutorials available there to proceed. But the problem is that the tutorial there didn't work very smoothly for me - at least for Python which was what I was trying.

Note that you need some additional libraries as well. So after doing quite a lot of work, I was able to find this other website (which might actually have the same libraries as OpenKinect since the developers involved are the same) called Pynect. This one worked very smoothly for me. All the additional required libraries are also there in the statement and will be installed if you don't already have it on your system. So, in my opinion, try out with Pynect first. In case you experience difficulties, try the OpenKinect site.

To summarise this paragraph, open your terminal and enter the two statements below:
sudo apt-get install build-essential git-core libusb-1.0-0-dev \
    python-pip python-dev python-numpy python-matplotlib

sudo pip install \
    -e git+git://github.com/bwhite/libfreenect.git@pynect#egg=freenect \
    -r https://github.com/bwhite/libfreenect/raw/pynect/requirements.txt

Installation done! Now to connect the Kinect
Ok, if everything went well, let's try it out... So plug in your Kinect to the external power cable, connect the USB to your machine and power it up. Your Kinect should have a blinking green LED (it was blinking for me) to show it's on. Once done, open your terminal and....

Free the Kinect!
Pause here for a moment. Before you write code, you should remember that Linux recognises your Kinect as a web cam or camera. So it gets held up. So even if you write code, your code won't be able to recognise that the Kinect is plugged in. Therefore, we first need to free the kinect. So in your terminal, issue the command:

sudo modprobe -r gspca_kinect

Test the Kinect
Run Andy Miller's demo program to test if everything runs fine. If everything is ok, you should see a small window popup that shows a live black and white (IR?) and coloured (normal webcam) version of whatever is in front of the Kinect. That's it :-) Smile and wave at the Kinect.

Did you know? There is something called Fakenect which will apparently allow some kind of simulation if you don't have a Kinect. Read more about it.


What next?
Why don't you try to capture images using your Kinect? Check it out here.

Comments

Popular posts from this blog

THE CURIOUS CASE OF RAHUL GANDHI - Nitin Gupta(Rivaldo)

The (fake) Quest To Eradicate AIDS with Mythical Mystical Indian roots

The Consumer Court Case - Samsung vs Gulagulaananda