From 4eff2334796ad92dd9051123cd9f7280b07e68ad Mon Sep 17 00:00:00 2001 From: Josh Hawkins <32435876+hawkeye217@users.noreply.github.com> Date: Fri, 4 Apr 2025 12:01:08 -0500 Subject: [PATCH] only publish to recognized plate field if object already has a sub label --- .../common/license_plate/mixin.py | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/frigate/data_processing/common/license_plate/mixin.py b/frigate/data_processing/common/license_plate/mixin.py index 7aa9861e88..09c5300d52 100644 --- a/frigate/data_processing/common/license_plate/mixin.py +++ b/frigate/data_processing/common/license_plate/mixin.py @@ -1159,14 +1159,6 @@ class LicensePlateProcessingMixin: ) return - # don't overwrite sub label for objects that have a sub label - # that is not a license plate - if obj_data.get("sub_label") and id not in self.detected_license_plates: - logger.debug( - f"{camera}: Not processing license plate due to existing sub label: {obj_data.get('sub_label')}." - ) - return - license_plate: Optional[dict[str, any]] = None if "license_plate" not in self.config.cameras[camera].objects.track: @@ -1403,12 +1395,23 @@ class LicensePlateProcessingMixin: None, ) - # If it's a known plate, publish to sub_label - if sub_label is not None: + # don't overwrite sub label for objects that have a sub label + # that is not a license plate + if ( + sub_label is not None + and obj_data.get("sub_label") is not None + and id not in self.detected_license_plates + ): + logger.debug( + f"{camera}: Not overwriting sub label for recognized license plate due to existing sub label: {obj_data.get('sub_label')}." + ) + elif sub_label is not None: + # If it's a known plate, publish to sub_label self.sub_label_publisher.publish( EventMetadataTypeEnum.sub_label, (id, sub_label, avg_confidence) ) + # always publish to recognized_license_plate field self.sub_label_publisher.publish( EventMetadataTypeEnum.recognized_license_plate, (id, top_plate, avg_confidence),