@@ -131,7 +131,11 @@ def HW_trigger(self, channel):
131131 """Function called by GPIO interupt, needs to trigger image capture"""
132132 with picamera .array .PiYUVArray (self .camera ) as output :
133133 self .camera .capture (output , format = "yuv" , use_video_port = False )
134- self ._queue .put (output .array [:, :, 0 ])
134+ self ._queue .put (
135+ output .array [
136+ self .roi .top : self .roi .top + self .roi .height ,
137+ self .roi .left : self .roi .left + self .roi .width ,
138+ 0 ,])
135139
136140 def _fetch_data (self ):
137141 if self ._queue .qsize () is not 0 :
@@ -161,7 +165,7 @@ def initialize(self):
161165 self .set_awb_mode (0 ) # set auto white balance to off
162166 self ._get_sensor_shape ()
163167 #default to full image at init.
164- self ._set_roi (ROI (0 , 0 , self .self . camera .resolution .width ,
168+ self ._set_roi (ROI (0 , 0 , self .camera .resolution .width ,
165169 self .camera .resolution .height ))
166170
167171
@@ -239,6 +243,13 @@ def setLED(self, state=False):
239243 GPIO .output (GPIO_CAMLED , state )
240244
241245 def set_exposure_time (self , value ):
246+ # frame rate has to be adjusted as well as max exposure time is
247+ # 1/framerate.
248+ #picam v1.3 I have has limit 1/6 to 90 fps
249+ #exposure time can be shorter than frame rate bound but not longer
250+ value = min (value , 6.0 )
251+ fr = max (value , 1.0 / 90.0 )
252+ self .set_framerate (1.0 / fr )
242253 # exposure times are set in us.
243254 self .camera .shutter_speed = int (value * 1.0e6 )
244255
@@ -249,8 +260,21 @@ def get_exposure_time(self):
249260 def get_cycle_time (self ):
250261 # fudge to make it work initially
251262 # exposure times are in us, so multiple by 1E-6 to get seconds.
252- return self .camera .exposure_speed * 1.0e-6 + 0.1
263+ # pi 4 camera module v 1.3 minimum reliable time to capture and
264+ # download a frame appears to be .7 s.
265+ return self .camera .exposure_speed * 1.0e-6 + 0.7
253266
267+
268+ def get_framerate (self ):
269+ return (float (self .camera .framerate ))
270+
271+
272+ def set_framerate (self , rate ):
273+ # rate= max (rate, self.camera.framerate_range.low)
274+ # rate= min (rate, self.camera.framerate_range.high)
275+ self .camera .framerate = rate
276+ return (float (self .camera .framerate ))
277+
254278 def _get_sensor_shape (self ):
255279 if self .camversion == "ov5647" : # picam version 1
256280 self .camera .resolution = (2592 , 1944 )
@@ -292,7 +316,9 @@ def soft_trigger(self):
292316# should be able to use rotation and hflip to set specific output image
293317# rotations
294318
295- # roi's can be set with the zoom function, default is (0,0,1,1) meaning all the data.
319+ # roi's can be set with the zoom function, default is (0,0,1,1)
320+ # meaning all the data. However this is no help as the grab is still
321+ # just as slow
296322
297323# Need to setup a buffer for harware triggered data aquisition so we can
298324# call the acquisition and then download the data at our leasure
0 commit comments