Archived:Take a photo at regular intervals using PySymbian
Article Metadata
Here is a code that will help to take photos from a camera at regular intervals.This interval can be set as required by the developer.
import e32, camera
path = "c:\\tmp.jpg"
def capture():
img = camera.take_photo()
img.save( path )
d = 0
while True:
print "Wait"
e32.ao_sleep(3)
capture()
print "Photo %d saved\n" %(d)
d+=1
print "Session Ended"
The loop in the code is a forever loop.This loop can be modified according to the condition required by the developer. The above code clicks a new image from the camera at a regular interval of 3 seconds. This interval can also be modified by changing the argument in the statement
e32.ao_sleep(3) Which is a delay introduced.
Also It can be observed that the images are saved with the same name with the above code.
Also provision can be made to save the images with different name.There are several formats for naming.
One such format is to save the image with the date in the file name.The following code an be used for the same.
from time import ctime
your_path="C:\\image "
def capture():
img = camera.take_photo()
img.save( your_path + ctime + ".jpg")
#this saves the picture in jpg format with a date in the filename
Both the codes can be appropriately combined to have the required code to capture photos from the camera at regular intervals and to save them to a desired location with the desired different file name.

