From c064b244db4722aabd2639bd14236da9469923ec Mon Sep 17 00:00:00 2001 From: Blake Blackshear Date: Tue, 13 Oct 2020 20:57:57 -0500 Subject: [PATCH] handle empty best frames --- detect_objects.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/detect_objects.py b/detect_objects.py index 015c85ece..47f5ae444 100644 --- a/detect_objects.py +++ b/detect_objects.py @@ -388,9 +388,11 @@ def main(): def best(camera_name, label): if camera_name in CONFIG['cameras']: best_object = object_processor.get_best(camera_name, label) - best_frame = best_object.get('frame', np.zeros((720,1280,3), np.uint8)) - - best_frame = cv2.cvtColor(best_frame, cv2.COLOR_YUV2BGR_I420) + best_frame = best_object.get('frame') + if best_frame is None: + best_frame = np.zeros((720,1280,3), np.uint8) + else: + best_frame = cv2.cvtColor(best_frame, cv2.COLOR_YUV2BGR_I420) crop = bool(request.args.get('crop', 0, type=int)) if crop: