I am working with the Raspberry Pi camera and need some help regarding the python script. I need to capture a set of 5 images continuously every 5 minutes interval until I want it to stop. This set of images will be captured with increment in the shutter speed.

Right now, I only have the script written for capturing 5 images.

from picamera import PiCamera
from time import sleep

camera.resolution=(1024, 768)
camera.start_preview(fullscreen=False, window=(100,200,500,600))
camera.capture_sequence(['image%02d.jpg' % i for i in range (5)])  

Please let me know how to set of images continuously with range of shutter speed. Thanks in advance.


3 Answers 3


If I've understood correctly, you want to capture 5 images, each with a different shutter speed, wait five minutes, and then repeat. In that case, capture_sequence isn't applicable as it would capture all frames with the same shutter speed.

In that case, the code you want should look something like this:

from picamera import PiCamera
from time import sleep

camera.resolution=(1024, 768)
camera.start_preview(fullscreen=False, window=(100,200,500,600))

at = 1 # keep track of the current image
while True:
    for shutterspeed in range(250,1500,250): # use shutterspeeds of 250, 500, 750, 1000, and 1250 microseconds, set this to the range of values you're interested in
        camera.shutter_speed = shutterspeed # set the shutter speed to this many microseconds
        sleep(2) # documentation suggests a short 2 second delay for the sensor to adjust
        camera.capture('image%05d.jpg' % at) # save the image in the current folder with 5 leading zeros in the filename
        at = at + 1 # increment the image number
    sleep(5*60) # wait 5 minutes

  • Hey, Thank you for your response. I have tried this script and it captures only one image after every 5 minutes. But I would like to capture 5 sets of images, each with different shutter speed, wait for minutes and then repeat to capture another 5 set of images. Thanks.
    – Bemche
    Sep 23, 2019 at 18:20
  • You should get 5 images every 5 minutes. ls -ltr for me clearly shows image00001.jpg to image00005.jpg taken at 11:19 and image00006.jpg to image00010.jpg taken at 11:24. The images may not look very different though due to the shutterspeeds being so similar. Try changing for shutterspeed in range(250,1500,250) to for shutterspeed in range(500,4500,500) for a wider range of shutter speeds, which should give more different images.
    – Fred
    Sep 24, 2019 at 11:28

I'm trying also to do some HDR images to acquire at the end a whole 8 or super8 film. Every picture of the film will be acquired with different stops. Here the code that I have already tested and that works fine:

from picamera import PiCamera
from time import sleep
from fractions import Fraction

camera = PiCamera()
camera.rotation = 180
camera.resolution = (3280,2464)
camera.framerate= 1/1
exposure = camera.exposure_speed
camera.exposure_mode = 'off'
while i < 4:
    camera.shutter_speed = exposure * 2**i
    camera.shutter_speed = int (exposure / 2**i)

First I take an image at EV0 and I save the exposure_speed so that I know the EV0 value. After that, I change the shutter_speed so that I have under- and over-exposed pictures


Gian Carlo


The task could be run every five minutes using cron.

Save your script as (e.g) /home/pi/mycapture.py

crontab -e

Then add

*/5 * * * * python /home/pi/mycapture.py

You would need a date/time stamp in the filename to avoid overwriting.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.