浏览代码

handle exception when frame isnt in cache

Blake Blackshear 4 年之前
父节点
当前提交
1785c69e1b
共有 1 个文件被更改,包括 5 次插入1 次删除
  1. 5 1
      frigate/object_processing.py

+ 5 - 1
frigate/object_processing.py

@@ -183,7 +183,11 @@ class TrackedObject():
         if self.thumbnail_data is None:
             return None
             
-        best_frame = cv2.cvtColor(self.frame_cache[self.thumbnail_data['frame_time']], cv2.COLOR_YUV2BGR_I420)
+        try:
+            best_frame = cv2.cvtColor(self.frame_cache[self.thumbnail_data['frame_time']], cv2.COLOR_YUV2BGR_I420)
+        except KeyError:
+            logger.warning(f"Unable to create jpg because frame {self.thumbnail_data['frame_time']} is not in the cache")
+            return None
  
         if bounding_box:
             thickness = 2