The Stanford Calibration Grid Detector

Vaibhav Vaish

Contents

Introduction

This page describes a program I built to automatically detect a calibration grid in camera images (and provides binaries for download). The basic operation is illustrated below:


Input image

Detected features

Output file of corner coordinates

Detecting the sub-pixel coordinates of image features, such as the corners of a calibration grid, is the first stage any camera calibration algorithm. This grid detector was built as part of the metric calibration pipeline of the Stanford Multi-camera array which consists of 100 cameras. However, this has been used in several other projects in our lab and by some of our colleagues elsewhere, such as:

The key strengths of our grid detector are:

We have successfully used the grid detector on images from different kinds of cameras (including those from our array, a Canon EOS D10, an Olympus 3000Z, Sony DKC-ST5, consumer webcams) on over 10,000 images.


Usage

usage: findgrid <image file> <grid file> <-f config file> [-e|c] [-p side space rows cols] [-t threshold]

findgrid:
Linux binary executable,
download here.

image file:
File containing image you want to run the grid detector on. PPM, PGM, PNG, JPG formats are supported.

grid file:
File name in which the output of the grid detector is written. The output grid file contains the (x,y) coordinates of the corners of grid squares detected, one corner per line. The line format is:

corner-number x-pixel coordinate y-pixel coordinate

Here is an example of a grid file. The corner numbers start at 0, and increase in row-major order. For the 6x6 grid in the example above, there are 6 x 6 = 36 squares and hence 36 x 4 = 144 corners. The top left corner is numbered 0 and the bottom right is 143.

config file:
File containing configuration parameters for the grid detector, download here. To be edited only by developers.

-e|c (optional):
This flag controls the edge detector used. -e results in the use of the Palmer edge detector, which is the default. -c results in use of the Canny edge detector. This is recommended only if the grid squares are large (more than 100 pixels x 100 pixels) in the image or axis aligned. I suggest you try both and go with whichever works better for your images.

-p side space rows cols (optional):
Specifying the geometry of the calibration grid used for verification. side refers to the length of the side of each of the grid squares, space is the distance between two adjacent squares in the same row or column. It is necessary to use the same unit of length for both. rows and cols are the number of rows and columns in the grid.

threshold: (optional)
When the calibration grid geometry is specified with -p, a 2D projective mapping (also called a homography or collineation) is computed between the detected grid squares and the specified calibration grid geometry and the RMS error (in pixels) of the mapping is computed. The user supplied threshold is used to verify the correctness of the grid detection. If the grid has been correctly detected, the RMS error should be small and below the threshold.

In rare cases, the grid detector can miss an entire row or column of squares. This is where the geometry verification is useful: the RMS error is high, and should exceed the threshold, in which case the program will print an error message and no grid file will be written. The default threshold is 1.0 pixel, for correctly detected grids the RMS error averages around 0.35 pixels.

Guidelines


Download

There are two files you need to download:

  1. the linux binary findgrid
  2. the parameter config file params.cfg
The linux binary has been tested on Centos 4.2, Ubuntu 5.04 and Fedora Core 4 distributions. It does require some standard shared libraries to be present on your system (libpng, libjpeg, X libraries) which most distributions should have. Here is a complete list of shared libraries required. The grid detector is based on two vision libraries by Phil McLauchlan et al, Gandalf [2] and Horatio [3] which are statically linked.


Calibration Grids

Here are some of the calibration grids we have used. A laser printer / plotter should print these with reasonable accuracy.

File Name Square Side (mm) Square Spacing (mm) Total Area (mm2)
biggie.pdf 100 50 850 x 850
regular.pdf 50 30 450 x 450
small.pdf 20 10 170 x 170
tiny.pdf 9 6 84 x 84

Grids of any sizes may be used provided they meet the following criteria:

  1. There should be 6 rows and 6 columns of squares, uniformly spaced.
  2. The fourth row (from the top) and the third column (from the left) should have white circles in the center. These special rows and columns are used as a reference when an entire row or column is occluded or not detected.
  3. The spacing between adjacent squares should be 50% of the square side or more.


Questions and Feedback

If you have feedback or questions, please email
calibgrid AT googlegroups dot com. While we cannot promise regular support, source code or additional feature enhancements, we'll do our best to help. We'd be happy to include your work in the list of projects where this program was useful if you like.


References

[1] J. Bouget.
Matlab Camera Calibration Toolbox

[2] Phil McLauchlan. Horatio: a computer vision and image processing library.

[3] Phil McLauchlan. Gandalf: a computer vision and numerical algorithm library.

[4] OpenCV computer vision library.


© Vaibhav Vaish
Last update: January 5, 2006 11:38:23 PM