Improve Face Library Management (#17213)

* Set maximum number of face images to be kept

* Fix vertical camera scaling

* adjust wording

* Add attributes to search data

* Add button to train face from event

* Handle event id saving in API
This commit is contained in:
Nicolas Mowen
2025-03-17 15:57:46 -06:00
committed by GitHub
parent ff8e145b90
commit bf22d89f67
10 changed files with 167 additions and 26 deletions

View File

@@ -28,6 +28,7 @@ logger = logging.getLogger(__name__)
MAX_DETECTION_HEIGHT = 1080
MAX_FACE_ATTEMPTS = 100
MIN_MATCHING_FACES = 2
@@ -482,6 +483,16 @@ class FaceRealTimeProcessor(RealTimeProcessorApi):
)
shutil.move(current_file, new_file)
files = sorted(
os.listdir(folder),
key=lambda f: os.path.getctime(os.path.join(folder, f)),
reverse=True,
)
# delete oldest face image if maximum is reached
if len(files) > MAX_FACE_ATTEMPTS:
os.unlink(os.path.join(folder, files[-1]))
def expire_object(self, object_id: str):
if object_id in self.detected_faces:
self.detected_faces.pop(object_id)