Posts: 18
Joined: Mon Sep 28, 2015 4:50 pm

how to name pictures and skip delay in picamera

Fri Oct 02, 2015 10:13 am

hi I have 2 questions about the raspberry pi camera using python,

first one is I want to make an infinite loop to take pictures on the mark of a push button, now I know how to do that, my question is how to make python auto generate name the pictures, like image1.jpg,image2.jpg,..... my program at the end should be me pushing first push, take picture and name it image1, then pushing second time to take second picture and name it image2 and so on.

second question is how do I skip the 5 second delay the camera takes before taking a picture, I want the camera to take the picture instantly when I push the button.

be patient with me please I am a beginner.

Posts: 5277
Joined: Sun Aug 05, 2012 3:12 pm

Re: how to name pictures and skip delay in picamera

Fri Oct 02, 2015 5:34 pm

If using raspistill for time-lapse you can automatically name them

raspistill -o myimage_%04d.jpg -tl 60000 -t 7200000

Or for individual images create a name eg

DATE=$(date +"%Y-%m-%d_%H%M")
raspistill -o /home/pi/$DATE.jpg

Or maybe

i= 0
while i< 9:
raspistill -t 2000 -o /home/pi/"image" +str(I) +".jpg"
i +=1

You can minimise the delay by setting -t to a smaller value but not less that 500

User avatar
Posts: 235
Joined: Sun Aug 19, 2012 11:19 am
Location: Cambridgeshire, UK
Contact: Website Twitter

Re: how to name pictures and skip delay in picamera

Mon Oct 05, 2015 10:43 pm

We have a learning resource for exactly this project. See Push Button Stop Motion.

The gist of the code is:

Code: Select all

with picamera.PiCamera() as camera:
    frame = 1
    while True:
        GPIO.wait_for_edge(button, GPIO.FALLING)
        camera.capture('/home/pi/animation/frame%03d.jpg' % frame)
        frame += 1
Former RPF staff. Author of gpiozero and creator of piwheels.

Return to “Python”