Formal Protocol for camera interface

I've now split the base camera code into a runtime-checkable Protocol
and a concrete base class (which is optional). This removes the requirement
for cameras to subclass `openflexure_microscope.things.camera.Camera`
and instead uses duck typing that should
work both statically and dynamically.

As part of this, I've moved the commonly-used dependencies
on the camera inside `openflexure_microscope.things.camera` for consistency, and to make it easy to update them if it changes in the future.
This commit is contained in:
Richard Bowman 2024-11-29 11:26:38 +00:00
parent 42b4c1246e
commit adbb805556
7 changed files with 76 additions and 68 deletions

View file

@ -24,11 +24,11 @@ from labthings_fastapi.outputs.mjpeg_stream import MJPEGStreamDescriptor
from labthings_fastapi.types.numpy import NDArray
from labthings_fastapi.server import ThingServer
from . import Camera, JPEGBlob
from . import BaseCamera, JPEGBlob
from ..stage import Stage
class SimulatedCamera(Camera):
class SimulatedCamera(BaseCamera):
"""A Thing representing an OpenCV camera"""
shape = (600, 800, 3)
glyph_shape = (51, 51, 3)