# KLL engineering 13.11.2013 # FROM: http://picamera.readthedocs.org/en/latest/index.html # test RPICAM python lib in Python 2.7 as system # sudo apt-get install python-pip # sudo pip install picamera # more info: # http://kll.engineering-news.org/kllfusion01/articles.php?article_id=56 # http://creativecommons.org/licenses/by-sa/3.0/ import time import picamera from datetime import datetime, timedelta def wait(): # Calculate the delay to the start of the next hour next_hour = (datetime.now() + timedelta(hour=1)).replace( minute=0, second=0, microsecond=0) delay = (next_hour - datetime.now()).seconds time.sleep(delay) PICPATH = '/var/run/shm/' # temp fs ramdisk PICNAME = 'RPICAM' PICTYP = '.jpg' PICCOUNT = 5 TIMWAIT1 = 2 # b4 first picture TIMWAITS = 10 # for pic sequence try: with picamera.PiCamera() as camera: # camera.resolution = (2592, 1944) # 5MB # camera.resolution = (1280, 720) camera.resolution = (640, 480) camera.start_preview() # camera.exposure_compensation = 2 # camera.exposure_mode = 'spotlight' # camera.meter_mode = 'matrix' # camera.image_effect = 'gpen' # Give the camera some time to adjust to conditions print('wait ' + str(TIMWAIT1) + ' sec ') time.sleep(TIMWAIT1) # wait() camera.exif_tags['IFD0.Artist'] = 'RPI' camera.exif_tags['IFD0.Copyright'] = 'Copyright (c) 2013 KLL (CC BY-SA 3.0)' # print('Capture one image ') # camera.capture(PICPATH + PICNAME + PICTYP) # print('Capture sequence of ' +str(PICCOUNT) + ' pictures with ' + str(TIMWAIT2) + ' sec delay') # for i, filename in enumerate(camera.capture_continuous(PICPATH + PICNAME + '{counter:02d}' + PICTYP)): # print('Captured image %s' % filename) # if i == PICCOUNT -1: # for ==2 i get 01,02,03 ??? # break # time.sleep(TIMWAITS) for filename in camera.capture_continuous(PICPATH + PICNAME + '{timestamp:%Y-%m-%d-%H-%M}' + PICTYP): print('Captured %s' % filename) # wait() time.sleep(TIMWAITS) camera.stop_preview() camera.close() # except KeyboardInterrupt: # User quit by [CTRL] [C] print "\nGoodbye!"