From f6172cb1e4681d16514026eaa9418546fa72bf73 Mon Sep 17 00:00:00 2001 From: Josh Hawkins <32435876+hawkeye217@users.noreply.github.com> Date: Thu, 27 Mar 2025 17:32:53 -0500 Subject: [PATCH] fix snapshot when using dedicated lpr --- .../data_processing/common/license_plate/mixin.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/frigate/data_processing/common/license_plate/mixin.py b/frigate/data_processing/common/license_plate/mixin.py index 60066c48d..a2528380b 100644 --- a/frigate/data_processing/common/license_plate/mixin.py +++ b/frigate/data_processing/common/license_plate/mixin.py @@ -634,13 +634,20 @@ class LicensePlateProcessingMixin: else: gray = image + if False: + smoothed = cv2.bilateralFilter(gray, d=3, sigmaColor=50, sigmaSpace=50) + sharpening_kernel = np.array([[-1, -1, -1], [-1, 9, -1], [-1, -1, -1]]) + processed = cv2.filter2D(smoothed, -1, sharpening_kernel) + else: + processed = gray + # apply CLAHE for contrast enhancement grid_size = ( max(4, input_w // 40), max(4, input_h // 40), ) clahe = cv2.createCLAHE(clipLimit=1.5, tileGridSize=grid_size) - enhanced = clahe.apply(gray) + enhanced = clahe.apply(processed) # Convert back to 3-channel for model compatibility image = cv2.cvtColor(enhanced, cv2.COLOR_GRAY2RGB) @@ -1257,9 +1264,10 @@ class LicensePlateProcessingMixin: f"{camera}: Writing snapshot for {id}, {top_plate}, {current_time}" ) frame_bgr = cv2.cvtColor(frame, cv2.COLOR_YUV2BGR_I420) + _, encoded_img = cv2.imencode(".jpg", frame_bgr) self.sub_label_publisher.publish( EventMetadataTypeEnum.save_lpr_snapshot, - (base64.b64encode(frame_bgr).decode("ASCII"), id, camera), + (base64.b64encode(encoded_img).decode("ASCII"), id, camera), ) self.detected_license_plates[id] = {