Skip to content

Commit 231c5a7

Browse files
Ian Dobbieiandobbie
authored andcommitted
Added fucntion to use picamera zoom function but doesn't speed up image capture
1 parent 02c795b commit 231c5a7

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

microscope/cameras/picamera.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,10 @@ def initialize(self):
160160
self.setLED(False)
161161
self.set_awb_mode(0) # set auto white balance to off
162162
self._get_sensor_shape()
163+
#default to full image at init.
164+
self._set_roi(ROI(0, 0, self.self.camera.resolution.width,
165+
self.camera.resolution.height))
166+
163167

164168
def make_safe(self):
165169
if self._acquiring:
@@ -252,8 +256,17 @@ def _get_sensor_shape(self):
252256
self.camera.resolution = (2592, 1944)
253257
# faqll back to defualt if not set above.
254258
res = self.camera.resolution
255-
self._set_roi(ROI(0, 0, res[0], res[1]))
256-
return res
259+
return (res.width, res.height)
260+
261+
def zoom(self,roi):
262+
#picamera zoom parameter returns an roi but defined as floats and not
263+
#in pixels
264+
x=roi[0]/self.camera.resolution.width
265+
width=(roi[2])/self.camera.resolution.width
266+
y=roi[1]/self.camera.resolution.height
267+
height=(roi[3])/self.camera.resolution.height
268+
print("using roi to set zoom",roi,(x,y,width,height))
269+
self.camera.zoom=(x,y,width,height)
257270

258271
def _do_trigger(self):
259272
self.soft_trigger()

0 commit comments

Comments
 (0)