Switch get_one_face() to pick the largest one

This commit is contained in:
Ariel Flesler 2023-07-18 21:10:19 +00:00 committed by GitHub
parent 68f534c35f
commit 6f862d1d48
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -20,9 +20,10 @@ def get_face_analyser() -> Any:
def get_one_face(frame: Frame) -> Any:
face = get_face_analyser().get(frame)
faces = get_face_analyser().get(frame)
try:
return min(face, key=lambda x: x.bbox[0])
# Pick the largest face (x2 - x1) * (y2 - y1)
return max(faces, key=lambda x: (x.bbox[2] - x.bbox[0]) * (x.bbox[3] - x.bbox[1]))
except ValueError:
return None