Difference between revisions of "Time lapse stabilization"

From PanoTools.org Wiki
Jump to: navigation, search
m (post processing)
(preparing the images)
Line 43: Line 43:
Two of my images (Scaled to 0.4 of what I worked with):
Two of my images (Scaled to 0.4 of what I worked with):
[[image:Timelapse_pre1.jpg]] [[image:Timelapse_pre2.jpg]]
=== Steps in hugin ===  
=== Steps in hugin ===  

Revision as of 07:36, 3 July 2008

Time Lapse stabilization

Remember the shaky videos of rockets being launched from the old days?

Did you see the modern NASA videos , where the FRAME bounces around the object being filmed, while the rocket remains perfectly stable in view? Thats' what you'll be able to do after reading this tutorial.

Why and when?

Sometimes you find yourselves with some time on your hand, a nice camera, a nice scene that would look nice in a time lapse movie, but no tripod and/or computer to take shots in exactly the same position in an exact time-sequence.

Just point the camera at what you want in your timelapse, and take shots, at regular intervals, as consistent in time delay and direction as you want/can.

You can play a sequence of jpgs using mplayer with:

  mplayer -mf fps=12  mf://\*.jpg

If you put the shots together like this the image will bounce and shake a lot, because you didn't point the camera in exactly the same direction every time.... This is where tripods excel above humans.

So, hugin to the rescue!

preparing the images

First, I reduced the size of all the jpgs by a factor of 4 in each direction. This gave me frames of about video quality, greatly reducing the amount of CPU time required to process the many images.

 mkdir small
 for i in *.jpg; do
     echo "$i "
     djpeg $i | pnmscale 0.25 | cjpeg > small/$i
 cd small

Two of my images (Scaled to 0.4 of what I worked with):

Timelapse pre1.jpg Timelapse pre2.jpg

Steps in hugin

I then started up hugin and loaded all the images.

Now to match all the images I have to do the control points manually, because this is not the "normal" use of hugin. However, for someone intimate with the workings of Hugin and the surrounding tools, it should be quite possible to modify one of the tools to allow doing this automatically in the future.

On the control-points tab, select image 0 on the left, and image 1 on the right. Now match two or three points in the image.

Next, you would normally match image 1 to image 2, and so on. In this case I recommend you match every image to image 0. So next you create several controlpoint matches on images 0 against image 2.

Next, I selected "equirectangular" for both the source images (under the "camera and lens" tab) and the destination (under the "stitcher" tab) (this may acutally not be the best selection, as hugin might also correct for lens distortion on the way. But at least it keeps things simple...)

Next, click "optimize now".

Next, I selected "high quality tiff" and "nona" as the stitcher. This triggers the creation of intermediate TIFF files which we're interested in.

Next click: "calculate field of view" in the stitcher tab, and "calculate optimal size".

Next, click "stitch now". In my case, the final enblend step crashed due to an installation error. This is ideal: We don't need it. Consider making the binary not executable for the duration of this project, or putting another program of the same name in your path, or configuring hugin to call some program that doesn't exist.

post processing

After entering the name "test.tif" as the output file, you will be left with realigned tiff files called test????.tif! You can then convert these to jpeg with:

   for i in test????.tif ; do
      tifftopnm $i | cjpeg > $i.jpg

now you can play them with:

   mplayer -mf fps=12 mf://\test\*.tif.jpg

The bouncing should be greatly reduced!

Here are two of the resulting images.

Timelapse post1.jpg Timelapse post2.jpg

final words

The inline scripts in this page are written in "bash". If you use tcsh, the syntax is slightly different. If you're on MS Windows, I don't know how you achieve such operations.

This tutoral was written by R.E.Wolff@BitWizard.nl . Feel free to Email me with suggestions or ways to do this easier. As this is a WIKI you could also edit this directly.

In newer versions of hugin, an application "align_image_stack" is available. This is not yet released, but a windows application executable is available. Unix users will have to get and compile from the subversion source.