2009-03-16

Time Lapse Agriculture

I always thought the one of the great pleasures of being a farmer was to "see plants grow". Maybe I'm too impatient, but after looking at them for 15 minutes and see nothing I decided to try and do a time lapse video.
Ana tried her film first, she used a regular camera and took pictures every 15 minutes for two days (most of it). Later I ordered the pictures, reduced the size and composed the video. In order to keep the same illumination during the day, she used an halogen lamp over the plants. Naturally it is quite clear that this fakes the results and her plants grow super fast...
I decided to use a computer and a webcam to do the job for me. First I tried a logitech quickcam messenger but the resolution was very coarse, it needs special drivers in linux and it does not auto adjust for the brightness.
Next, Tiago borrowed me a Philips Webcam PCVC830K, it worked out of the box in Suse 10.3, resolution is 640x480 and adjusts for the brightness.
I created two scripts, one to take the pictures every 6 minutes and another to compose the video.
Here is the snapshot script:
#!/bin/bash
## adapted from http://mydebian.blogdns.org/?p=261#more-261
## Takes a picture every (wait) seconds and renames it ${now}

# how long to wait between each download
wait=360

## main endless loop ##
while true
do
now=$(/bin/date '+%Y%m%d%H%M%S')

## fetch new webcam shot ##

ffmpeg -s vga -r 1 -t 1 -f video4linux -i /dev/video0 -y plant.jpg
mv plant.jpg "${now}.jpg"
## echo "${now:8:2}" just the hour
echo "${now}"
/bin/sleep $wait

done
Here is the script to compose the video:

#!/bin/bash
mencoder -ovc copy -mf w=640:h=480:fps=15:type=jpg 'mf://*.jpg' -o time.avi
During the shoot I hit the box with the vacuum cleaner, so there's a small shift... be warned. The shoot takes place from Friday night to Monday morning. The plant box is facing south and is close to the TV, so during the night there's a first level of darkness, then when we turn off the TV the only light is the webcam red led. The red led allows us to see some, although little movement.
Here is the video...

No comments: