RaspberryPi/Timelapse4
From charlesreid1
Also see RaspberryPi/USB Camera
Contents
Overview
For timelapses 1-3, I had multiple headaches dealing with the weak-sauce ribbon-cable Pi camera. I dumped it for a more hefty, webcam-style USB camera. Photo:
This camera is 1/2 inch in diameter.
Timelapse 4 Plan
First, let's start with what we like, and what we've accomplished:
- Several things were accomplished with RaspberryPi/Timelapse3 (example: we were able to control the LED).
- Can resurrect idea bucket, continue working on the weatherproofing ideas, now that the bottleneck has been removed (better camera)
Plan for weatherproof camera mount:
- KISS
- Mount it, use the cap that came with it, put a rubber gasket around it to protect from rain further
- Don't worry about making it bomb-proof your first time. Just get the parts working in sync.
Stuff List
Hardware list:
- raspberry pi 3
- usb jump drive (for photo storage)
- usb camera
Software list:
- script to operate camera
- necessary Python bindings for taking photos
- motion server/fwcapture?
Modifications
Modifications to the Pelican case are covered at the RaspberryPi/Weatherproof Camera Case page.
Pelican Case Modification: Success
Modifications made to the Pelican case, described at RaspberryPi/Weatherproof Camera Case, were successful. The camera lens was about 0.55 inches in diameter, and fits into the hole with very little clearance. I have more notes on the specifics of the case modification over at RaspberryPi/Weatherproof Camera Case. This is Stage 1 of the Pelican modifications. Eventually this will be full-on waterproof, but the goal for Timelapse 4 was to keep it simple, stupid.
Upgrading Image Software
I needed to upgrade the way I was grabbing images from the camera. I decided to bite the bullet and go with SimpleCV, which would provide access to more high-power image processing applications - exactly what I'm looking for.
Installing SimpleCV
To install SimpleCV on the Raspberry Pi, you will need to install scipy, and that's gonna take a while. Same thing with OpenCV, a library required by SimpleCV.
$ sudo apt-get install python-scipy $ sudo apt-get install python-opencv
(Note: I don't recommend doing pip install scipy
, as that does not install the proper linear algebra headers, and now you're going to spend your evening in Dependency Hell.)
Now install SimpleCV:
$ sudo pip install simplecv
Using SimpleCV
Basic usage script for SimpleCV:
from SimpleCV import Camera import time cam = Camera() time.sleep(3) # wait for the camera to warm up img = cam.getImage() img.save("image.png")
If added to an infinite loop with a time delay, this can be used to make timelapse photos:
from SimpleCV import Camera import os import time from datetime import datetime cam = Camera() time.sleep(0.1) lapse_dir = datetime.strftime(datetime.now(),"timelapse_%Y%m%d-%H%M%S") os.system('mkdir '+lapse_dir) while True: prefix = datetime.strftime(datetime.now(),"%Y%m%d-%H%M%S") filename = lapse_dir+"/"+prefix+".jpg" img = cam.getImage() img.save(filename) print "Saving photo to %s"%(filename) time.sleep(2)
Results
Here's a sample image:
Flags