mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-05-05 13:07:44 +03:00
fix snapshot when using dedicated lpr
This commit is contained in:
parent
3f1b4438e4
commit
f6172cb1e4
@ -634,13 +634,20 @@ class LicensePlateProcessingMixin:
|
|||||||
else:
|
else:
|
||||||
gray = image
|
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
|
# apply CLAHE for contrast enhancement
|
||||||
grid_size = (
|
grid_size = (
|
||||||
max(4, input_w // 40),
|
max(4, input_w // 40),
|
||||||
max(4, input_h // 40),
|
max(4, input_h // 40),
|
||||||
)
|
)
|
||||||
clahe = cv2.createCLAHE(clipLimit=1.5, tileGridSize=grid_size)
|
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
|
# Convert back to 3-channel for model compatibility
|
||||||
image = cv2.cvtColor(enhanced, cv2.COLOR_GRAY2RGB)
|
image = cv2.cvtColor(enhanced, cv2.COLOR_GRAY2RGB)
|
||||||
@ -1257,9 +1264,10 @@ class LicensePlateProcessingMixin:
|
|||||||
f"{camera}: Writing snapshot for {id}, {top_plate}, {current_time}"
|
f"{camera}: Writing snapshot for {id}, {top_plate}, {current_time}"
|
||||||
)
|
)
|
||||||
frame_bgr = cv2.cvtColor(frame, cv2.COLOR_YUV2BGR_I420)
|
frame_bgr = cv2.cvtColor(frame, cv2.COLOR_YUV2BGR_I420)
|
||||||
|
_, encoded_img = cv2.imencode(".jpg", frame_bgr)
|
||||||
self.sub_label_publisher.publish(
|
self.sub_label_publisher.publish(
|
||||||
EventMetadataTypeEnum.save_lpr_snapshot,
|
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] = {
|
self.detected_license_plates[id] = {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user