Stories on maker education and innovation 

Home making Taking Time Lapse Photos with Your Raspberry Pi
formats

Taking Time Lapse Photos with Your Raspberry Pi

Simple CV

One of my friends from SparkMacon makerspace had a question about taking time lapse photos using a Raspberry Pi.  Since this feels like a fun starter project for many makers, I wanted to share an approach using an easy computer vision library, SimpleCV.   SimpleCV by http://www.sightmachine.com/  enables novice programmers to build computer vision experiences using Python and concise code patterns.  This code should also work on Mac, Linux, Windows, and a Raspberry Pi.

To utilize SimpleCV on your Raspberry Pi, follow the install instructions located here.

Make sure to install a web camera or the Raspberry Pi camera module.

If you’re not familiar with the Python programming language, you can learn the basics from CodeAcademy.com .   I have a few free e-books located on this blog post.

I found a time lapse capture script by larsyencken on github.   That looks really simple.   Copy the following code into a text file named “time_lapse.py.”   

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import os
import SimpleCV
import time

# get access to the camera
cam = SimpleCV.Camera()

# setup a display
disp = SimpleCV.Display((1024, 768))

# this variable is used for naming each file or frame.
i = 0

while disp.isNotDone():
    # wait 2 seconds
    time.sleep(2)

    # capture the image. Display it. Save the image as a JPEG.
    img = cam.getImage()
    img.save(disp)
    img.save('%.06d.jpg' % i)

    # change the filename counter variable.
    i += 1

    if disp.lastLeftButton:
        break

You can run this code by executing the following command:

python time_lapse.py

After running this script, your program should capture a new image every two seconds.  Each frame will be numbered.

If you’re interested in learning more with SimpleCV, make sure to check out their documentation resources.   It’s a fun and easy way to do computer vision.

What other cool ways could you use SimpleCV? We would enjoy hearing your ideas!

 

 

 
 Share on Facebook Share on Twitter Share on Reddit Share on LinkedIn
No Comments  comments 
© Inspired To Educate
credit