From e930492ccc5322a9ee00844ce9577d7d9f82651e Mon Sep 17 00:00:00 2001 From: Josh Hawkins <32435876+hawkeye217@users.noreply.github.com> Date: Sun, 8 Mar 2026 17:22:38 -0500 Subject: [PATCH] Publish license plate box coordinates (#22337) * publish the detected plate's box coordinates in tracked_object_update * docs --- docs/docs/integrations/mqtt.md | 3 ++- .../common/license_plate/mixin.py | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/docs/docs/integrations/mqtt.md b/docs/docs/integrations/mqtt.md index ca3589df1..0ef6774a8 100644 --- a/docs/docs/integrations/mqtt.md +++ b/docs/docs/integrations/mqtt.md @@ -159,7 +159,8 @@ Published when a license plate is recognized on a car object. See the [License P "plate": "123ABC", "score": 0.95, "camera": "driveway_cam", - "timestamp": 1607123958.748393 + "timestamp": 1607123958.748393, + "plate_box": [917, 487, 1029, 529] // box coordinates of the detected license plate in the frame } ``` diff --git a/frigate/data_processing/common/license_plate/mixin.py b/frigate/data_processing/common/license_plate/mixin.py index c184b8b75..e4fbd1172 100644 --- a/frigate/data_processing/common/license_plate/mixin.py +++ b/frigate/data_processing/common/license_plate/mixin.py @@ -1225,6 +1225,8 @@ class LicensePlateProcessingMixin: logger.debug(f"{camera}: License plate area below minimum threshold.") return + plate_box = license_plate + license_plate_frame = rgb[ license_plate[1] : license_plate[3], license_plate[0] : license_plate[2], @@ -1341,6 +1343,20 @@ class LicensePlateProcessingMixin: logger.debug(f"{camera}: License plate is less than min_area") return + # Scale back to original car coordinates and then to frame + plate_box_in_car = ( + license_plate[0] // 2, + license_plate[1] // 2, + license_plate[2] // 2, + license_plate[3] // 2, + ) + plate_box = ( + left + plate_box_in_car[0], + top + plate_box_in_car[1], + left + plate_box_in_car[2], + top + plate_box_in_car[3], + ) + license_plate_frame = car[ license_plate[1] : license_plate[3], license_plate[0] : license_plate[2], @@ -1404,6 +1420,8 @@ class LicensePlateProcessingMixin: 0, [license_plate_frame.shape[1], license_plate_frame.shape[0]] * 2 ) + plate_box = tuple(int(x) for x in expanded_box) + # Crop using the expanded box license_plate_frame = license_plate_frame[ int(expanded_box[1]) : int(expanded_box[3]), @@ -1611,6 +1629,7 @@ class LicensePlateProcessingMixin: "id": id, "camera": camera, "timestamp": start, + "plate_box": plate_box, } ), )