mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-15 15:45:27 +03:00
check for known plates
This commit is contained in:
parent
706ed0c578
commit
a96442ea13
@ -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."
|
||||||
|
)
|
||||||
|
|||||||
@ -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],
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user