From 3c069bacdc32cb5e91303d10a5c678b2cdfbad21 Mon Sep 17 00:00:00 2001 From: ivelin Date: Sun, 25 Aug 2019 13:37:21 -0500 Subject: [PATCH] bug fixes in saved samples code --- detect_objects.py | 13 ++++++++----- frigate/object_detection.py | 8 ++++---- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/detect_objects.py b/detect_objects.py index a680a9bef..2dd5000d7 100755 --- a/detect_objects.py +++ b/detect_objects.py @@ -88,11 +88,14 @@ def main(): while True: # max out at 5 FPS time.sleep(0.2) - frame = cameras[camera_name].get_current_frame_with_objects() - # encode the image into a jpg - ret, jpg = cv2.imencode('.jpg', frame) - yield (b'--frame\r\n' - b'Content-Type: image/jpeg\r\n\r\n' + jpg.tobytes() + b'\r\n\r\n') + try: + frame = cameras[camera_name].get_current_frame_with_objects() + # encode the image into a jpg + ret, jpg = cv2.imencode('.jpg', frame) + yield (b'--frame\r\n' + b'Content-Type: image/jpeg\r\n\r\n' + jpg.tobytes() + b'\r\n\r\n') + except Exception as e: + print("Error while preparing the next image for http output: " + str(e)) app.run(host='0.0.0.0', port=WEB_PORT, debug=False) diff --git a/frigate/object_detection.py b/frigate/object_detection.py index 500bc341c..9b3987d1d 100755 --- a/frigate/object_detection.py +++ b/frigate/object_detection.py @@ -119,8 +119,8 @@ class PreppedQueueProcessor(threading.Thread): file_prefix = now.strftime("%Y%m%d-%H%M%S") if detected_objects: # default 2 seconds between saved detection samples - save_det_interval = frame['save_samples'].get('detection_interval', 2) - # print("Detection interval for saved samples : {}".format(save_det_interval)) + save_det_interval = frame['save_samples'].get('detections_interval', 2) + # print("Interval for saved detection samples : {}".format(save_det_interval)) # check if enough time has passed since the last saved detection sample if (now - self.last_saved_det_frame_time).total_seconds() >= save_det_interval: dir += "/detections/" @@ -153,8 +153,8 @@ class PreppedQueueProcessor(threading.Thread): img.save(img_file_path, "JPEG") else: # default 300 seconds (5 min) between saved non detection samples - save_non_det_interval = frame['save_samples'].get('detection_interval', 300) - # print("Detection interval for non saved samples : {}".format(save_non_det_interval)) + save_non_det_interval = frame['save_samples'].get('non_detections_interval', 300) + # print("Interval for saved non-detection samples : {}".format(save_non_det_interval)) # check if enough time has passed since the last saved non-detection sample if (now - self.last_saved_non_det_frame_time).total_seconds() >= save_non_det_interval: dir += "/non_detections/"