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