mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-05 18:55:23 +03:00
Set thumbnail height to 175
This commit is contained in:
parent
028c117cdd
commit
9e2f9a9b6f
@ -82,11 +82,11 @@ class ExternalEventProcessor:
|
|||||||
label: str,
|
label: str,
|
||||||
event_id: str,
|
event_id: str,
|
||||||
draw: dict[str, any],
|
draw: dict[str, any],
|
||||||
img_bytes: any,
|
img_frame: any,
|
||||||
) -> str:
|
) -> str:
|
||||||
# write clean snapshot if enabled
|
# write clean snapshot if enabled
|
||||||
if camera_config.snapshots.clean_copy:
|
if camera_config.snapshots.clean_copy:
|
||||||
ret, png = cv2.imencode(".png", img_bytes)
|
ret, png = cv2.imencode(".png", img_frame)
|
||||||
|
|
||||||
if ret:
|
if ret:
|
||||||
with open(
|
with open(
|
||||||
@ -107,7 +107,7 @@ class ExternalEventProcessor:
|
|||||||
height = box["box"][3] * camera_config.detect.height
|
height = box["box"][3] * camera_config.detect.height
|
||||||
|
|
||||||
draw_box_with_label(
|
draw_box_with_label(
|
||||||
img_bytes,
|
img_frame,
|
||||||
x,
|
x,
|
||||||
y,
|
y,
|
||||||
x + width,
|
x + width,
|
||||||
@ -118,11 +118,17 @@ class ExternalEventProcessor:
|
|||||||
color=box.get("color", (255, 0, 0)),
|
color=box.get("color", (255, 0, 0)),
|
||||||
)
|
)
|
||||||
|
|
||||||
ret, jpg = cv2.imencode(".jpg", img_bytes)
|
ret, jpg = cv2.imencode(".jpg", img_frame)
|
||||||
with open(
|
with open(
|
||||||
os.path.join(CLIPS_DIR, f"{camera_config.name}-{event_id}.jpg"),
|
os.path.join(CLIPS_DIR, f"{camera_config.name}-{event_id}.jpg"),
|
||||||
"wb",
|
"wb",
|
||||||
) as j:
|
) as j:
|
||||||
j.write(jpg.tobytes())
|
j.write(jpg.tobytes())
|
||||||
|
|
||||||
|
# create thumbnail with max height of 175 and save
|
||||||
|
width = int(175 * img_frame.shape[1] / img_frame.shape[0])
|
||||||
|
thumb = cv2.resize(
|
||||||
|
img_frame, dsize=(width, 175), interpolation=cv2.INTER_AREA
|
||||||
|
)
|
||||||
|
ret, jpg = cv2.imencode(".jpg", thumb)
|
||||||
return base64.b64encode(jpg.tobytes()).decode("utf-8")
|
return base64.b64encode(jpg.tobytes()).decode("utf-8")
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user