00001 import freenect
00002 import cv
00003 import numpy as np
00004
00005 cv.NamedWindow('Depth')
00006
00007 def display(dev, data, timestamp):
00008 data -= np.min(data.ravel())
00009 data *= 65536 / np.max(data.ravel())
00010 image = cv.CreateImageHeader((data.shape[1], data.shape[0]),
00011 cv.IPL_DEPTH_16U,
00012 1)
00013 cv.SetData(image, data.tostring(),
00014 data.dtype.itemsize * data.shape[1])
00015 cv.ShowImage('Depth', image)
00016 cv.WaitKey(5)
00017 freenect.runloop(lambda *x: display(*freenect.depth_cb_np(*x)))