mirror of
https://github.com/blakeblackshear/frigate.git
synced 2025-02-18 00:16:41 +01:00
Improvements to face recognition (#15854)
* Do not add margin to face images * remove margin * Correctly clear
This commit is contained in:
parent
a6ae208fe7
commit
4f85b18b08
@ -456,14 +456,9 @@ class EmbeddingMaintainer(threading.Thread):
|
|||||||
logger.debug("Detected no faces for person object.")
|
logger.debug("Detected no faces for person object.")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
margin = int((face_box[2] - face_box[0]) * 0.25)
|
|
||||||
face_frame = person[
|
face_frame = person[
|
||||||
max(0, face_box[1] - margin) : min(
|
max(0, face_box[1]) : min(frame.shape[0], face_box[3]),
|
||||||
frame.shape[0], face_box[3] + margin
|
max(0, face_box[0]) : min(frame.shape[1], face_box[2]),
|
||||||
),
|
|
||||||
max(0, face_box[0] - margin) : min(
|
|
||||||
frame.shape[1], face_box[2] + margin
|
|
||||||
),
|
|
||||||
]
|
]
|
||||||
face_frame = cv2.cvtColor(face_frame, cv2.COLOR_RGB2BGR)
|
face_frame = cv2.cvtColor(face_frame, cv2.COLOR_RGB2BGR)
|
||||||
else:
|
else:
|
||||||
@ -492,15 +487,10 @@ class EmbeddingMaintainer(threading.Thread):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
face_frame = cv2.cvtColor(frame, cv2.COLOR_YUV2BGR_I420)
|
face_frame = cv2.cvtColor(frame, cv2.COLOR_YUV2BGR_I420)
|
||||||
margin = int((face_box[2] - face_box[0]) * 0.25)
|
|
||||||
|
|
||||||
face_frame = face_frame[
|
face_frame = face_frame[
|
||||||
max(0, face_box[1] - margin) : min(
|
max(0, face_box[1]) : min(frame.shape[0], face_box[3]),
|
||||||
frame.shape[0], face_box[3] + margin
|
max(0, face_box[0]) : min(frame.shape[1], face_box[2]),
|
||||||
),
|
|
||||||
max(0, face_box[0] - margin) : min(
|
|
||||||
frame.shape[1], face_box[2] + margin
|
|
||||||
),
|
|
||||||
]
|
]
|
||||||
|
|
||||||
res = self.face_classifier.classify_face(face_frame)
|
res = self.face_classifier.classify_face(face_frame)
|
||||||
|
@ -309,8 +309,7 @@ class FaceClassificationModel:
|
|||||||
)
|
)
|
||||||
|
|
||||||
def clear_classifier(self) -> None:
|
def clear_classifier(self) -> None:
|
||||||
self.classifier = None
|
self.face_recognizer = None
|
||||||
self.labeler = None
|
|
||||||
self.label_map = {}
|
self.label_map = {}
|
||||||
|
|
||||||
def detect_faces(self, input: np.ndarray) -> tuple[int, cv2.typing.MatLike] | None:
|
def detect_faces(self, input: np.ndarray) -> tuple[int, cv2.typing.MatLike] | None:
|
||||||
|
Loading…
Reference in New Issue
Block a user