diff --git a/frigate/events/external.py b/frigate/events/external.py index 5e79ff57fe..42cc10e210 100644 --- a/frigate/events/external.py +++ b/frigate/events/external.py @@ -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( @@ -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, @@ -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")