From 082d3b928cf961e649fa521c095627a8546d2ad6 Mon Sep 17 00:00:00 2001 From: Ludo Date: Mon, 13 Nov 2023 13:25:51 +0100 Subject: [PATCH] Add JPEG quality parameter to camera capture --- test.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test.py b/test.py index dc2b5c4..ab32c0c 100644 --- a/test.py +++ b/test.py @@ -13,6 +13,7 @@ def send_frames(ws): global should_send_frames, running camera = PiCamera() camera.resolution = (1920, 1080) + jpeg_quality = 85 stream = io.BytesIO() while running: @@ -20,7 +21,8 @@ def send_frames(ws): time.sleep(0.1) continue - camera.capture(stream, format='jpeg', use_video_port=True) + camera.capture(stream, format='jpeg', + use_video_port=True, quality=jpeg_quality) if should_send_frames: stream.seek(0) buffer = stream.read() @@ -29,8 +31,6 @@ def send_frames(ws): stream.seek(0) stream.truncate() - time.sleep(0.05) # Control frame rate - camera.close() print("Camera released and thread terminating...")