From 75c052ff4e2796cde18c2d0849ec4ddf3fc9a247 Mon Sep 17 00:00:00 2001 From: Nick Mowen Date: Tue, 20 Jun 2023 06:39:13 -0600 Subject: [PATCH] Catch cases where incorrect size is requested --- frigate/http.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/frigate/http.py b/frigate/http.py index b4813c1f2..f72f15c38 100644 --- a/frigate/http.py +++ b/frigate/http.py @@ -1100,6 +1100,15 @@ def latest_frame(camera_name): height = int(request.args.get("h", str(frame.shape[0]))) width = int(height * frame.shape[1] / frame.shape[0]) + if not frame: + return "Unable to get valid frame from {}".format(camera_name), 500 + + if height < 1 or width < 1: + return ( + "Invalid height / width requested :: {} / {}".format(height, width), + 400, + ) + frame = cv2.resize(frame, dsize=(width, height), interpolation=cv2.INTER_AREA) ret, jpg = cv2.imencode(