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.”
# 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
# wait 2 seconds
# capture the image. Display it. Save the image as a JPEG.
img = cam.getImage()
img.save('%.06d.jpg' % i)
# change the filename counter variable.
i += 1
You can run this code by executing the following command:
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!