I recently started a new job so I will not be posting as much now unfortunately. I am trying to decide how I want the script that uses at to function. The problem is that if the power was consistent that script that is the last one in this post would work beautifully. However since power may not be on 100% of the time because of a snow storm or something else knocks the power out, this script may not function the way it should. If the power is off when the script was scheduled to run, it will run whenever the system starts up, not at the correct time. And this is a major problem. So my next idea was to set all of the times that the camera would take a picture for the whole year. This script accomplishes that.
# this script will set all of the times when
# the camera should take a picture.
# set some variables
# test how many times this script should execute
# I chose 400 because there is 365 days in a year
# and this is a little more than that
while [ $count -lt 400 ]
# set what time at should execute the script
at -f /root/camera_1443min now + $min’min’
# add 1 day and 3 minutes to the last time
# 1440min = 1day
min=$((min + 1443))
# increment the count by one
count=$((count + 1))
The main problem with this script is that if the power is off, and it misses one or more of these scheduled time, it will execute them when the computer boots. The problem with this is that I will have pictures in the folder along with all of the rest of them that were not taken at the right time. Still trying to figure out how to deal with that. If at had configuration files that would turn “execute old jobs at boot” on and off that would be nice! The other option is to assume that the power will only go out once or twice, and that I should not worry about it, and write a script that executes at startup to put the date and time into a file. Then I could get the date and time from that file and go find the images that were taken at the wrong time.
I ask this question on the Unix/Linux Stack Exchange forum and I am waiting to see if there are any answers that will work.
NOTE: This is kinda complicated to explain in text so I did my best. Leave a comment below if you have questions!
The enclosure is setup outside my window and it taking pictures of our garden. This is so I can test it and make sure everything works correctly. Here are some pictures of the setup.
Here is the time lapse video that the setup shot on 7-16-2012. It was taking a picture once every 5 minutes.
Now that I have my Raspberry Pi I wrote and tested the script to set the time on the Raspberry Pi using my Canon Powershot A510. This is a follow up of my previous post. This is tested and works with a Canon Powershot A510 but it may work with other Canon Cameras, however some may require a little modification to the script.
# this script works with the Canon Powershot A510
# other models may or may not work
# use gphoto2 to get the camera time
camera_time=`gphoto2 –summary | grep -i “unix time” | cut -d ” ” -f4`
# for some reason I had to subtract some time to get it to be correct
camera_time=$(($camera_time – 3592))
# convert UNIX time to readable time
time=`date -d @$camera_time`
# the next four (4) lines cut the timestamp into specific parts so
# that it can be used when setting the time
b=`echo $time | cut -d ” ” -f2`
c=`echo $time | cut -d ” ” -f3`
d=`echo $time | cut -d ” ” -f4`
f=`echo $time | cut -d ” ” -f6`
# this sets the variable real_time equal to the values from gphoto2
# and puts them in the correct order
real_time=`echo $c $b $f $d`
# set the system time equal to the time from gphoto2
date -s “$real_time”
And this script is put into a cron job that is set to run at startup using these details here.
If the power goes out and the camera and the Raspberry Pi shut down, when the power comes back the camera should startup faster than the Raspberry Pi and when the script runs it can set the time correctly. The camera has a small battery to keep time, and it will last for a long time with no power and still keep time.
Everything is setup outside my window taking pictures of our garden today. This is my chance to test and get all of the bugs worked out before I setup for a long period of time. Already I have changed several things and I updated the scripts post to reflect these changes.
I will probably post pictures of the setup tomorrow along with the time lapse that it is taking today.
I have been playing around with my Raspberry Pi for about the past 3ish hours! It is an amazing little device! My curiosity for how it will work with my project caused me to jump right into working on those details.
I wrote the disk image to the SD card following the instructions here – I used the dd command on Fedora. Then to fix the partitions I used gparted on Fedora. Good instructions are here.
I do not like Debian/Ubuntu as well as some other distributions because they do not adhere to some of the conventions as well as other distributions do. This is mainly a personal preference, but since I have a choice I can be picky. So I started with the Arch distribution. All was going well until I tried to install gphoto2. It would get part way through installing and then would quit with an unknown error message. I have not used Arch very much so I moved onto the Fedora distribution. This distribution is not recommended and I can see why. About every 20-30 seconds it would dump error message garbage into the terminal. And since Fedora is not a stable distro I decided that for my project a stable distrobution will probably help me not to lose sleep at night worrying about whether something happened and it shut off.
Next I tried Debian 6. For some reason it starts up, then tries to shut itself down the first time. And it hangs on stopping portmap. However after cycling the power it starts up just fine into runlevel 3 – command line mode. However after after installing gphoto2 it would not take a picture. So I tried installing an older version of gphoto2. Still nothing. It would sometimes take a picture, but then after that it would stop responding. So that was not an option.
The next morning I decided to go back to Arch and spend a little more time on that. After figuring out that it is required to select the mirror where the package manager searches for files I edited /etc/pacman.d/mirrorlist and uncommented several mirrors. Then it would install! And it installed gphoto2 just fine and it works perfectly when run as root. If gphoto2 is run as an ordinary user it causes problems. So after some messing around (hey this is what I like doing!) I now have Arch running and gphoto2 working as expected.
Here is a link to my most recent time lapse video. It is of the sunrise from clouds rest in Yosemite National Park. More details in the description on Vimeo.
Just got a super AWESOME email from Newark/Element14 a little bit ago. It said that my Raspberry Pi shipped and has tracking information!! However UPS tracking has no information yet… But at least it shipped and is 6 days early! Can’t wait for my UPS package!!
Looking into how to process an HDR time lapse… An HDR image allows for an image that is closer to what we see in real life when done right. However they can be vastly blown out of proportion as well. Although it would require three times the number of pictures I was thinking about trying it for the year-long time lapse. There are several programs that offer a batch process mode of HDR, but none are free. The two I looked into the most was Photomatix and SNS-HDR (this website is in polish).
But since these images are coming from a low end camera, all the HDR seems to do is magnify the noise really bad in low light conditions. The results are amazing in good light however. These were shot in San Francisco at approximately 7pm. Below is a picture that was edited with SNS-HDR, but with the trial version so it has their watermark on it. So while was a fun little exploring to figure out how to do HDR time lapse, at this point I do not think it will be worth it. (Definitely keeping it in mind however…)
There is a really good wiki page here that has many different software packages for processing HDR and the different options they each have.
The Magpi is a great monthly magazine available for free download from their website. They have great articles about everything Raspberry Pi related. Their latest issue has 150+ games to try on your Raspberry Pi and other interesting articles. It is a very good way to stay up to date on what is going on within the Raspberry Pi community.