-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbase_app.py
More file actions
40 lines (27 loc) · 904 Bytes
/
base_app.py
File metadata and controls
40 lines (27 loc) · 904 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#! -*- coding:utf8 -*-
import freenect
import cv2
class FreenectCv2App(object):
"""Clase base para extender una aplicacion freenect"""
def __init__(self):
self.keep_running = True
def run(self):
"""Starts execution"""
freenect.runloop(
depth=self.display_depth,
video=self.display_rgb,
body=self.main
)
def main(self, *args):
if not self.keep_running:
raise freenect.Kill
def display_depth(self, dev, data, timestamp):
"""Works over a frame of depth map"""
self._wait_for_exit()
def display_rgb(self, dev, data, timestamp):
"""Works over a video frame"""
self._wait_for_exit()
def _wait_for_exit(self):
"""Wait for ESC keypress to exit app"""
if cv2.waitKey(10) == 27:
self.keep_running = False