bug fixes in saved samples code

This commit is contained in:
ivelin 2019-08-25 13:37:21 -05:00
parent e26baeb782
commit 3c069bacdc
2 changed files with 12 additions and 9 deletions

View File

@ -88,11 +88,14 @@ def main():
while True: while True:
# max out at 5 FPS # max out at 5 FPS
time.sleep(0.2) time.sleep(0.2)
try:
frame = cameras[camera_name].get_current_frame_with_objects() frame = cameras[camera_name].get_current_frame_with_objects()
# encode the image into a jpg # encode the image into a jpg
ret, jpg = cv2.imencode('.jpg', frame) ret, jpg = cv2.imencode('.jpg', frame)
yield (b'--frame\r\n' yield (b'--frame\r\n'
b'Content-Type: image/jpeg\r\n\r\n' + jpg.tobytes() + b'\r\n\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) app.run(host='0.0.0.0', port=WEB_PORT, debug=False)

View File

@ -119,8 +119,8 @@ class PreppedQueueProcessor(threading.Thread):
file_prefix = now.strftime("%Y%m%d-%H%M%S") file_prefix = now.strftime("%Y%m%d-%H%M%S")
if detected_objects: if detected_objects:
# default 2 seconds between saved detection samples # default 2 seconds between saved detection samples
save_det_interval = frame['save_samples'].get('detection_interval', 2) save_det_interval = frame['save_samples'].get('detections_interval', 2)
# print("Detection interval for saved samples : {}".format(save_det_interval)) # print("Interval for saved detection samples : {}".format(save_det_interval))
# check if enough time has passed since the last saved detection sample # 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: if (now - self.last_saved_det_frame_time).total_seconds() >= save_det_interval:
dir += "/detections/" dir += "/detections/"
@ -153,8 +153,8 @@ class PreppedQueueProcessor(threading.Thread):
img.save(img_file_path, "JPEG") img.save(img_file_path, "JPEG")
else: else:
# default 300 seconds (5 min) between saved non detection samples # default 300 seconds (5 min) between saved non detection samples
save_non_det_interval = frame['save_samples'].get('detection_interval', 300) save_non_det_interval = frame['save_samples'].get('non_detections_interval', 300)
# print("Detection interval for non saved samples : {}".format(save_non_det_interval)) # 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 # 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: if (now - self.last_saved_non_det_frame_time).total_seconds() >= save_non_det_interval:
dir += "/non_detections/" dir += "/non_detections/"