Sunday, June 22, 2014

Long duration time lapse

After a couple of trials, I was ready to try a full day time lapse. Using the 7-day USB timer in my Cottonpickers solar project kit (see previous post), I set the timer to wake up the Pi at 5am and off at 10:30pm.

The Process

The Pi has a boot task in rc.local to immediately start a simple shell script that takes a few variables and kicks off the raspistill program. Here it is, if you are interested:

#!/bin/bash
# start a series of time lapse pictures every x seconds for y minutes
test_file=/home/pi/.timelapse
start_date_folder=$(date +%Y_%m_%d)
start_time_folder=$(date +%H_%M)
time_stamp=$(date +%Y-%m-%d-%H-%M-%S)
stills_path=/home/pi/stills/$start_date_folder/$start_time_folder
interval_sec=20
interval_ms=$(($interval_sec*1000))
#ONLY INTEGERS ALLOWED FOR VARIABLES (NO FLOATS)
run_hrs=17
run_mins=0
total_mins=$((60*$run_hrs+run_mins))
echo "total_mins = $total_mins"
duration_ms=$(($total_mins*60*1000))
echo "duration_ms $duration_ms"
shutdown_min=$(($total_mins+2))
echo "shutdown_min = $shutdown_min"
if ! [ -d $stills_path ]; then echo "make dir $stills_path"; `mkdir -p $stills_path`; fi
echo "starting raspistill"
raspistill -rot 90 -o ${stills_path}/still_%04d.jpg -tl $interval_ms -t $duration_ms && echo "shutdown now"


After all the pictures are taken, I run a separate shell script to encode the video from all those stills:

#!/bin/bash
path="/home/pi/stills/${1}/${2}"
#echo $path
output="timelapse_${1}_${2}.avi"
#echo $output
ls ${path}/*.jpg > list.txt && mencoder -nosound -ovc lavc -lavcopts vcodec=mpeg4:aspect=16/9:vbitrate=8000000 -vf scale=1920:1080 -o $output -mf type=jpeg:fps=24 mf://@list.txt

I usually do the encoding later, but I could have it automated. I can also automate copying the resulting video to my dropbox folder.

Protecting the Hardware

The last photos of my Pi had it encased in the Nwazet camera case. I have taken steps to protect it from the elements. To keep expenses down, I used an old Lock & Lock food storage container that was large enough. Joey says my new case looks ghetto. My neighbor wondered what the hell it was. "It's a scientific experiment, yo!"

To get a clear viewport, I used a 2" hole saw to cut a hole into the lid, where I press fit a 52mm UV camera filter (and screw-on lens hood). I used aquarium silicone I had laying around to seal the fitting. I picked up the Chinese-made filter and hood for $6 on eBay.

It was also necessary to add additional holes in the case to attach the tripod adapter bracket. The tight fit prevents from using my larger USB Wi-Fi dongle, so I'm getting a right-angle USB adapter for that ($3 on eBay). In the mean time, I have my stubby one in place, which, I usually remove during photography to save power. However, the solar kit, which has 1500ma panel and (4) 3400mAh Li-ion batteries easily handled the Pi with the Wi-Fi running!

Notice also the bubble level attached to the top of the camera. This allows me to get it level with the horizon quickly. The next order of business will be to plug up those holes to keep out bugs and moisture. I'm afraid of introducing a microclimate that creates moisture, so maybe I'll use some extra window screen material or open cell foam. I may thrown in some silica packets too for good measure.


The Result

This 17 hour time lapse probably took around 2 hours to encode (also done on the Pi). Once complete, I upload to YouTube for sharing. This time, the color balance was a bit off, skewed to warmer temperatures. I made a correction in youTube, but I'm not sure if this was because of the UV filter. I used the filter on a previous trial without this side-effect.


0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home