Skip to content

Commit

Permalink
Set thumbnail height to 175
Browse files Browse the repository at this point in the history
  • Loading branch information
NickM-27 committed May 18, 2023
1 parent 028c117 commit 9e2f9a9
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions frigate/events/external.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,11 @@ def _write_images(
label: str,
event_id: str,
draw: dict[str, any],
img_bytes: any,
img_frame: any,
) -> str:
# write clean snapshot if enabled
if camera_config.snapshots.clean_copy:
ret, png = cv2.imencode(".png", img_bytes)
ret, png = cv2.imencode(".png", img_frame)

if ret:
with open(
Expand All @@ -107,7 +107,7 @@ def _write_images(
height = box["box"][3] * camera_config.detect.height

draw_box_with_label(
img_bytes,
img_frame,
x,
y,
x + width,
Expand All @@ -118,11 +118,17 @@ def _write_images(
color=box.get("color", (255, 0, 0)),
)

ret, jpg = cv2.imencode(".jpg", img_bytes)
ret, jpg = cv2.imencode(".jpg", img_frame)
with open(
os.path.join(CLIPS_DIR, f"{camera_config.name}-{event_id}.jpg"),
"wb",
) as j:
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")

0 comments on commit 9e2f9a9

Please sign in to comment.