mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-18 17:14:26 +03:00
Fix crash when no faces exist
This commit is contained in:
parent
0963c561d1
commit
be78b59467
@ -33,7 +33,7 @@ class FaceProcessor(RealTimeProcessorApi):
|
|||||||
self.face_config = config.face_recognition
|
self.face_config = config.face_recognition
|
||||||
self.face_detector: cv2.FaceDetectorYN = None
|
self.face_detector: cv2.FaceDetectorYN = None
|
||||||
self.landmark_detector: cv2.face.FacemarkLBF = None
|
self.landmark_detector: cv2.face.FacemarkLBF = None
|
||||||
self.face_recognizer: cv2.face.LBPHFaceRecognizer = None
|
self.recognizer: cv2.face.LBPHFaceRecognizer = None
|
||||||
self.requires_face_detection = "face" not in self.config.objects.all_objects
|
self.requires_face_detection = "face" not in self.config.objects.all_objects
|
||||||
self.detected_faces: dict[str, float] = {}
|
self.detected_faces: dict[str, float] = {}
|
||||||
|
|
||||||
@ -114,6 +114,9 @@ class FaceProcessor(RealTimeProcessorApi):
|
|||||||
faces.append(img)
|
faces.append(img)
|
||||||
labels.append(idx)
|
labels.append(idx)
|
||||||
|
|
||||||
|
if not faces:
|
||||||
|
return
|
||||||
|
|
||||||
self.recognizer: cv2.face.LBPHFaceRecognizer = (
|
self.recognizer: cv2.face.LBPHFaceRecognizer = (
|
||||||
cv2.face.LBPHFaceRecognizer_create(
|
cv2.face.LBPHFaceRecognizer_create(
|
||||||
radius=2, threshold=(1 - self.face_config.min_score) * 1000
|
radius=2, threshold=(1 - self.face_config.min_score) * 1000
|
||||||
@ -212,9 +215,12 @@ class FaceProcessor(RealTimeProcessorApi):
|
|||||||
if not self.landmark_detector:
|
if not self.landmark_detector:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
if not self.label_map:
|
if not self.recognizer:
|
||||||
self.__build_classifier()
|
self.__build_classifier()
|
||||||
|
|
||||||
|
if not self.recognizer:
|
||||||
|
return None
|
||||||
|
|
||||||
img = cv2.cvtColor(face_image, cv2.COLOR_BGR2GRAY)
|
img = cv2.cvtColor(face_image, cv2.COLOR_BGR2GRAY)
|
||||||
img = self.__align_face(img, img.shape[1], img.shape[0])
|
img = self.__align_face(img, img.shape[1], img.shape[0])
|
||||||
index, distance = self.recognizer.predict(img)
|
index, distance = self.recognizer.predict(img)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user