Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 21 additions & 12 deletions robocon/vision/vision.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ def __init__(self,
send_to_sheep=False,
save=True):

super(PostProcessor, self).__init__()
super(PostProcessor, self).__init__(daemon=True)

self._owner = owner
self.zone = zone
Expand All @@ -344,7 +344,9 @@ def __init__(self,
def stop(self):
"""Finish current work then join main process"""
self._stop_event.set()
self.join()
# may be called during interpreter shutdown, where daemon threads never
# finish, so don't wait forever
self.join(timeout=2)

def stopped(self):
"""public alias for _stop_event"""
Expand Down Expand Up @@ -409,16 +411,23 @@ def run(self):
except queue.Empty:
pass
else:
frame = capture.colour_frame
if self._bounding_box:
frame = self._draw_bounding_box(frame, detections)
if self._save:
encoded_img = base64.b64encode(cv2.imencode(".jpg", frame)[1]) + b'\n'
self._image_pipe.write(encoded_img)
if self._usb_stick:
self._write_to_usb(capture, detections)
if self._send_to_sheep:
pass
try:
self._process(capture, detections)
except Exception:
logging.exception("Failed to postprocess frame")

def _process(self, capture, detections):
"""Draws on a frame and sends it to wherever it has been configured to go"""
frame = capture.colour_frame
if self._bounding_box:
frame = self._draw_bounding_box(frame, detections)
if self._save:
encoded_img = base64.b64encode(cv2.imencode(".jpg", frame)[1]) + b'\n'
self._image_pipe.write(encoded_img)
if self._usb_stick:
self._write_to_usb(capture, detections)
if self._send_to_sheep:
pass


class Vision():
Expand Down
Loading