From bca053196332e1097e29d2c5f7d0104159abb82f Mon Sep 17 00:00:00 2001 From: Blake Blackshear Date: Fri, 15 Jan 2021 07:52:53 -0600 Subject: [PATCH] handle null thumbnail data --- frigate/object_processing.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/frigate/object_processing.py b/frigate/object_processing.py index 97300ef20..80b2882dd 100644 --- a/frigate/object_processing.py +++ b/frigate/object_processing.py @@ -166,10 +166,9 @@ class TrackedObject(): 'entered_zones': list(self.entered_zones).copy(), 'thumbnail': base64.b64encode(self.get_thumbnail()).decode('utf-8') if include_thumbnail else None } - if not self.thumbnail_data['frame_time'] in self.frame_cache: - logger.error(f"Unable to create thumbnail for {self.obj_data['id']}") - logger.error(f"Looking for frame_time of {self.thumbnail_data['frame_time']}") - logger.error(f"Thumbnail frames: {','.join([str(k) for k in self.frame_cache.keys()])}") + + def get_thumbnail(self): + if self.thumbnail_data is None or not self.thumbnail_data['frame_time'] in self.frame_cache: ret, jpg = cv2.imencode('.jpg', np.zeros((175,175,3), np.uint8)) jpg_bytes = self.get_jpg_bytes(timestamp=False, bounding_box=False, crop=True, height=175) @@ -181,6 +180,9 @@ class TrackedObject(): return jpg.tobytes() def get_jpg_bytes(self, timestamp=False, bounding_box=False, crop=False, height=None): + if self.thumbnail_data is None: + return None + best_frame = cv2.cvtColor(self.frame_cache[self.thumbnail_data['frame_time']], cv2.COLOR_YUV2BGR_I420) if bounding_box: