Browsed by
Tag: Python

Workshop Weekend: Timelapse

Workshop Weekend: Timelapse

A month ago I had a little workshop weekend where I built an electronic camera controller using a relay and an Arduino, this weekend it was about time to try it out.

What do you need to make a time lapse? Well, the most important thing is the camera. No camera, no pictures, no time-lapse. In addition you should find somewhere (location) with an OK view and a motive where some changes are bound to occur over a longer amount of time than normally. One of the reasons to do a time lapse shoot is to convey a temporal understanding which cannot be understood through a 1:1 time frame. On one hand we can see the tiny details making up a whole macro movement when we shoot a video in extreme slow motion (the opposite of time-lapse), or we can see things which normally occur over a long time span in a shorter presentation. Both these changing of time is one aspect discussed after the introduction of photography and cinematography. No longer were the possibility to document the present limited to painting canvas, it was moved to the domain of mechanical reproduction. Utilizing this we could learn more about the world. The photography did not just change the temporal realm, also the spacial changed: Tiny thing could be viewed as large (electron microscope), big thing could be viewed as small (as in satellite photos). To exemplify the temporal realm exposed to video I’ve added two different movies below. The upper video presents a short amount of time in a long time span, and the other video shows the opposite: A long amount of time presented in a short amount of time

[vimeo]http://vimeo.com/19819283[/vimeo]
[vimeo]http://vimeo.com/18792120[/vimeo]

Pretty cool, right! Well, the first video is shoot on a Phantom Flex which is a pretty amazing camera able to do an impressive amount of exposures each second, but unless you have lots of money to spend on one of those you have to be happy with something which shoots at one third of the Flex’s speed or less. The good news is that making a video like the second can be done with more affordable equipment, so it may be no surprise that I went for the time-lapse function. Here is the result:

[vimeo]http://www.vimeo.com/20725917[/vimeo]

This video is shoot between 5ish and until around 7.30 from the School of Informatics’ offices in the top floor of Appleton Tower in Edinburgh. The presentation lasts from 23 seconds, and shows the view toward McEwan Hall with the old town and the castle in the background. The movement in the frame was unintended, but happened as my tripod (which is 5 cm high) was gaffed to a metal pole close to the window and probably the result of a weak construction with force created by the shutter. In the beginning I shot a picture every 30th, then every 20th and then finally every 10th second. The latter is the frequency which most of the movie is shot, and only a couple of frames are in 30 and 20 second intervals. If you go for a 10 second exposure you will get 360 pictures per hour.

Creating many pictures is not enough; they have to be compiled together into a video file. I did this in a two-step procedure, first by resizing and renaming the files. This was done by a Python script you can find beneath the article. The second thing to do was to make the pictures into a video. As you probably know, the illusion of motion picture is nothing more than still pictures in an ordered sequence running at a higher speed than the absorbance rate of the eyes (and the rest of the cognitive apparatus). The video frame rate here is around 20 pictures per second. The frame rate and the commands to the mencoder encoder are fixed with a shell script from Mario Valle (mencoder.sh) with some modifications to fit the name structure generated by the Python script.

Well, it was very fun setting up the equipment, and the photography process is done without the help from human hand and the result is done almost by itself, so I hope to get more videos of Edinburgh running at a high pace.

The resizing Code

#!/usr/bin/python
import os
import sys
import Image
import re
# You need to create a folder called zepics a subfolder to the executive folder of this script
# The pictures you want to transform has to be in same folder as the script
width = 1290
height = 864
ext = ".jpg"
counter = 0
path = os.getcwd()
dirList=os.listdir(path)
dirList.sort()
for fname in dirList:
if (re.search(".JPG", fname)):
print("Resizing image: "+fname)
im1=Image.open(fname)
im2 = im1.resize((width, height))
tempcounter = 100000 + counter
im2.save("zepics/img"+str(tempcounter) + ext)
counter = counter + 1
else:
print "I could not resize: "+fname

The Arduino Code

int ledPin = 2;
void setup() // run once, when the sketch starts
{
pinMode(ledPin, OUTPUT);
}
void loop()
{
digitalWrite(ledPin, HIGH);
delay(500);
digitalWrite(ledPin, LOW);
delay(10000);
}

The remote controller:

The prototyping board:

Update 21. March

Here is another time lapse video shot from the top of the Appleton Tower, this time the skies are documented. Interestingly did we not see much movement of the skies in chronological clock time, but with a shot taken each 7th second, the movement are clearly visible

[vimeo]http://www.vimeo.com/21238949[/vimeo]