What might cause a camera capture post delay

Howdy, I have the 5647 camera, although I’m pretty sure the problem I am having isn’t camera model specific.

Right now, if I use a simple FOR loop, I can capture just over 17 images a second at a resolution of 1640x1232.

I have a hall effects switch that magnetically triggers an event to occur. That event will enable this new program to take a still photo. However, when I run this program, I can only get 1 image every 4 seconds. Its as if the computer is hanging up on something.

I realize, it could be the fault of my program, however, when I replace the camera.capture with a print to the console, the program can keep up with the trigger at about a max speed of about 26-27 trigger events, which for my applications is more than plenty.

So, I guess my question is what might cause this extra after an image is captured in the trigger event program vs the FOR-loop program? Any ideas would be appreciated.

Also, I’m not sure if there is a more appropriate forum to inquire on, please advise.

Thank you

From the phenomenon you described, it seems that every time the image is taken, the camera has to be re-initialized, which takes time, because the camera initialization requires rewriting a large number of registers.

Yeah, it seems like it is doing something like you’ve described. I think I have to approach the camera capture routine differently.


OK, waiting your great news.

Maybe someone can take a peek at this to see what I am missing.
I’m very rusty with programming and learning Python as I go.

I have a Hall Effect sensor on pin 17 and the OV5647 camera.

SO far I cobbled this together, which seems to work as I expect.

However, if I uncomment the camera.capture line, there is a significant delay to capture no more than 2 images per second at the smaller 640x480 resolution!
That being said, I expect some kind of delay, however it is taking much longer that if captured without any sensor triggering the capture.

import time
import picamera
import RPi.GPIO as GPIO

sensorPin = 17
GPIO.setup(sensorPin, GPIO.IN)
photo_width = 640 #1640
photo_height = 480 #1232
counter = 0

def how_long(start, op):
   print('%s took %.2fs' % (op, time.time() - start))
   return time.time()

def sensorCapture(channel):
   global counter, start, annotation

   if GPIO.input(channel):
      filename = 'images/image%02d.png' % counter
      print("Frame ", counter)
      start = how_long(start, 'Capture')

start = time.time()
camera = picamera.PiCamera()
camera.resolution = (photo_width, photo_height)
camera.shutter_speed = 800
camera.awb_mode = 'sunlight'
camera.iso = 60
start = how_long(start, 'Camera initialize')
camera.start_preview(fullscreen=False, window=(0, 40, 640, 480))
start = time.time()

GPIO.add_event_detect(sensorPin, GPIO.RISING, callback=sensorCapture, bouncetime=1)