diff --git a/frigate/config/semantic_search.py b/frigate/config/semantic_search.py index be4148e5e..f5e881e4e 100644 --- a/frigate/config/semantic_search.py +++ b/frigate/config/semantic_search.py @@ -1,4 +1,4 @@ -from typing import Optional +from typing import Dict, List, Optional from pydantic import Field @@ -41,3 +41,6 @@ class LicensePlateRecognitionConfig(FrigateBaseModel): default=500, title="Min area of license plate to consider running license plate recognition.", ) + known_plates: Optional[Dict[str, List[str]]] = Field( + default={}, title="Known plates to track." + ) diff --git a/frigate/embeddings/maintainer.py b/frigate/embeddings/maintainer.py index 4e24fdd86..90f31456b 100644 --- a/frigate/embeddings/maintainer.py +++ b/frigate/embeddings/maintainer.py @@ -239,6 +239,9 @@ class EmbeddingMaintainer(threading.Thread): if event_id in self.detected_faces: self.detected_faces.pop(event_id) + if event_id in self.detected_license_plates: + self.detected_license_plates.pop(event_id) + if updated_db: try: event: Event = Event.get(Event.id == event_id) @@ -569,11 +572,20 @@ class EmbeddingMaintainer(threading.Thread): ) return + # Determine subLabel based on known plates + # Default to the detected plate, use label name if there's a match + sub_label = license_plates[0] + for label, plates in self.lpr_config.known_plates.items(): + if license_plates[0] in plates: + sub_label = label + break + + # Send the result to the API resp = requests.post( f"{FRIGATE_LOCALHOST}/api/events/{id}/sub_label", json={ "camera": obj_data.get("camera"), - "subLabel": license_plates[0], + "subLabel": sub_label, "subLabelScore": confidences[0], }, )