diff --git a/openflexure_microscope/camera/pi.py b/openflexure_microscope/camera/pi.py index 4b2a15bf..13f26cd5 100644 --- a/openflexure_microscope/camera/pi.py +++ b/openflexure_microscope/camera/pi.py @@ -565,15 +565,20 @@ class PiCameraStreamer(BaseCamera): # While the iterator is not closed try: while True: - # reset stream for next frame + # Reset the stream for the next frame self.stream.seek(0) self.stream.truncate() - # to stream, read the new frame + # Sleep for the approximate camera framerate time.sleep(1 / self.camera.framerate * 0.1) - # yield the result to be read + # Get the latest frame data from the stream frame = self.stream.getvalue() - # ensure the size of package is right + # This loop iterates faster than the PiCamera will collect + # frames. On iterations between frames, the buffer will be + # empty (because we truncated it earlier). In these cases + # we just pass and loop again until a frame is actually present. + # This also means that the size of FrameStream is always 1 frame, + # since we truncate it here before a new frame can be appended. if len(frame) == 0: pass else: