Nikon 880 + Toshiba Satellite 110cs = time lapse
I have an old Nikon 880 connected via serial cable to an even older Toshiba Satellite 110cs running Debian 2.2 with a cron job which takes a picture looking out the window every ten minutes. It's been running for a couple of years now and has taken nearly one hundred thousand photos. I made a script to switch to 30 second exposures at night, and back to auto exposure during the day.
The shell script below reads the shutter state to use (auto or 30000000) from the file "shutter", checks the average pixel value from the last image recorded in file "average" and if it's above a brightness threshold, sets the shutter to auto, below, sets it to 30 seconds, takes a picture with that shutter setting, downloads the picture with the date and time as the filename, erases the picture, creates a thumbnail, rsync's the picture and thumbnail to my mac.
ImageMagick can give an average pixel value with recent versions, but the old version in Debian potato doesn't have that feature, so I resize the image to 1x1 pixel, and get the value of that pixel for an average.
Then if the shutter value has changed, write it to the shutter file, delete the thumbnail, and delete all but the last 576 images (I like to keep a number of images on the laptop in case it disconnects from the wireless network, it will have a backlog of images, but not too many, or the drive fills up).
Here's a time lapse from the camera setup looking out the window. http://www.youtube.com/watch?v=aPANmSG_vKU
Thanks to Brian Lee and his GSCam webpage, which I currently don't see on the web, unfortunately. His page gave me some ideas, and he shared his code with me which gave me some hints for using photopc.
#!/bin/sh
shutterdark="30000000"
shutterlight="Auto"
avglight="200"
avgdark="14"
thedate=`date "+%Y%m%d_%H%M%S"`
echo $thedate
filename="$thedate.jpg"
averagejpg="average.jpeg"
shutter=`cat shutter`
shutterlast="$shutter"
lastavg=`cat average`
if [ "$shutter" = "$shutterdark" ]; then
if [ "$lastavg" -gt "$avglight" ]; then
shutter="$shutterlight"
fi
fi
if [ "$shutter" = "$shutterlight" ]; then
if [ "$lastavg" -lt "$avgdark" ]; then
shutter="$shutterdark"
fi
fi
echo $shutter
photopc shutter $shutter flash Off snapshot > /dev/null 2>&1
sleep 40
photopc -zqf $filename image 1 . eraseall
/usr/bin/X11/convert -geometry 168x126 $filename thumbs/t_$filename
rsync -aq -e ssh *.jpg user@192.168.1.15:Sites/nikon880/
rsync -aq -e ssh thumbs/*.jpg user@192.168.1.15:Sites/nikon880/thumbs/
/usr/bin/X11/convert -geometry 1x1 $filename $averagejpg
/usr/bin/X11/convert $averagejpg text:average.txt
avg=`cat average.txt | awk '{ print $2 }' | tr "," "\n" | awk -F" " 'BEGIN {x=0} {x+=$1} END {printf("%d", x/3)}'`
echo $avg
echo $avg > average
if [ "$shutterlast" != "$shutter" ]; then
echo $shutter > shutter
fi
rm thumbs/*.jpg
ls -r 2*_*.jpg | tail -n +576 | xargs rm -f
## linux_macosx_hints_etc page