About Us Virtual Tours News Partners Contact  
 

Simple Lens Calibration Tutorial

This tutorial describes lens calibration for your Free Hugin Panorama Stitcher to obtain lens parameters a, b, c.

Note The pre-release version has been used for this tutorial. Your version may differ slightly butthe underlying principle will remain the same.

The method used here is to set up some straight lines which pass near the edge of the photograph and across the photo near the image centre. The lines do not have to be parallel, but they do need to be straight and either have a sharp edge or be fine enough to ensure that points selected on them define a straight line.

'Straight lines' in Hugin are defined by a special kind of control point called a straight line control point.

For this example I have set out four pegs in my lawn which roughly define a 4m square and then run a taut string line around the pegs and on one diagonal. The string used is a twisted red and white polypropylene of about 1mm diameter, which provides a very fine line. The alternating red and white helps locate the string against the background. I photographed the image from a step ladder.

You can download this image (p1010230.jpg) and try it yourself.

scr_230

Start by launching Hugin, and using the Assistant tab select the 1. Load images button to select the image for the project.

Select the Camera and Lens tab and check the Geometric data. The lens data should be automatically extracted (as shown in the last screen shot, below). The Radial Distortion parameters should all be zero.

Select the Control Points tab. The image should be shown in both image windows. Select your first point near the end of one of the string lines. I started near the left hand end of the string line near the lower edge of the image. Be sure to get your point as close to the centreline of the string as you can. Now choose a 'matching' point near the other end of this string line in the second image. It may be necessary to set the zoom to 100% or even higher.

Set mode: to Add New Line. The alignment should say Line 3.

Add additional point pairs working in from each end of the string line to give reasonably spaced points, each time setting alignment to Line 3. It may be necessary to switch the zoom back to "Fit to Window" between points to get a good overall view of the control points.

Add a second set of points along the diagonal string line, again working in from each end. After the first point set mode: add new line to ensure that Hugin understands that this set corresponds to a different straight line (Line 4).

scr_shot-2

Select the Stitcher tab and set the projection to Rectilinear.

Select the Optimizer tab and set Quick Optimizer to the custom parameters below, then tick the Lens Parameters boxes Distortion (a):, Barrel (b):, and Distortion (c):, then select Optimize now!. If the results show very small errors select Yes to apply the changes.

scr_shot-3

Select the Camera and Lens tab to view the lens distortion parameters.

scr_shot-4

The lens parameters I obtained were a=0.00104, b=-0.00169 and c=0.00509. The lens calibration data can be saved using the Save lens... button, and used in future Hugin projects.

It should only be necessary to use two straight lines for this exercise.

Further information

For extra accuracy add more points to more 'straight lines', but to avoid confusion just add to the project an extra photo of the same scene from a slightly different angle. Put your new 'straight lines' in this photo, when you optimise, both images will be optimised together.

The same technique can be used to optimise fisheye photos, just ensure that the output Projection is always Rectilinear. You will find that the entire fisheye image doesn't fit into a 'rectilinear' output, so just work with half of the photo, hugin will assume that the distortion is symmetrical.

Other techniques for calibrating a lens include:

  • Stitching a normal panorama and optimising Positions, View and Barrel. The advantage of this is that hugin will calculate lens angle of view (FoV) as well. The disadvantage is that with lots of parameters to optimise, hugin has less chance to be very accurate correcting lens distortion. (note: to get a really accurate FoV you need a 360° panorama)
  • Alternatively, horizontal control and vertical control points can be used to correct perspective and optimise lens parameters at the same time. Again, this technique can also be used to calculate lens FoV, the disadvantage is that you need an object such as a building with exactly perpendicular features for your sample photos.

Tutorial and photos — Terry Duell. Created July 2008 - Modified 2009 by Salvatore Cardu

 

Jump to Following Panorama Tutorials

Author and images Ed Halley — Created November 2003
 
Home  |  About Us  |  Virtual Tours  |  Partners  |  Contact  |  Terms & Conditions
© Copyright 2004 - 2008 VR2020.com
About Us Virtual Tours Virtual Tour News Virtual Tour Partners Contact Us