Skip to content

NVR with realtime local object detection for IP cameras

fix(face_recognition): feed BGR (not RGB) to FaceDetectorYN in manual detection branch (#23123)

Vinnie Esposito704ee9667cdf
diff --git a/frigate/data_processing/real_time/face.py b/frigate/data_processing/real_time/face.py
index c6b6346b54..c5c4ec56f0 100644
--- a/frigate/data_processing/real_time/face.py
+++ b/frigate/data_processing/real_time/face.py
@@ -229,9 +229,10 @@ class FaceRealTimeProcessor(RealTimeProcessorApi):
logger.debug(f"No person box available for {id}")
return
- rgb = cv2.cvtColor(frame, cv2.COLOR_YUV2RGB_I420)
+ # YuNet (cv2.FaceDetectorYN) is trained on BGR
+ bgr = cv2.cvtColor(frame, cv2.COLOR_YUV2BGR_I420)
left, top, right, bottom = person_box
- person = rgb[top:bottom, left:right]
+ person = bgr[top:bottom, left:right]
face_box = self.__detect_face(person, self.face_config.detection_threshold)
if not face_box:
@@ -250,11 +251,6 @@ class FaceRealTimeProcessor(RealTimeProcessorApi):
)
return
- try:
- face_frame = cv2.cvtColor(face_frame, cv2.COLOR_RGB2BGR)
- except Exception as e:
- logger.debug(f"Failed to convert face frame color for {id}: {e}")
- return
else:
# don't run for object without attributes
if not obj_data.get("current_attributes"):