import time

import picamera


VIDEO_MINUTES = 15

FRAMES_PER_MINUTE = 4

FRAMES = FRAMES_PER_MINUTE * VIDEO_MINUTES


def capture_frame(frame):

    with picamera.PiCamera() as camera:

        camera.resolution = (1024, 768)

        camera.start_preview()

        time.sleep(2)

        camera.capture('/home/pi/Capture/Frame%03d.jpg' % frame, resize=(320, 240), quality=50)

        camera.stop_preview()


print "Starting capture..."

# Capture the images.

for frame in range(FRAMES):

    # Note the time before the capture.

    start = time.time()

    capture_frame(frame)

    # Wait for the next capture, taking the image capture time into account when calculating the delay.

    time.sleep(int(60 / FRAMES_PER_MINUTE) - (time.time() - start))

print "Capture completed!"


#EOF


A Shark