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:
parent
42b4c1246e
commit
adbb805556
7 changed files with 76 additions and 68 deletions
|
|
@ -21,10 +21,10 @@ from labthings_fastapi.dependencies.metadata import GetThingStates
|
|||
from labthings_fastapi.outputs.mjpeg_stream import MJPEGStreamDescriptor
|
||||
from labthings_fastapi.types.numpy import NDArray
|
||||
|
||||
from . import Camera, JPEGBlob
|
||||
from . import BaseCamera, JPEGBlob
|
||||
|
||||
|
||||
class OpenCVCamera(Camera):
|
||||
class OpenCVCamera(BaseCamera):
|
||||
"""A Thing representing an OpenCV camera"""
|
||||
def __init__(self, camera_index: int=0):
|
||||
self.camera_index = camera_index
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue