Skip to content

Commit 6a4ee44

Browse files
committed
Fix picamera roi code to use the ROI named tuples and then just return roi #279
1 parent 76a6364 commit 6a4ee44

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

microscope/cameras/picamera.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -226,9 +226,9 @@ def _get_binning(self):
226226
return Binning(1, 1)
227227

228228
@keep_acquiring
229-
def _set_roi(self, left, top, width, height):
230-
"""Set the ROI to (left, tip, width, height)."""
231-
self.roi = ROI(left, top, width, height)
229+
def _set_roi(self, region):
230+
"""Set the ROI to the name tuple ROI(left, top, width, height)."""
231+
self.roi = region
232232

233233
# set camera LED status, off is best for microscopy.
234234
def setLED(self, state=False):
@@ -252,7 +252,7 @@ def _get_sensor_shape(self):
252252
self.camera.resolution = (2592, 1944)
253253
# faqll back to defualt if not set above.
254254
res = self.camera.resolution
255-
self._set_roi(0, 0, res[0], res[1])
255+
self._set_roi(ROI(0, 0, res[0], res[1]))
256256
return res
257257

258258
def _do_trigger(self):
@@ -265,7 +265,8 @@ def soft_trigger(self):
265265
if self._acquiring:
266266
with picamera.array.PiYUVArray(self.camera) as output:
267267
self.camera.capture(output, format="yuv", use_video_port=False)
268-
self._queue.put(output.array[:, :, 0])
268+
self._queue.put(output.array[self.roi[1]:self.roi[1]+self.roi[3],
269+
self.roi[0]:self.roi[0]+self.roi[2], 0])
269270

270271

271272
# ongoing implemetation notes

0 commit comments

Comments
 (0)