Camera settings exposed in UI defined by server.
This commit is contained in:
parent
3651013440
commit
e7e3a08210
7 changed files with 159 additions and 80 deletions
|
|
@ -20,7 +20,7 @@ import piexif
|
|||
import labthings_fastapi as lt
|
||||
from labthings_fastapi.types.numpy import NDArray
|
||||
|
||||
from openflexure_microscope_server.ui import ActionButton
|
||||
from openflexure_microscope_server.ui import ActionButton, PropertyControl
|
||||
from openflexure_microscope_server.background_detect import (
|
||||
ColourChannelDetectLUV,
|
||||
BackgroundDetectAlgorithm,
|
||||
|
|
@ -487,6 +487,11 @@ class BaseCamera(lt.Thing):
|
|||
"""The calibration actions that appear only in settings panel."""
|
||||
return []
|
||||
|
||||
@lt.thing_property
|
||||
def manual_camera_settings(self) -> list[PropertyControl]:
|
||||
"""The camera settings to expose as property controls in the settings panel."""
|
||||
return []
|
||||
|
||||
# Note that the default detector name is set at init. This is over written if
|
||||
# setting is loaded from disk.
|
||||
@lt.thing_setting
|
||||
|
|
|
|||
|
|
@ -35,7 +35,12 @@ from picamera2.outputs import Output
|
|||
import labthings_fastapi as lt
|
||||
from labthings_fastapi.exceptions import NotConnectedToServerError
|
||||
|
||||
from openflexure_microscope_server.ui import ActionButton, action_button_for
|
||||
from openflexure_microscope_server.ui import (
|
||||
ActionButton,
|
||||
PropertyControl,
|
||||
action_button_for,
|
||||
property_control_for,
|
||||
)
|
||||
from . import picamera_recalibrate_utils as recalibrate_utils
|
||||
from . import BaseCamera, JPEGBlob, ArrayModel
|
||||
|
||||
|
|
@ -833,6 +838,33 @@ class StreamingPiCamera2(BaseCamera):
|
|||
),
|
||||
]
|
||||
|
||||
@lt.thing_property
|
||||
def manual_camera_settings(self) -> list[PropertyControl]:
|
||||
"""The camera settings to expose as property controls in the settings panel."""
|
||||
return [
|
||||
property_control_for(
|
||||
self,
|
||||
"exposure_time",
|
||||
label="Exposure Time (0-33251)",
|
||||
read_back=True,
|
||||
read_back_delay=1000,
|
||||
),
|
||||
property_control_for(
|
||||
self,
|
||||
"analogue_gain",
|
||||
label="Analogue Gain",
|
||||
read_back=True,
|
||||
read_back_delay=1000,
|
||||
),
|
||||
property_control_for(
|
||||
self,
|
||||
"colour_gains",
|
||||
label="Colour Gains",
|
||||
read_back=True,
|
||||
read_back_delay=1000,
|
||||
),
|
||||
]
|
||||
|
||||
@lt.thing_property
|
||||
def lens_shading_tables(self) -> Optional[LensShading]:
|
||||
"""The current lens shading (i.e. flat-field correction).
|
||||
|
|
|
|||
|
|
@ -21,7 +21,12 @@ from scipy.ndimage import gaussian_filter
|
|||
|
||||
import labthings_fastapi as lt
|
||||
|
||||
from openflexure_microscope_server.ui import ActionButton, action_button_for
|
||||
from openflexure_microscope_server.ui import (
|
||||
ActionButton,
|
||||
PropertyControl,
|
||||
action_button_for,
|
||||
property_control_for,
|
||||
)
|
||||
|
||||
from . import BaseCamera, JPEGBlob, ArrayModel
|
||||
from ..stage import BaseStage
|
||||
|
|
@ -166,7 +171,7 @@ class SimulatedCamera(BaseCamera):
|
|||
)
|
||||
|
||||
# Add noise and convert to uint8
|
||||
image += RNG.normal(scale=2, size=self.shape).astype("int16")
|
||||
image += RNG.normal(scale=self.noise_level, size=self.shape).astype("int16")
|
||||
image[image < 0] = 0
|
||||
image[image > 255] = 255
|
||||
return image.astype("uint8")
|
||||
|
|
@ -221,6 +226,8 @@ class SimulatedCamera(BaseCamera):
|
|||
return self._capture_thread.is_alive()
|
||||
return False
|
||||
|
||||
noise_level = lt.ThingProperty(float, 2.0)
|
||||
|
||||
def _capture_frames(self):
|
||||
portal = lt.get_blocking_portal(self)
|
||||
while self._capture_enabled:
|
||||
|
|
@ -306,3 +313,8 @@ class SimulatedCamera(BaseCamera):
|
|||
action_button_for(self.load_sample, submit_label="Load Sample"),
|
||||
action_button_for(self.remove_sample, submit_label="Remove Sample"),
|
||||
]
|
||||
|
||||
@lt.thing_property
|
||||
def manual_camera_settings(self) -> list[PropertyControl]:
|
||||
"""The camera settings to expose as property controls in the settings panel."""
|
||||
return [property_control_for(self, "noise_level", label="Noise Level")]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue