Skip to content

Commit 38d0325

Browse files
committed
Changes after tests with hardware.
Fixed ClarityProcessor import and conversion of UMat to ndarray.
1 parent f8543a2 commit 38d0325

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

microscope/filterwheels/aurox.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@
3838
import microscope.devices
3939
from typing import Mapping
4040
from enum import IntEnum
41+
try:
42+
# Currently, clarity_process is a module that is not packaged, so needs
43+
# to be put on the python path somewhere manually.
44+
from clarity_process import ClarityProcessor
45+
except:
46+
_logger.warning("Could not import clarity_process module: no processing available.")
4147

4248
_logger = logging.getLogger(__name__)
4349

@@ -126,12 +132,7 @@ def __init__(self, camera=None, **kwargs) -> None:
126132
self._cam = camera(**cam_kwargs)
127133
self._cam.pipeline.append(self._c_process_data)
128134
# Is processing available?
129-
self._can_process = False
130-
try:
131-
from clarity_process import ClarityProcessor
132-
self._can_process = True
133-
except:
134-
_logger.warning("Could not import clarity_process module: no processing available.")
135+
self._can_process = 'ClarityProcessor' in globals()
135136
# Data processor object, created after calibration
136137
self._processor = None
137138
# Acquisition mode
@@ -156,11 +157,11 @@ def _c_process_data(self, data):
156157
elif self._mode == Mode.difference:
157158
if self._processor is None:
158159
raise Exception("Not calibrated yet - can not process image")
159-
return self._processor.process(data)
160+
return self._processor.process(data).get() # get converts UMat to ndarray.
160161
elif self._mode == Mode.calibrate:
161162
# This will introduce a significant delay, but returning the
162163
# image indicates that the calibration step is complete.
163-
self._processor = clarity_process.ClarityProcessor(data)
164+
self._processor = ClarityProcessor(data)
164165
return data
165166
else:
166167
raise Exception("Unrecognised mode: %s", self._mode)

0 commit comments

Comments
 (0)