I’ve done quite a bit to improve my Raspberry Pi-based timelapser. I have a pretty good system together now, thanks in part to recent firmware updates to the Pi which allow me to directly control the shutter speed and ISO of the camera sensor instead of relying on auto-exposure settings. The auto-exposure is pretty unreliable from one shot to the next: the camera makes a different decision each time it snaps a picture, which leads to quite a lot of flicker. Previously, I was dealing with this flicker by manipulating the images in post-production, but I’ve now written some code to get the camera to try to maintain a constant image brightness across a long shoot.
The code now consists of a ‘timelapser’ class, which keeps track of its current shutterspeed and ISO (SS/ISO henceforth), and the brightness of the last few images taken. It then adjusts SS/ISO to try to get the image brightness to 100. By keeping track of the last few images, it is a bit less susceptible to being upset by one strange image (like, say, if I put my hand over the lens for one shot, producing a black image), or more standard movement within the frame. On the other hand, it takes a while longer to settle down to the ‘right’ SS/ISO. So it’s currently set up with an initialization step, where it finds a good SS/ISO pretty quickly, and then transitions to actually taking pictures. The result is very little flicker as the timelapse goes on, and a pretty constant level of image brightness when light levels gradually change: like when we watch dawn or dusk. (If you’re interested in playing around with the code, I’ve set up a github repository here.)
As an example, this is a video that we shot over about three days on my friends Ketan and Ananya’s balcony. They have a great view over Toronto, from the CN Tower to Honest Ed’s.
The main problem I ran into with this video is a (probable) hardware issue with the Pi: if the power supply isn’t *just right*, one tends to get a corrupted SD card after a couple-few days of continuous use. After running the camera for about five days, I took it down and found the SD card was hopelessly corrupted. There were about 6000 images captured, but I was only able to recover about half of them, giving the 2.5 days of footage that you see here. Even so, there are occasional gaps in the images (which look like jumps or cuts in the video), and occasional black splotches which I *think* are bad blocks on the SD card.
I’ve gotten around this problem, though, by switching the Pi hard disk to a USB drive: the USB ports are much better supplied for power. One still needs an SD card to boot from, but the utilization is read-only and lasts about five seconds before it switches over to the USB drive. After many more experiments since the balcony shoot, I’ve had almost no problems with the USB drives.
In other news, I’ve placed two cameras at Elizabeth’s family cottage up in Meaford, Ontario, looking out over Lake Huron for the winter. The cameras will be running for about four or five months; it will be super-interesting to see what they turn up. I’ve been planning this for a while: the camera has two pis and two camera boards, in case one of them has a problem somewhere in the shoot. Unfortunately, window frosting is a potential problem, but at the very least I hope we’ll get to see some good spring thaw…
In other news, I’ve been doing some regression testing on the Pi’s camera sensor to try to guess quickly the right SS/ISO for getting a reasonably bright picture. I expect my next post will be a project report.
Until next time!