Skip to content

Commit

Permalink
Add JPEG quality parameter to camera capture
Browse files Browse the repository at this point in the history
  • Loading branch information
infinitel8p committed Nov 13, 2023
1 parent 2a639c2 commit 082d3b9
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions test.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,16 @@ def send_frames(ws):
global should_send_frames, running
camera = PiCamera()
camera.resolution = (1920, 1080)
jpeg_quality = 85
stream = io.BytesIO()

while running:
if not should_send_frames:
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()
Expand All @@ -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...")

Expand Down

0 comments on commit 082d3b9

Please sign in to comment.