All things Raspberry Pi and Time Lapse

Great tutorial here on Instructables on how to build a portable Internet radio box. This project includes some soldering, but has good instructions. I am going to look into installing pianobar as that looks like it could be really useful and right at home on the Rasberry Pi.

Advertisements

Gertboard Arrived!

My gertboard arrived today! So I setup the soldering stuff and went to work on the practice board from Elenco that I bought from Amazon. And I found out real quick that the soldering iron that I have is not high enough quality. The tip did not get evenly hot which made it hard to solder. So I decided to buy a different soldering iron. I bought this one from Adafruit as they have Raspberry Pi and lots of other awesome electronics and DIY kits/parts. So I am assuming that since they say that this soldering iron is a good entry-level tool that it should be worth it. So now the only problem is waiting for that to ship…

I was looking up some instructional videos about the gertboard and came across these three from Element14.

Advice about assembly – Surface mount – Through hole

And as mentioned in this video at approximately 6:10 he says that there was only 10 jumper wires that came with the kit, and there are 12 LEDs. So there is not enough jumper cables to connect all 12 LEDs at the same time. So in addition to the soldering iron I bought a pack of these F/F jumper wires and also a pack of M/M jumper wires.  This gives me the option of creating my own M/F jumper wires by combining one of each. And these come in packs of 40 so I should have plenty!

Adafruit is a really awesome website. And Sparkfun is really amazing too!

Here is a picture of what all arrived in the package from Newark. Gertboard on the left. Small components in bags in the center. And some of the bigger chips in anti-static bags on the right.

IMG_0914

Next two images are of the GPIO cable coming out of the case that I posted about previously.

IMG_0909 IMG_0910

The next two images are of the bare Gertboard. First one is the top of the board, and the second is the bottom of the board.

IMG_0912 IMG_0913

Pro Time Lapses

This video on Vimeo is absolutely amazing! It is a combination of day and night shots that were taken in Yosemite National Park. This next video is also a collection of shots from Arizona and Utah. Both of these videos are absolutely worth the time to watch them. The second video is by a guy named Dustin Farrell and he has some great tutorials on shooting and post processing.

Yosemite – https://vimeo.com/35396305

Arizona and Utah – https://vimeo.com/29950141

Gertboard Update

I do not understand Newark… But this time I am not complaining! They shipped my Gertboard yesterday and it is on its way to me! I have decided that if I ever buy anything from Newark the best plan is to buy it, then forget about and do not check the ship date on their website. Just wait for an email with the confirmation or better yet wait till it shows up on my doorstep. My previous post here explains some of the problems I had when I originally submitted this order. In Newark’s defense I basically have only bought items that were in extremely high demand, but some customer contact would have been nice. Looking forward to that package arriving!

Raspi.tv and gertboard

There is an awesome site here at Raspi.tv where there is lots of good information regarding raspberry pi information. The page here on that site shows how to control a fan and a light from a raspberry pi. This is a project I was wanting to work on after I got a gertboard and learned more about controlling things in the physical world. Also along those lines is how he is controlling a fan from the gertboard here.

As far as the gertboard I ordered… I finally contacted Newark because the ship date has changed about 5 times (sometimes farther away, and other times to a past date) and they said that they should ship in about 2 weeks. Maybe. However, on their site the ship date is now showing Feb 2013… The good news is that I am actually getting a un-built kit. Newark is no longer selling these, but may start to offer a pre-built gertboard. It looks like a site from the UK may still offer the un-built kit, but they don’t ship to the US.

ImageMagick scripts

I found this post here about a guy who took all of his shots from a year and compiled them into a single image. This sounded like a cool idea, but I could never find the code for how this was accomplished. But I figured that it shouldn’t be too hard so I set about doing it for myself. I have 21 images so far and I compiled them into these two images. One from right to left. And the other from bottom to top.

Once I have more images it should look better as each section will be considerably smaller. I achieved these results using a command line program called ImageMagick on Linux. It was a very simple install ‘yum install ImageMagick’ (notice the capital letters) since I am using Fedora and that was all. Debian based distros may be something like ‘sudo apt-get install ImageMagick’ but I have not tried it. The weird thing though was that I was actually using the command line tool ‘convert’ from the command line instead of ‘ImageMagick’. Great documentation available at their site about the usage here. And documentation specifically about the cropping here. The command line usage looks like this:

convert input_file XxY+X+Y output_file

The program uses the X and Y axis for where to crop. The top left corner of the image is 0x0. The +X+Y is offset from that initial 0x0. Check out the scripts below for actual usage in the script. I did the math before I ran the script and that is where the 92 and 73 come from. I took the dimension of the image and divided by the number of images that I had. So the first image is 2048 wide and I had 21 images. Then I rounded that number down to get the 92 that was used in the script.

This first script is for the top image cutting columns of the image.

#!/bin/bash
# jamesmiller
# get list of files in current directory
files=`ls | grep “^rasplapse*”`
# set the initial crop point
x_factor=0
# for each file in the current directory
for x in $files
do
# ImageMagick convert program to crop the image
convert $x -crop 92×0+$x_factor+0 column_$x
# add to the initial crop point so the next image
# is not the same strip as the previous image
x_factor=$((x_factor + 92))
# add a border of white
#convert column_$x -border 1x column_$x
done
# get the list of newly created images
column_files=`ls | grep “^column*”`
# add all of the strips of images into one image
convert $column_files +append column_file.jpg

This script is for the bottom image cutting rows of the image.

#!/bin/bash
# jamesmiller
# get list of files in current directory
files=`ls -r | grep “^rasplapse*”`
# set the initial crop point
x_factor=0
# for each file in the current directory
for x in $files
do
# ImageMagick convert program to crop the image
convert $x -crop 0x73+0+$x_factor row_$x
# add to the initial crop point so the next image
# is not the same strip as the previous image
x_factor=$((x_factor + 73))
done
# get the list of newly created images
row_files=`ls -r | grep “^row*”`
# add all of the strips of images into one image
convert $row_files -append row_file.jpg

The very last line of each script is what compiles all of the strips of images into one image. NOTE: these scripts are meant to be executed in the folder containing the images. And they may need to be modified to suit other uses depending on the file naming structure and so forth.

I also tried these scripts using the pictures that were taken every 2 minutes. But even separating them out into three different pictures it didn’t turn out that neat. There was very little change across the picture because not that much moved in a single day.

Looking forward to using this technique on more pictures like the pictures shown above once I have more images!

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!

Tag Cloud