-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathexample_iot.py
36 lines (22 loc) · 902 Bytes
/
example_iot.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
from deeplens.struct import *
from deeplens.tracking.contour import *
from deeplens.tracking.event import *
from deeplens.dataflow.agg import get
from deeplens.utils.ui import play, overlay
#VIDEO File Name
#FILE_NAME = 'iot_videos/khnl6v2j10017mv_1582586053225_fridge_idle1.mp4'
FILE_NAME = 'iot_videos/khnl6v2j10017mv_1582586199865_fridge_door3.mp4'
FRAME_RATE = 24
#create vstream object
vstream = VideoStream(FILE_NAME)
region = Box(200,90,250,110) #region where the fridge is
fridge_session_length_s = 30 #minimum time between events.
vstream = vstream[KeyPoints(blur=1)]\
[ActivityMetric('door', region)]\
[Filter('door', [1], 0, delay=FRAME_RATE*fridge_session_length_s)]
for time, image in get(vstream, 'door', FRAME_RATE):
print('Door Opened at', time, 's')
#hit q to exit
cv2.imshow('Player',image)
if cv2.waitKey(0) & 0xFF == ord('q'):
exit()