Sprouting time-lapse with RaspberryPi Cam

As physical distancing continued and we started a small garden on our balcony, I had an idea how to put my old Raspberry Pi 1 to good use. After ordering and receiving a Raspberry Pi Cam, an SD card, and a power supply, I head everything to capture a time-lapse of sprouting seeds.

The setup is simple. I cut a hole, slightly smaller than the housing of the camera's lens, into a shoe box and pushed the frame into it from the inside. Thus, a tripod analog was created. The Raspberry Pi went into the box as well, with the power cable coming out the top. I placed the seeds on a plate with a tissue as water reservoir and carefully arranged with some cardboard to have the seeds fill the camera's field of view. As the final step, the camera's focus was properly set.

View from the top on the experiment's setup.

On the Raspberry ran a stock Raspberry with the following script. The script instructs the camera to take a photo every fifteen minutes. The photo's filenames are composed of the current date and time, ordered from most to least significant component, that is, from year to second. Named this way, lexical order of the filenames is equivalent to the files' order by time of capture.

from picamera import PiCamera
import time

camera = PiCamera()

while True:
    filename = time.strftime("%Y%m%d-%H%M%S.jpg")
    camera.capture('/home/pi/experiment/' + filename)
    time.sleep(900)

After four days (by chance it was exactly 4 days), I stopped the script and had 384 photos taken at fifteen minute intervals. I ran those photos through FFmpeg, to create a time-lapse movie. The following two invocations did the trick

ffmpeg -pattern_type glob -i '*.jpg' -r 24 -c:v libvpx-vp9 -pass 1 -b:v 2M -an -f webm /dev/null
ffmpeg -pattern_type glob -i '*.jpg' -r 24 -c:v libvpx-vp9 -pass 2 -b:v 2M -an -f webm kresse.webm

They create a WebM file containing the video encoded with VP9. The source images are specified by the glob paramter *.jpg that sorts the matching filenames lexicographicaly, which corresponds to chronological order as stated above.

The resulting video file is almost 4 MB in size with a resolution of 1680x1050; the Raspberry Pi Cam's resolution. With 24 frames per second it last 16 seconds.

My intention was to try out how it works and what the results would be. For that, I am happy with the results. You can see the sprouts growing. I want to say that they stop during the night, but it is dark for so long it is hard to judge. This leads to one immediate improvement one could make to the setup: LEDs that light up the scene for each photo. Maybe I will pick up the project again.