Tag Archives: openKinect

Python + opencv + ….. wait for it …+ Kinect

11 Dec

Yes, I am back again after a long time. At present I am working in implementing SLAM (which I’ll post in a few days). So, I started out with my environment Linux. Installed openKinect libraries for Kinect. There are other libraries as well but I have tried this one first and it installed smoothly no errors. Now I wrote a small piece of code to get started, yes in Python. The freenect Library has python wrappers, which are also easy to install. Following is the basic code for the newbies.

#######################################################################

import freenect
import cv
import numpy as np
cv.NamedWindow(‘RGB’)

def video_kin(dev,video, timestamp):
global run
print timestamp
cv.ShowImage(‘RGB’,cv.fromarray(video))
cv.WaitKey(10)

freenect.runloop(video=video_kin)

###############################################################

Explanation of Code :

The last Line of the code freenect is the actual backbone. This is the library provided by freenect people for python and has one of the method runloop. This will fetch the video data frame as numpy array. So , in order to show that image we need to first convert it to CvMat or other format.Yeah and most importantly don’t forget to run the code as sudo, ┬ákinect won,t work unless you are a priveleged person.

If you have problems feel free to comment, I’ll try to resolve.

Advertisements