Set max limit to faces to recognize

This commit is contained in:
Nicolas Mowen 2025-03-28 12:02:54 -06:00
parent 5ba7aac431
commit f6e0826208

View File

@ -33,7 +33,8 @@ logger = logging.getLogger(__name__)
MAX_DETECTION_HEIGHT = 1080 MAX_DETECTION_HEIGHT = 1080
MIN_MATCHING_FACES = 2 MAX_FACES_ATTEMPTS_AFTER_REC = 6
MAX_FACE_ATTEMPTS = 12
class FaceRealTimeProcessor(RealTimeProcessorApi): class FaceRealTimeProcessor(RealTimeProcessorApi):
@ -170,6 +171,23 @@ class FaceRealTimeProcessor(RealTimeProcessorApi):
) )
return return
# check if we have hit limits
if (
id in self.person_face_history
and len(self.person_face_history[id]) > MAX_FACES_ATTEMPTS_AFTER_REC
):
# if we are at max attempts after rec and we have a rec
if obj_data.get("sub_label"):
logger.debug(
"Not processing due to hitting max attempts after true recognition."
)
return
# if we don't have a rec and are at max attempts
if len(self.person_face_history[id]) > MAX_FACE_ATTEMPTS:
logger.debug("Not processing due to hitting max rec attempts.")
return
face: Optional[dict[str, any]] = None face: Optional[dict[str, any]] = None
if self.requires_face_detection: if self.requires_face_detection: