Blackened files
This commit is contained in:
parent
be5ddb76ae
commit
4e7606aa0c
24 changed files with 200 additions and 120 deletions
|
|
@ -120,15 +120,10 @@ class BaseCamera(metaclass=ABCMeta):
|
|||
self.stream_timeout = 20
|
||||
self.stream_timeout_enabled = False
|
||||
|
||||
self.state = {
|
||||
"board": None
|
||||
}
|
||||
self.state = {"board": None}
|
||||
|
||||
# TODO: Load/save these to config
|
||||
self.paths = {
|
||||
"default": BASE_CAPTURE_PATH,
|
||||
"temp": TEMP_CAPTURE_PATH
|
||||
}
|
||||
self.paths = {"default": BASE_CAPTURE_PATH, "temp": TEMP_CAPTURE_PATH}
|
||||
|
||||
# Capture data
|
||||
self.images = []
|
||||
|
|
@ -296,7 +291,7 @@ class BaseCamera(metaclass=ABCMeta):
|
|||
output = CaptureObject(filepath=filepath)
|
||||
# Insert a temporary tag if temporary
|
||||
if temporary:
|
||||
output.put_tags(['temporary'])
|
||||
output.put_tags(["temporary"])
|
||||
|
||||
# Update capture list
|
||||
self.images.append(output)
|
||||
|
|
@ -339,7 +334,7 @@ class BaseCamera(metaclass=ABCMeta):
|
|||
output = CaptureObject(filepath=filepath)
|
||||
# Insert a temporary tag if temporary
|
||||
if temporary:
|
||||
output.put_tags(['temporary'])
|
||||
output.put_tags(["temporary"])
|
||||
|
||||
# Update capture list
|
||||
self.videos.append(output)
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ def pull_usercomment_dict(filepath):
|
|||
try:
|
||||
exif_dict = piexif.load(filepath)
|
||||
except InvalidImageDataError:
|
||||
logging.error("Invalid data at {}. Skipping.".format(filepath))
|
||||
logging.warning("Invalid data at {}. Skipping.".format(filepath))
|
||||
return None
|
||||
if "Exif" in exif_dict and 37510 in exif_dict["Exif"]:
|
||||
return yaml.load(exif_dict["Exif"][37510].decode())
|
||||
|
|
@ -316,4 +316,4 @@ class CaptureObject(object):
|
|||
return False
|
||||
|
||||
def close(self):
|
||||
pass
|
||||
pass
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ import logging
|
|||
# Type hinting
|
||||
from typing import Tuple
|
||||
|
||||
from .base import BaseCamera, CaptureObject
|
||||
from openflexure_microscope.camera.base import BaseCamera
|
||||
|
||||
|
||||
# MAIN CLASS
|
||||
|
|
@ -26,11 +26,9 @@ class MockStreamer(BaseCamera):
|
|||
BaseCamera.__init__(self)
|
||||
|
||||
# Store state of PiCameraStreamer
|
||||
self.state.update({
|
||||
"stream_active": False,
|
||||
"record_active": False,
|
||||
"board": None
|
||||
})
|
||||
self.state.update(
|
||||
{"stream_active": False, "record_active": False, "board": None}
|
||||
)
|
||||
|
||||
# Update config properties
|
||||
self.image_resolution = (1312, 976)
|
||||
|
|
@ -57,7 +55,12 @@ class MockStreamer(BaseCamera):
|
|||
)
|
||||
|
||||
draw = ImageDraw.Draw(image)
|
||||
draw.text((20, 70), "Camera disconnected: {}".format(datetime.now().strftime("%d/%m/%Y, %H:%M:%S")))
|
||||
draw.text(
|
||||
(20, 70),
|
||||
"Camera disconnected: {}".format(
|
||||
datetime.now().strftime("%d/%m/%Y, %H:%M:%S")
|
||||
),
|
||||
)
|
||||
|
||||
image.save(self.stream, format="JPEG")
|
||||
|
||||
|
|
@ -80,12 +83,14 @@ class MockStreamer(BaseCamera):
|
|||
conf_dict = BaseCamera.read_config(self)
|
||||
|
||||
# Include device-specific config items
|
||||
conf_dict.update({
|
||||
"stream_resolution": self.stream_resolution,
|
||||
"image_resolution": self.image_resolution,
|
||||
"numpy_resolution": self.numpy_resolution,
|
||||
"jpeg_quality": self.jpeg_quality,
|
||||
})
|
||||
conf_dict.update(
|
||||
{
|
||||
"stream_resolution": self.stream_resolution,
|
||||
"image_resolution": self.image_resolution,
|
||||
"numpy_resolution": self.numpy_resolution,
|
||||
"jpeg_quality": self.jpeg_quality,
|
||||
}
|
||||
)
|
||||
|
||||
return conf_dict
|
||||
|
||||
|
|
@ -179,7 +184,7 @@ class MockStreamer(BaseCamera):
|
|||
|
||||
with self.lock:
|
||||
if isinstance(output, str):
|
||||
output = open(output, 'wb')
|
||||
output = open(output, "wb")
|
||||
|
||||
output.write(self.stream.getvalue())
|
||||
|
||||
|
|
|
|||
|
|
@ -66,12 +66,14 @@ class PiCameraStreamer(BaseCamera):
|
|||
) #: :py:class:`picamera.PiCamera`: Picamera object
|
||||
|
||||
# Store state of PiCameraStreamer
|
||||
self.state.update({
|
||||
"stream_active": False,
|
||||
"record_active": False,
|
||||
"preview_active": False,
|
||||
"board": f"picamera_{self.camera.revision}",
|
||||
})
|
||||
self.state.update(
|
||||
{
|
||||
"stream_active": False,
|
||||
"record_active": False,
|
||||
"preview_active": False,
|
||||
"board": f"picamera_{self.camera.revision}",
|
||||
}
|
||||
)
|
||||
|
||||
# Reset variable states
|
||||
self.set_zoom(1.0)
|
||||
|
|
@ -113,13 +115,15 @@ class PiCameraStreamer(BaseCamera):
|
|||
conf_dict = BaseCamera.read_config(self)
|
||||
|
||||
# Include device-specific config items
|
||||
conf_dict.update({
|
||||
"stream_resolution": self.stream_resolution,
|
||||
"image_resolution": self.image_resolution,
|
||||
"numpy_resolution": self.numpy_resolution,
|
||||
"jpeg_quality": self.jpeg_quality,
|
||||
"picamera_settings": {},
|
||||
})
|
||||
conf_dict.update(
|
||||
{
|
||||
"stream_resolution": self.stream_resolution,
|
||||
"image_resolution": self.image_resolution,
|
||||
"numpy_resolution": self.numpy_resolution,
|
||||
"jpeg_quality": self.jpeg_quality,
|
||||
"picamera_settings": {},
|
||||
}
|
||||
)
|
||||
|
||||
# Include a subset of picamera properties
|
||||
# TODO: Expand this subset so we have more metadata?
|
||||
|
|
@ -333,7 +337,7 @@ class PiCameraStreamer(BaseCamera):
|
|||
return output
|
||||
|
||||
else:
|
||||
logging.error(
|
||||
logging.warning(
|
||||
"Cannot start a new recording\
|
||||
until the current recording has stopped."
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue