All things Raspberry Pi and Time Lapse

Posts tagged ‘time lapse’

Finished and Uploaded!!

The video of the compilation of over 3 months is edited and uploaded! It has been 3 months since I setup the Canon PowerShot camera and Raspberry Pi in the greenhouse to watch the plants grow. And grow they did! The greenhouse starts out empty and in 15 seconds the plants are ceiling height. It was just under 90 frames total because some of the frames were too dark to use. And unfortunately some of the current images are pretty dark. But it worked!! And now I know what to change so that the images are not as dark for next time. Let me know what you think in the comments!

https://vimeo.com/57635944

 

Now I am looking at setting up for a year – as was my original goal…

 

Building a Gertboard

Finally edited the time lapse of building my Gertboard. It took about 4-5 hours from start to finish. I missed a small portion of soldering the header pins because the camera ran out of battery. The surface mount components were the hardest, but after that it was pretty straight forward and really fun! Here is the link to Vimeo and the Time Lapse (https://vimeo.com/56662328). After finishing the board I ran the test scripts that were written in C and it worked except for the motor controller. For some reason it would not turn the motor. Still working on figuring out what I am doing wrong there…

Finished shot of the Gertboard connected to the Raspberry Pi.

gertboard

Updated scripts

I made some pretty major changes to the scripts after I figured out the problem with the camera card filling up. The changes were partly because of this, and partly to consolidate code to make it easier to make a minor change. The changes are as follows.

This is the main script to take a picture with gphoto2. Instead of having a separate script for each time the camera takes a picture I added the ability to add arguments to the script. This is represented by the $1 and $2 and so forth. When executing the script it now looks like this on the command line:

/path/to/script argument1 argument2

And as you might assume “argument1” gets assigned to $1 and “argument2 gets assigned to $2. This makes it possible to increase the flexibility of a script and reduce the number of scripts needed to the project to work. It also adds the ability to make a small change to the script and affect everything. Like for example if I want to change the aperture I only have to make one change instead of changing it in every script. The updated script is shown below.

#!/bin/bash
# jamesmiller
# 6-22-2012
#
# change directories to the correct folder to save the image
cd /root/$1
# check how many images are in the folder
before=`ls -l | wc -l`
# take the picture using gphoto2
gphoto2 –set-config shootingmode=3 –set-config aperture=9 –set-config shutterspeed=37 –set-config focusingpoint=0 –set-config imagequality=2 –capture-image-and-download –filename “%Y%m%d%H%M%S_$2.jpg”
# wait for 30 seconds to give the camera time to take the
# picture and save it.
sleep 30
# then check how many images are in the folder
after=`ls -l | wc -l`
# compare the before and after image count. If it is the same
# number then we assume that the image did not get downloaded
# and stayed in the folder on the camera card.
if [ $before == $after ]
then
# execute the download script to download that picture
/root/download_pics $2
fi

And the script that gets executed if the number of pictures stays the same is shown below. It is not commented at all, so I will update that when I have some time.

#!/bin/bash
# jamesmiller
cd /root
# use a here doc to list all directories in the main
# DCIM directory on the camera
dir=$(gphoto2 –shell << EOF |
cd store_00010001/DCIM/
ls
exit
EOF
grep CANON)
# for every directory in DCIM do these actions
for x in $dir
do
# except for this directory so that the card ALWAYS has
# one picture on it so it doesnt stop taking pictures
if [[ $x == 157* ]]
then
continue
else
# Use another here doc to list the files in each directory
img=$(gphoto2 –shell << EOF |
cd store_00010001/DCIM/$x
ls
exit
EOF
grep IMG)
# change directories to the camera card and the correct folder
gphoto2 –shell << EOF
cd store_00010001/DCIM/$x
# download the image to the main folder (/root) of the raspberrypi
get $img
# delete the image from the camera sd card
delete $img
cd ..
# remove the directory
rmdir $x
exit
EOF
# get the time stamp information from the image that was downloaded
tstamp=`stat $img | grep Modify | cut -d ” ” -f2,3 | cut -d “.” -f1 | tr ‘ ‘ ‘_’`
# rename the image that was labeled like IMG_1398 to a filename with the
# timestamp inforamation
mv $img $tstamp$1
# move that image to another folder to keep /root clean
mv $tstamp$1 canon_pics
fi
done

The general idea of the script is that it uses a Here document to accomplish its goals. It changes directories to the camera card, then gets the folders listed there. Then for each folder it downloads the images to the Raspberry Pi, deletes the images from the camera, and then deletes the folder. After that it renames the images (which needs some work) and saves them in a separate folder.

The crontab changed as well because of the changes to the main script.

@reboot /root/set_camera_time
@reboot /root/focuslock
1 12 * * * /root/camera pics_1day 1day
31 7 * * * /root/camera pics_7am 7am
31 15 * * * /root/camera pics_3pm 3pm
*/2 5-20 * * 3 /root/camera pics_2min 2min

This shows how the one main script is being used to take four different sets of images. And it labels them correctly and saves them in the correct folder so they do not get mixed with another time.

These scripts work using Arch Linux and a canon PowerShot A510. It should work with other setups, but I have not tested it with anything else.
I downloaded all of the pictures so far and it is looking amazing. It is possible to see the plants grow daily. The one issue I am having is with flicker. This is caused by a sunny day, then a cloudy day, then a sunny day. The camera is set to manual because on the auto feature it can change drastically between two sunny days, and cause more drastic changes than dealing with the problems of the manual settings. I am looking into the GBS (Granite Bay Software) plugin for After Effects which smooths the exposure across multiple images. From the initial test it looks like it did a very good job, but before I buy it I am looking to see about any other options (if there is any) and how they compare.

More about those images soon!

Some pictures that it shot before stopping

Here is the first image that it took on 8-26 at 12noon.

And this image was taken on 9-3 at 12noon.

It is not very clear in this format, but if you download both images and then flip back and forth there is a major change in the plants in the 9 days from the first one to second one. I am hoping to see more of these differences as the plants grow!

Unfortunately it only took pictures for 9 days and that is too short to make into a timelapse…. And when it was taking a picture every 2 minutes it had focusing problems. There is no way to set a manual focus, however I thought I had that accomplished using focuslock in gphoto2. The focus lock seemed to work just fine for the once a day picture but not the other. There was nothing that was moving drastically from each shot so it was weird that it didn’t focus right.

Still planning to setup for the second time this weekend!

Update… And its not good…

I went to check on how the time lapse setup was working. And it was not. It worked for not quite a week and then stopped taking pictures for some reason. So I brought it home and have been working to see what was wrong. And so far I cant figure it out. I cannot get the camera to take a picture using gphoto2 anymore. I tried a whole new installation of Arch (I kept the previous one separate) and it still wont take a picture. The other camera that I had bought previously (Canon Powershot SX100) will work just fine though. So that would lead me to believe that the Powershot A510 wont work. However, the camera will still take a picture just fine when it is disconnected from the Raspberry Pi and functioning like a regular camera.

So now I am not sure what to try. It seems like it is a problem with the camera, but the camera will still take a picture so it didnt completely die. Anyone have any suggestions?

RaspLapse is installed!

On Saturday (Aug 25) afternoon the RaspLapse project was installed! I am really looking forward to the results. For now it is situated on the Fan/Exhaust end of a greenhouse. I am going to leave it there and take pictures as they pull existing tomato plants out. Then it will be ready to watch the new plants grow! Here is a before and after shot of the installation process. (Sorry about the picture quality…)

Before…

Image

And after…Image

The box on the right is holds the camera, Raspberry Pi, and some connections between the camera and the Raspberry PI. The box on the left holds the power connections, and the Ethernet cable so I can download the pictures without ever touching the enclosure holding the camera.

EXTRA

Here is a picture of what the camera is shooting… This is the raw image.. No editing at all. In the end I will crop/rotate in Photoshop.

Time Lapse shot on Canon S2IS

This is my Vimeo video link that I shot about half of a year ago. I setup my Canon Powershot S2 IS under our orange tree shooting the clouds that were particularly awesome that day. This is the result!

 

The second one is one that I shot using the same camera of some ice cubes melting. This one provides what I think of as a time lapse perfect opportunity. There would be no other way to capture this!

 

http://vimeo.com/36116642

http://vimeo.com/36520044

Tag Cloud