demo_mp_async.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 import freenect
3 import matplotlib.pyplot as mp
4 import signal
5 import frame_convert
6 
7 mp.ion()
8 image_rgb = None
9 image_depth = None
10 keep_running = True
11 
12 
13 def display_depth(dev, data, timestamp):
14  global image_depth
15  data = frame_convert.pretty_depth(data)
16  mp.gray()
17  mp.figure(1)
18  if image_depth:
19  image_depth.set_data(data)
20  else:
21  image_depth = mp.imshow(data, interpolation='nearest', animated=True)
22  mp.draw()
23 
24 
25 def display_rgb(dev, data, timestamp):
26  global image_rgb
27  mp.figure(2)
28  if image_rgb:
29  image_rgb.set_data(data)
30  else:
31  image_rgb = mp.imshow(data, interpolation='nearest', animated=True)
32  mp.draw()
33 
34 
35 def body(*args):
36  if not keep_running:
37  raise freenect.Kill
38 
39 
40 def handler(signum, frame):
41  global keep_running
42  keep_running = False
43 
44 
45 print('Press Ctrl-C in terminal to stop')
46 signal.signal(signal.SIGINT, handler)
47 freenect.runloop(depth=display_depth,
48  video=display_rgb,
49  body=body)
def display_depth(dev, data, timestamp)
def display_rgb(dev, data, timestamp)
def pretty_depth(depth)
Definition: frame_convert.py:4
def handler(signum, frame)
def body(args)


libfreenect
Author(s): Hector Martin, Josh Blake, Kyle Machulis, OpenKinect community
autogenerated on Thu Jun 6 2019 19:25:38