Microscope capture objects now just handle on-disk data

This commit is contained in:
Joel Collins 2019-09-16 16:35:32 +01:00
parent a832dfb2f1
commit dc794d4df8
10 changed files with 125 additions and 311 deletions

View file

@ -90,24 +90,18 @@ class MockStreamer(BaseCamera):
Args:
config (dict): Dictionary of config parameters.
"""
paused_stream = False
logging.debug("PiCameraStreamer: Applying config:")
logging.debug("MockStreamer: Applying config:")
logging.debug(config)
with self.lock:
# Apply valid config params to Picamera object
# Apply valid config params to camera object
if not self.state["record_active"]: # If not recording a video
# PiCameraStreamer parameters
for key, value in config.items(): # For each provided setting
if hasattr(self, key):
setattr(self, key, value)
# If stream was paused to update config, unpause
if paused_stream:
logging.info("Resuming stream.")
else:
raise Exception(
"Cannot update camera config while recording is active."
@ -135,7 +129,7 @@ class MockStreamer(BaseCamera):
Start a new video recording, writing to a output object.
Args:
output (CaptureObject/str): Output object to write data bytes to.
output: String or file-like object to write capture data to
fmt (str): Format of the capture.
quality (int): Video recording quality.
@ -167,7 +161,7 @@ class MockStreamer(BaseCamera):
Target object can be overridden for development purposes.
Args:
output (CaptureObject/str): Output object to write data bytes to.
output: String or file-like object to write capture data to
use_video_port (bool): Capture from the video port used for streaming. Lower resolution, faster.
fmt (str): Format of the capture.
resize ((int, int)): Resize the captured image.
@ -175,7 +169,12 @@ class MockStreamer(BaseCamera):
"""
with self.lock:
logging.warning("Capture not implemented in mock camera")
if isinstance(output, str):
output = open(output, 'wb')
output.write(self.stream.getvalue())
output.close()
# HANDLE STREAM FRAMES