-
Notifications
You must be signed in to change notification settings - Fork 0
/
frameImport.py
29 lines (25 loc) · 997 Bytes
/
frameImport.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
import cv2
import queue
class frameImport:
def __init__(self, video_input, lotic_signal):
self.video_input = video_input
self.frame_input_queue = queue.Queue(100)
self.lotic_signal = lotic_signal
def videoSource(self):
self.video_source = cv2.VideoCapture(self.video_input)
return self.video_source
def receiveFrame(self):
while self.lotic_signal.keep_running():
grabbed, self.frame = self.video_source.read()
if not grabbed:
# Todo: you probably don't wanna do this in the "it runs forever"
# case. This is only useful for reading video files with an end.
# But I think that's what you want here, so...
print("not grabbed")
break
self.frame_input_queue.put(self.frame)
def grabFrame(self):
try:
return self.frame_input_queue.get(timeout=3)
except queue.Empty:
return None