Standardize object end

This commit is contained in:
Nicolas Mowen 2025-01-10 08:03:10 -07:00
parent ca144e30ee
commit a69da6ee8f
3 changed files with 19 additions and 4 deletions

View File

@ -76,7 +76,7 @@ class EmbeddingMaintainer(threading.Thread):
self.processors: list[ProcessorApi] = [] self.processors: list[ProcessorApi] = []
if self.config.face_recognition.enabled: if self.config.face_recognition.enabled:
self.processors.append(FaceProcessor(self.config.face_recognition, metrics)) self.processors.append(FaceProcessor(self.config, metrics))
# create communication for updating event descriptions # create communication for updating event descriptions
self.requestor = InterProcessRequestor() self.requestor = InterProcessRequestor()
@ -222,8 +222,8 @@ class EmbeddingMaintainer(threading.Thread):
event_id, camera, updated_db = ended event_id, camera, updated_db = ended
camera_config = self.config.cameras[camera] camera_config = self.config.cameras[camera]
if event_id in self.detected_faces: for processor in self.processors:
self.detected_faces.pop(event_id) processor.expire_object(event_id)
if event_id in self.detected_license_plates: if event_id in self.detected_license_plates:
self.detected_license_plates.pop(event_id) self.detected_license_plates.pop(event_id)

View File

@ -392,3 +392,7 @@ class FaceProcessor(ProcessorApi):
"message": "Successfully registered face.", "message": "Successfully registered face.",
"success": True, "success": True,
} }
def expire_object(self, object_id: str):
if object_id in self.detected_faces:
self.detected_faces.pop(object_id)

View File

@ -30,7 +30,7 @@ class ProcessorApi(ABC):
pass pass
@abstractmethod @abstractmethod
def handle_request(self, request_data: dict[str, any]) -> any | None: def handle_request(self, request_data: dict[str, any]) -> dict[str, any] | None:
"""Handle metadata requests. """Handle metadata requests.
Args: Args:
request_data (dict): containing data about requested change to process. request_data (dict): containing data about requested change to process.
@ -39,3 +39,14 @@ class ProcessorApi(ABC):
None if request was not handled, otherwise return response. None if request was not handled, otherwise return response.
""" """
pass pass
@abstractmethod
def expire_object(self, object_id: str) -> None:
"""Handle objects that are no longer detected.
Args:
object_id (str): id of object that is no longer detected.
Returns:
None.
"""
pass