From ddaa746807d7992d47d2eabe56bf06e10e6fd093 Mon Sep 17 00:00:00 2001 From: Blake Blackshear Date: Fri, 24 Apr 2020 07:48:19 -0500 Subject: [PATCH] resize to aspect ratio of frame --- detect_objects.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/detect_objects.py b/detect_objects.py index 6d77452b6..b5e8b1fac 100644 --- a/detect_objects.py +++ b/detect_objects.py @@ -328,7 +328,9 @@ def main(): if frame is None: frame = np.zeros((height,int(height*16/9),3), np.uint8) - frame = cv2.resize(frame, dsize=(int(height*16/9), height), interpolation=cv2.INTER_LINEAR) + width = int(height*frame.shape[1]/frame.shape[0]) + + frame = cv2.resize(frame, dsize=(width, height), interpolation=cv2.INTER_LINEAR) frame = cv2.cvtColor(frame, cv2.COLOR_RGB2BGR) ret, jpg = cv2.imencode('.jpg', frame)