Improvements to properties and docstrings
This commit is contained in:
parent
4d9669f8ae
commit
0e1d9cca18
3 changed files with 29 additions and 10 deletions
|
|
@ -265,7 +265,7 @@ class JPEGSharpnessMonitor:
|
||||||
stage: BaseStage,
|
stage: BaseStage,
|
||||||
camera: BaseCamera,
|
camera: BaseCamera,
|
||||||
method: SharpnessMethod = SharpnessMethod.JPEG,
|
method: SharpnessMethod = SharpnessMethod.JPEG,
|
||||||
record: Optional[SharpnessMethod] = None,
|
record: Optional[int] = None,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Initialise a new JPEGSharpnessMonitor. The args are injected automatically.
|
"""Initialise a new JPEGSharpnessMonitor. The args are injected automatically.
|
||||||
|
|
||||||
|
|
@ -355,7 +355,7 @@ class JPEGSharpnessMonitor:
|
||||||
|
|
||||||
# FocusFoM metric
|
# FocusFoM metric
|
||||||
if self.record & SharpnessMethod.FOCUS_FOM:
|
if self.record & SharpnessMethod.FOCUS_FOM:
|
||||||
self._focus_foms.append(self.camera._focus_fom)
|
self._focus_foms.append(self.camera.focus_fom)
|
||||||
|
|
||||||
if not self.running:
|
if not self.running:
|
||||||
break
|
break
|
||||||
|
|
@ -487,7 +487,7 @@ class AutofocusThing(lt.Thing):
|
||||||
dz: int = 2000,
|
dz: int = 2000,
|
||||||
start: Literal["centre", "base"] = "centre",
|
start: Literal["centre", "base"] = "centre",
|
||||||
sharpness_metric: SharpnessMethod = SharpnessMethod.JPEG,
|
sharpness_metric: SharpnessMethod = SharpnessMethod.JPEG,
|
||||||
record: Optional[SharpnessMethod] = None,
|
record: Optional[int] = None,
|
||||||
) -> SharpnessDataArrays:
|
) -> SharpnessDataArrays:
|
||||||
"""Sweep the stage up and down, then move to the sharpest point.
|
"""Sweep the stage up and down, then move to the sharpest point.
|
||||||
|
|
||||||
|
|
@ -499,10 +499,11 @@ class AutofocusThing(lt.Thing):
|
||||||
:param start: Starting position of the sweep. "centre" begins at -dz/2,
|
:param start: Starting position of the sweep. "centre" begins at -dz/2,
|
||||||
while "base" begins from the current position.
|
while "base" begins from the current position.
|
||||||
:param sharpness_metric: Sharpness metric used for evaluation. Either
|
:param sharpness_metric: Sharpness metric used for evaluation. Either
|
||||||
JPEG file size (JPEG) or inbuilt figure of metric (FOCUS_FOM).
|
JPEG file size (1) or inbuilt figure of metric (2).
|
||||||
:param record: Optional bitmask of sharpness metrics to record during
|
:param record: Optional bitmask of sharpness metrics to record during
|
||||||
acquisition. If None, defaults to recording only the selected
|
acquisition. Sharpness metrics can be selected as the sum of their int
|
||||||
sharpness_metric.
|
value (see sharpness_metric).
|
||||||
|
If None, defaults to recording only the selected sharpness_metric.
|
||||||
|
|
||||||
:returns: SharpnessDataArrays containing all recorded sharpness and
|
:returns: SharpnessDataArrays containing all recorded sharpness and
|
||||||
stage position data for the sweep.
|
stage position data for the sweep.
|
||||||
|
|
@ -561,7 +562,7 @@ class AutofocusThing(lt.Thing):
|
||||||
dz: int = 2000,
|
dz: int = 2000,
|
||||||
start: Literal["centre", "base"] = "centre",
|
start: Literal["centre", "base"] = "centre",
|
||||||
sharpness_metric: SharpnessMethod = SharpnessMethod.JPEG,
|
sharpness_metric: SharpnessMethod = SharpnessMethod.JPEG,
|
||||||
record: Optional[SharpnessMethod] = None,
|
record: Optional[int] = None,
|
||||||
) -> tuple[list[float], list[float]]:
|
) -> tuple[list[float], list[float]]:
|
||||||
"""Repeatedly autofocus the stage until it looks focused.
|
"""Repeatedly autofocus the stage until it looks focused.
|
||||||
|
|
||||||
|
|
@ -574,10 +575,11 @@ class AutofocusThing(lt.Thing):
|
||||||
:param start: Starting position of the sweep. "centre" begins at -dz/2,
|
:param start: Starting position of the sweep. "centre" begins at -dz/2,
|
||||||
while "base" begins from the current position.
|
while "base" begins from the current position.
|
||||||
:param sharpness_metric: Sharpness metric used for evaluation. Either
|
:param sharpness_metric: Sharpness metric used for evaluation. Either
|
||||||
JPEG file size (JPEG) or inbuilt figure of metric (FOCUS_FOM).
|
JPEG file size (1) or inbuilt figure of metric (2).
|
||||||
:param record: Optional bitmask of sharpness metrics to record during
|
:param record: Optional bitmask of sharpness metrics to record during
|
||||||
acquisition. If None, defaults to recording only the selected
|
acquisition. Sharpness metrics can be selected as the sum of their int
|
||||||
sharpness_metric.
|
value (see sharpness_metric).
|
||||||
|
If None, defaults to recording only the selected sharpness_metric.
|
||||||
|
|
||||||
:returns: SharpnessDataArrays containing all recorded sharpness and
|
:returns: SharpnessDataArrays containing all recorded sharpness and
|
||||||
stage position data for the sweep.
|
stage position data for the sweep.
|
||||||
|
|
|
||||||
|
|
@ -179,6 +179,7 @@ class BaseCamera(OFMThing):
|
||||||
mjpeg_stream = lt.outputs.MJPEGStreamDescriptor()
|
mjpeg_stream = lt.outputs.MJPEGStreamDescriptor()
|
||||||
lores_mjpeg_stream = lt.outputs.MJPEGStreamDescriptor()
|
lores_mjpeg_stream = lt.outputs.MJPEGStreamDescriptor()
|
||||||
_memory_buffer = CameraMemoryBuffer()
|
_memory_buffer = CameraMemoryBuffer()
|
||||||
|
supports_focus_fom: bool = False
|
||||||
|
|
||||||
def __init__(self, thing_server_interface: lt.ThingServerInterface) -> None:
|
def __init__(self, thing_server_interface: lt.ThingServerInterface) -> None:
|
||||||
"""Initialise the base camera, this creates the background detectors.
|
"""Initialise the base camera, this creates the background detectors.
|
||||||
|
|
@ -213,6 +214,17 @@ class BaseCamera(OFMThing):
|
||||||
"""Close hardware connection when the Thing context manager is closed."""
|
"""Close hardware connection when the Thing context manager is closed."""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@property
|
||||||
|
def focus_fom(self) -> int:
|
||||||
|
"""Return the focus figure of merit.
|
||||||
|
|
||||||
|
This returns a NotImplementedError if not supported by the camera.
|
||||||
|
To use, requires self.supports_focus_fom to be set to True.
|
||||||
|
"""
|
||||||
|
raise NotImplementedError(
|
||||||
|
"This camera does not support Figure of Merit focusing."
|
||||||
|
)
|
||||||
|
|
||||||
@lt.property
|
@lt.property
|
||||||
def calibration_required(self) -> bool:
|
def calibration_required(self) -> bool:
|
||||||
"""Whether the camera needs calibrating.
|
"""Whether the camera needs calibrating.
|
||||||
|
|
|
||||||
|
|
@ -380,6 +380,11 @@ class StreamingPiCamera2(BaseCamera):
|
||||||
f"but found {hw_sensor_model}."
|
f"but found {hw_sensor_model}."
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def focus_fom(self) -> int:
|
||||||
|
"""Return the focus figure of merit."""
|
||||||
|
return self._focus_fom
|
||||||
|
|
||||||
def _on_frame_complete(self, request: Request) -> None:
|
def _on_frame_complete(self, request: Request) -> None:
|
||||||
md = request.get_metadata()
|
md = request.get_metadata()
|
||||||
fom = md.get("FocusFoM")
|
fom = md.get("FocusFoM")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue