From 25f6ee7610871cc51f43332fb3a8aac9881b26b2 Mon Sep 17 00:00:00 2001 From: Josh Hawkins <32435876+hawkeye217@users.noreply.github.com> Date: Wed, 7 May 2025 10:19:52 -0500 Subject: [PATCH] always apply motion mask when using yolov9 plate detection --- docs/docs/configuration/license_plate_recognition.md | 8 ++++---- frigate/data_processing/common/license_plate/mixin.py | 4 ++++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/docs/docs/configuration/license_plate_recognition.md b/docs/docs/configuration/license_plate_recognition.md index d7bc37ace..41b296a49 100644 --- a/docs/docs/configuration/license_plate_recognition.md +++ b/docs/docs/configuration/license_plate_recognition.md @@ -359,10 +359,10 @@ The YOLOv9 license plate detector model will run (and the metric will appear) if If you are detecting `car` or `motorcycle` on cameras where you don't want to run LPR, make sure you disable LPR it at the camera level. And if you do want to run LPR on those cameras, make sure you define `license_plate` as an object to track. -### It looks like Frigate picked up my camera's timestamp as the license plate. How can I prevent this? +### It looks like Frigate picked up my camera's timestamp or overlay text as the license plate. How can I prevent this? -This could happen if cars or motorcycles travel close to your camera's timestamp. You could either move the timestamp through your camera's firmware, or apply a mask to it in Frigate. +This could happen if cars or motorcycles travel close to your camera's timestamp or overlay text. You could either move the text through your camera's firmware, or apply a mask to it in Frigate. -If you are using a model that natively detects `license_plate`, add an _object mask_ of type `license_plate` and a _motion mask_ over your timestamp. +If you are using a model that natively detects `license_plate`, add an _object mask_ of type `license_plate` and a _motion mask_ over your text. -If you are using dedicated LPR camera mode, only a _motion mask_ over your timestamp is required. +If you are not using a model that natively detects `license_plate` or you are using dedicated LPR camera mode, only a _motion mask_ over your text is required. diff --git a/frigate/data_processing/common/license_plate/mixin.py b/frigate/data_processing/common/license_plate/mixin.py index b4ccf9cb8..f4ff08644 100644 --- a/frigate/data_processing/common/license_plate/mixin.py +++ b/frigate/data_processing/common/license_plate/mixin.py @@ -1297,6 +1297,10 @@ class LicensePlateProcessingMixin: return rgb = cv2.cvtColor(frame, cv2.COLOR_YUV2BGR_I420) + + # apply motion mask + rgb[self.config.cameras[camera].motion.mask == 0] = [0, 0, 0] + left, top, right, bottom = car_box car = rgb[top:bottom, left:right]