mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-03-22 16:18:22 +03:00
lpr dynamic config
This commit is contained in:
parent
b920f43c76
commit
15bca564f2
@ -12,6 +12,7 @@ from frigate.comms.embeddings_updater import EmbeddingsRequestEnum
|
|||||||
from frigate.comms.event_metadata_updater import EventMetadataPublisher
|
from frigate.comms.event_metadata_updater import EventMetadataPublisher
|
||||||
from frigate.comms.inter_process import InterProcessRequestor
|
from frigate.comms.inter_process import InterProcessRequestor
|
||||||
from frigate.config import FrigateConfig
|
from frigate.config import FrigateConfig
|
||||||
|
from frigate.config.classification import LicensePlateRecognitionConfig
|
||||||
from frigate.data_processing.common.license_plate.mixin import (
|
from frigate.data_processing.common.license_plate.mixin import (
|
||||||
WRITE_DEBUG_IMAGES,
|
WRITE_DEBUG_IMAGES,
|
||||||
LicensePlateProcessingMixin,
|
LicensePlateProcessingMixin,
|
||||||
@ -47,6 +48,11 @@ class LicensePlatePostProcessor(LicensePlateProcessingMixin, PostProcessorApi):
|
|||||||
self.sub_label_publisher = sub_label_publisher
|
self.sub_label_publisher = sub_label_publisher
|
||||||
super().__init__(config, metrics, model_runner)
|
super().__init__(config, metrics, model_runner)
|
||||||
|
|
||||||
|
def update_config(self, lpr_config: LicensePlateRecognitionConfig) -> None:
|
||||||
|
"""Update LPR config at runtime."""
|
||||||
|
self.lpr_config = lpr_config
|
||||||
|
logger.debug("LPR config updated dynamically")
|
||||||
|
|
||||||
def process_data(
|
def process_data(
|
||||||
self, data: dict[str, Any], data_type: PostProcessDataEnum
|
self, data: dict[str, Any], data_type: PostProcessDataEnum
|
||||||
) -> None:
|
) -> None:
|
||||||
|
|||||||
@ -8,6 +8,7 @@ import numpy as np
|
|||||||
from frigate.comms.event_metadata_updater import EventMetadataPublisher
|
from frigate.comms.event_metadata_updater import EventMetadataPublisher
|
||||||
from frigate.comms.inter_process import InterProcessRequestor
|
from frigate.comms.inter_process import InterProcessRequestor
|
||||||
from frigate.config import FrigateConfig
|
from frigate.config import FrigateConfig
|
||||||
|
from frigate.config.classification import LicensePlateRecognitionConfig
|
||||||
from frigate.data_processing.common.license_plate.mixin import (
|
from frigate.data_processing.common.license_plate.mixin import (
|
||||||
LicensePlateProcessingMixin,
|
LicensePlateProcessingMixin,
|
||||||
)
|
)
|
||||||
@ -40,6 +41,11 @@ class LicensePlateRealTimeProcessor(LicensePlateProcessingMixin, RealTimeProcess
|
|||||||
self.camera_current_cars: dict[str, list[str]] = {}
|
self.camera_current_cars: dict[str, list[str]] = {}
|
||||||
super().__init__(config, metrics)
|
super().__init__(config, metrics)
|
||||||
|
|
||||||
|
def update_config(self, lpr_config: LicensePlateRecognitionConfig) -> None:
|
||||||
|
"""Update LPR config at runtime."""
|
||||||
|
self.lpr_config = lpr_config
|
||||||
|
logger.debug("LPR config updated dynamically")
|
||||||
|
|
||||||
def process_frame(
|
def process_frame(
|
||||||
self,
|
self,
|
||||||
obj_data: dict[str, Any],
|
obj_data: dict[str, Any],
|
||||||
|
|||||||
@ -102,6 +102,7 @@ class EmbeddingMaintainer(threading.Thread):
|
|||||||
self.face_recognition_config_subscriber = ConfigSubscriber(
|
self.face_recognition_config_subscriber = ConfigSubscriber(
|
||||||
"config/face_recognition", exact=True
|
"config/face_recognition", exact=True
|
||||||
)
|
)
|
||||||
|
self.lpr_config_subscriber = ConfigSubscriber("config/lpr", exact=True)
|
||||||
|
|
||||||
# Configure Frigate DB
|
# Configure Frigate DB
|
||||||
db = SqliteVecQueueDatabase(
|
db = SqliteVecQueueDatabase(
|
||||||
@ -277,6 +278,7 @@ class EmbeddingMaintainer(threading.Thread):
|
|||||||
self.config_updater.check_for_updates()
|
self.config_updater.check_for_updates()
|
||||||
self._check_classification_config_updates()
|
self._check_classification_config_updates()
|
||||||
self._check_face_recognition_config_updates()
|
self._check_face_recognition_config_updates()
|
||||||
|
self._check_lpr_config_updates()
|
||||||
self._process_requests()
|
self._process_requests()
|
||||||
self._process_updates()
|
self._process_updates()
|
||||||
self._process_recordings_updates()
|
self._process_recordings_updates()
|
||||||
@ -289,6 +291,7 @@ class EmbeddingMaintainer(threading.Thread):
|
|||||||
self.config_updater.stop()
|
self.config_updater.stop()
|
||||||
self.classification_config_subscriber.stop()
|
self.classification_config_subscriber.stop()
|
||||||
self.face_recognition_config_subscriber.stop()
|
self.face_recognition_config_subscriber.stop()
|
||||||
|
self.lpr_config_subscriber.stop()
|
||||||
self.event_subscriber.stop()
|
self.event_subscriber.stop()
|
||||||
self.event_end_subscriber.stop()
|
self.event_end_subscriber.stop()
|
||||||
self.recordings_subscriber.stop()
|
self.recordings_subscriber.stop()
|
||||||
@ -381,6 +384,30 @@ class EmbeddingMaintainer(threading.Thread):
|
|||||||
|
|
||||||
logger.debug("Applied dynamic face recognition config update")
|
logger.debug("Applied dynamic face recognition config update")
|
||||||
|
|
||||||
|
def _check_lpr_config_updates(self) -> None:
|
||||||
|
"""Check for LPR config updates."""
|
||||||
|
topic, lpr_config = self.lpr_config_subscriber.check_for_update()
|
||||||
|
|
||||||
|
if topic is None:
|
||||||
|
return
|
||||||
|
|
||||||
|
previous_min_area = self.config.lpr.min_area
|
||||||
|
self.config.lpr = lpr_config
|
||||||
|
|
||||||
|
for camera_config in self.config.cameras.values():
|
||||||
|
if camera_config.lpr.min_area == previous_min_area:
|
||||||
|
camera_config.lpr.min_area = lpr_config.min_area
|
||||||
|
|
||||||
|
for processor in self.realtime_processors:
|
||||||
|
if isinstance(processor, LicensePlateRealTimeProcessor):
|
||||||
|
processor.update_config(lpr_config)
|
||||||
|
|
||||||
|
for processor in self.post_processors:
|
||||||
|
if isinstance(processor, LicensePlatePostProcessor):
|
||||||
|
processor.update_config(lpr_config)
|
||||||
|
|
||||||
|
logger.debug("Applied dynamic LPR config update")
|
||||||
|
|
||||||
def _process_requests(self) -> None:
|
def _process_requests(self) -> None:
|
||||||
"""Process embeddings requests"""
|
"""Process embeddings requests"""
|
||||||
|
|
||||||
|
|||||||
@ -40,21 +40,7 @@ const lpr: SectionConfigOverrides = {
|
|||||||
"device",
|
"device",
|
||||||
"replace_rules",
|
"replace_rules",
|
||||||
],
|
],
|
||||||
restartRequired: [
|
restartRequired: ["model_size", "enhancement", "device"],
|
||||||
"enabled",
|
|
||||||
"model_size",
|
|
||||||
"detection_threshold",
|
|
||||||
"min_area",
|
|
||||||
"recognition_threshold",
|
|
||||||
"min_plate_length",
|
|
||||||
"format",
|
|
||||||
"match_distance",
|
|
||||||
"known_plates",
|
|
||||||
"enhancement",
|
|
||||||
"debug_save_plates",
|
|
||||||
"device",
|
|
||||||
"replace_rules",
|
|
||||||
],
|
|
||||||
uiSchema: {
|
uiSchema: {
|
||||||
format: {
|
format: {
|
||||||
"ui:options": { size: "md" },
|
"ui:options": { size: "md" },
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user