Skip to content

Commit

Permalink
MicroscopeCamera: add option to set default ROI (microscope-cockpit#837)
Browse files Browse the repository at this point in the history
  • Loading branch information
carandraug authored and iandobbie committed Sep 30, 2023
1 parent cf9f244 commit cb3f329
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion cockpit/devices/microscopeCamera.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,36 @@
(DEFAULTS_NONE, DEFAULTS_PENDING, DEFAULTS_SENT) = range(3)


def _config_to_ROI(roi_str: str):
return ROI(*[int(t) for t in roi_str.strip('()').split(',')])


class MicroscopeCamera(MicroscopeBase, CameraDevice):
"""A class to control remote python microscope cameras."""
"""Device class for a remote Python-Microscope camera.
The default transform and ROI can be configured, in the same
format as the one used in Python-Microscope. For example:
[south camera]
type: cockpit.devices.microscopeCamera.MicroscopeCamera
uri: PYRO:[email protected]:7003
# transform: (lr, ud, rot)
transform: (1, 0, 0)
# ROI: (left, top, width, height)
ROI: (512, 512, 128, 128)
"""
def __init__(self, name, config):
# camConfig is a dict with containing configuration parameters.
super().__init__(name, config)
self.enabled = False
self.panel = None

if 'roi' in config:
self._base_ROI = _config_to_ROI(config.get('roi'))
else:
self._base_ROI = None

def initialize(self):
# Parent class will connect to proxy
super().initialize()
Expand All @@ -66,6 +88,8 @@ def initialize(self):
pass
if self.baseTransform:
self._setTransform(self.baseTransform)
if self._base_ROI is not None:
roi = self._proxy.set_roi(self._base_ROI)

def finalizeInitialization(self):
super().finalizeInitialization()
Expand Down

0 comments on commit cb3f329

Please sign in to comment.