-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathimage_capture.py
executable file
·41 lines (34 loc) · 1.13 KB
/
image_capture.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
38
39
40
41
import time
import threading
# Image capture thread
class ImageCapture(threading.Thread):
def __init__(self, camera, processor):
self.running = False
self.processor = processor
self.camera = camera
super(ImageCapture, self).__init__()
self.start()
def run(self):
print('Start the stream using the video port')
self.running = True
self.camera.capture_sequence(
self.TriggerStream(),
format='bgr',
use_video_port=True
)
print('Terminating camera processing...')
self.processor.terminated = True
self.processor.join()
print('Image_capture terminated')
def stop(self):
""" Stop this threaded class """
self.running = False
# Stream delegation loop
def TriggerStream(self):
""" Method called which loops endlessly """
while self.running:
if self.processor.event.is_set():
time.sleep(0.01)
else:
yield self.processor.stream
self.processor.event.set()