Time-Lapse Seed Germination: Part II
This is the second and final post regarding our first timelapse project. If you haven't read part one yet, you can find it here.
The below video represents the final results of our first timelapse project.
The camera itself was triggered using the gphoto2 command line utility running on the Raspberry Pi which itself was connected to the DSLR camera via USB. You can find the source code used for this project on our GitHub repository. If you explore the code repository, you can see that the original plan for this project was to use a mini servo to manually press the camera's shutter release button which ended up not being a very reliable solution.
The new and improved method used software commands to capture and download images from the camera at 15 minute intervals. After about four weeks of taking pictures, we ended up with roughly 1300 still images which were later stitched together into a continuous video file. To do this, we first sorted the images in chronological order and then passed in those ordered filenames to a text file. We were then able to use the mencoder command line utility to produce an initial .avi video file of all of our images. The Raspberry Pi Foundation has a good tutorial on this process.
The final post-production of the video was done in Adobe Premier Pro.
As stated above, our first attempts made use of a micro servo to manually control the camera. The results of this attempt can be seen in the animated GIF below. It shows a 'Blue Lake Stringless' garden bean germinating over a 5 hour period. That's about as long as we were able to capture images before we realized the servo method wasn't going to work for the long-term.
Even after transitioning away from the servo method, we ran into a few technical problems using the software method. The first major problem was that the camera needed to stay on indefinitely to respond to the software image capture signals every 15 minutes. Obviously, leaving the camera on continuously quickly drained the camera battery. This problem was mitigated in part using an AC battery pack, which allowed the battery to be plugged into a wall socket. Unfortunately, the camera seemed to treat this as a normal draining battery so the battery would need to be reseated in the camera about every 12 hours to restore the battery power indicator to full strength.
In order to stitch together still images into a continuous timelapse video, it's important that the chronological order of the images is preserved. The earliest iteration of the code controlling the camera images attempted to do this by naming the images based on the number of times the camera was given a command to take a picture. For example, the first picture was named 0.jpeg, the second picture was named 1.jpeg, etc. Unfortunately, this counting mechanism did not take into account the possibility that the program may have to restart at some point. When this happened, the counter would just start from the beginning, naming new pictures as 0.jpeg, overwriting the existing 0.jpeg file that had been taken in the past!
Later iterations of the code solved this problem by examining the folder containing all of the images that had already been taken. The program would read all of the filenames, find the highest number, and then name all subsequent photos starting from that point, rather than starting over from zero.
Because some images had been taken using the original flawed code, we couldn't rely solely on the filenames to sort the images in chronological order. To get around this issue, we wrote another script that read the metadata of the image files, specifically the 'DateTimeOriginal' property of the EXIF data which contains the timestamp of when the image was originally shot. This script allowed us to rename the files in a way that made sorting them easy and intuitive (important when dealing with 1300+ image files).
As you can see from the YouTube video up top, many of the images are overexposed. Unfortunately, this problem was mainly due to our inexperience of taking timelapse video. The exposure was set early on in the seedling stage but never readjusted as time went on. As the seedling grew towards the light source, the overexposure became more apparent, and we unfortunately lost a lot of detail in the color of the leaves. This problem was exacerbated by setting the camera to take low resolution JPEG images, rather than using a high resolution RAW image format which would have allowed us to correct the exposure in post-production.
For subsequent timelapse projects, we will likely address these problems by taking the camera out of full-manual settings, allowing it to adjust its shutter speed for a more even and consistent exposure. Additionally, we would take RAW camera images, and closely monitor the storage space of the SD card to ensure we do not run out of space before the timelapse project is complete.
If you have any questions or comments about this project, be sure to leave them in the comments below!