-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MicroscopeCamera: add option to set default ROI (#837)
- Loading branch information
1 parent
04d217d
commit 1285b9f
Showing
1 changed file
with
25 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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() | ||
|
@@ -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() | ||
|