diff --git a/src/picam/picam1.py b/src/picam/picam1.py index 263778f..8c75d77 100644 --- a/src/picam/picam1.py +++ b/src/picam/picam1.py @@ -1,5 +1,6 @@ -from picam import PiCam +from src.picam import PiCam +from io import BytesIO from picamera import PiCamera class PiCam1(PiCam): @@ -36,12 +37,17 @@ class PiCam1(PiCam): def capture(self, preview: bool = False) -> bytes: # Bytes to hold output buffer out = bytes() + bytes_stream = BytesIO() if not preview: # If preview we'll already have the right resolution self.set_camera_resolution(self.capture_resolution) - self.camera.capture(out, format='rgb', use_video_port=preview) + self.camera.capture(bytes_stream, format='rgb', use_video_port=preview) + + bytes_stream.seek(0) + bytes_stream.readinto(out) + bytes_stream.close() if not preview: # If preview we'll already have the right resolution