check for known plates

This commit is contained in:
Josh Hawkins 2024-10-25 17:48:57 -05:00
parent 706ed0c578
commit a96442ea13
2 changed files with 17 additions and 2 deletions

View File

@ -1,4 +1,4 @@
from typing import Optional from typing import Dict, List, Optional
from pydantic import Field from pydantic import Field
@ -41,3 +41,6 @@ class LicensePlateRecognitionConfig(FrigateBaseModel):
default=500, default=500,
title="Min area of license plate to consider running license plate recognition.", 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."
)

View File

@ -239,6 +239,9 @@ class EmbeddingMaintainer(threading.Thread):
if event_id in self.detected_faces: if event_id in self.detected_faces:
self.detected_faces.pop(event_id) self.detected_faces.pop(event_id)
if event_id in self.detected_license_plates:
self.detected_license_plates.pop(event_id)
if updated_db: if updated_db:
try: try:
event: Event = Event.get(Event.id == event_id) event: Event = Event.get(Event.id == event_id)
@ -569,11 +572,20 @@ class EmbeddingMaintainer(threading.Thread):
) )
return 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( resp = requests.post(
f"{FRIGATE_LOCALHOST}/api/events/{id}/sub_label", f"{FRIGATE_LOCALHOST}/api/events/{id}/sub_label",
json={ json={
"camera": obj_data.get("camera"), "camera": obj_data.get("camera"),
"subLabel": license_plates[0], "subLabel": sub_label,
"subLabelScore": confidences[0], "subLabelScore": confidences[0],
}, },
) )