-
Notifications
You must be signed in to change notification settings - Fork 2
/
watcher.py
37 lines (29 loc) · 935 Bytes
/
watcher.py
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
35
36
37
import util
import numpy as np
class Watcher(object):
predicate = {}
debug = False
rect = None
def __init__(self, rect=None):
# how big of an area are we concerned with
if rect:
self.rect = rect
self.window = None
super(Watcher, self).__init__()
def shouldWatch(self):
for key, val in self.predicate.items():
if self.manager.state(key) != val:
return False
return True
def transform(self, frame):
return util.crop(frame, np.hstack(self.rect))
#return frame[self.rect[0][1]:self.rect[1][1], self.rect[0][0]:self.rect[1][0], ...]
def debugRect(self):
return self.rect
def updateFrame(self, frame):
if not self.rect:
self.rect = ((0,0), frame.shape[:2][::-1])
self.window = self.transform(frame)
self.update()
def update(self):
pass