Optimised captures by using greenlets for disk IO

This commit is contained in:
Joel Collins 2020-06-11 11:42:31 +01:00
parent 1a0ede609d
commit 7c9f42f7f3
8 changed files with 86 additions and 41 deletions

View file

@ -197,19 +197,14 @@ class MissingCamera(BaseCamera):
bayer (bool): Store raw bayer data in capture
"""
if isinstance(output, CaptureObject):
target = output.file
else:
target = output
with self.lock:
if isinstance(target, str):
target = open(target, "wb")
if isinstance(output, str):
output = open(output, "wb")
target.write(self.stream.getvalue())
output.write(self.stream.getvalue())
if isinstance(target, str):
target.close()
if isinstance(output, str):
output.close()
# HANDLE STREAM FRAMES

View file

@ -115,11 +115,6 @@ class PiCameraStreamer(BaseCamera):
"picamera_lst.npy"
) #: str: Path of .npy lens shading table file
# Create an empty stream
self.stream = io.BytesIO()
# Start streaming
self.start_worker()
@property
def configuration(self):
@ -520,12 +515,6 @@ class PiCameraStreamer(BaseCamera):
Returns:
output_object (str/BytesIO): Target object.
"""
if isinstance(output, CaptureObject):
target = output.file
else:
target = output
with self.lock:
logging.info("Capturing to {}".format(output))
@ -535,20 +524,20 @@ class PiCameraStreamer(BaseCamera):
time.sleep(0.1)
self.camera.capture(
target,
output,
format=fmt,
quality=100,
resize=resize,
bayer=(not use_video_port) and bayer,
use_video_port=use_video_port,
)
time.sleep(0.1)
#time.sleep(0.1)
# Set resolution and start stream recording if necessary
if not use_video_port:
self.start_stream_recording()
return target
return output
def yuv(
self, use_video_port: bool = True, resize: Tuple[int, int] = None