소스 검색

handle empty best frames

Blake Blackshear 4 년 전
부모
커밋
c064b244db
1개의 변경된 파일5개의 추가작업 그리고 3개의 파일을 삭제
  1. 5 3
      detect_objects.py

+ 5 - 3
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: