Revision as of 05:20, 27 July 2012 by hamishwillee (Talk | contribs)

Archived:Take a photo at regular intervals using PySymbian

From Nokia Developer Wiki
Jump to: navigation, search
Article Metadata
Created: cyke64 (02 Oct 2007)
Last edited: hamishwillee (27 Jul 2012)

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"
print "Photo %d saved\n" %(d)
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.

46 page views in the last 30 days.