Stereo tutorial — Basic bricks

This tutorial describes how to calibrate a pair of images and build a simple surface model

To make it simple I have used two stacks of bricks, at known coordinates. Knowing the basic dimensions of a brick, it becomes a simple matter to set up calibration data.

The stereo images are bricks1.tiff, and bricks3.tiff, which you can download and use to try this yourself. Save the files into your Stereo images directory.

 bricks1

bricks3

The dimensional data for a brick and the arrangement shown is detailed in this diagram

bricks-dims

The Calibration file

Write  a text file with the coordinates of 5 or 6 points that you can clearly identify in both images.

Here is the set of points I used. The format is simply x,y,z. Save this file as bricks-cal.txt.

0    106    75
227    106    75
454    106    0
454    1424    0
227    1530    75
0    1530    75

Use the diagram above, to locate each of these points.

I suggest that you make a rough diagram of the bricks and mark the locations of each of your calibration points, in the order that they have been entered into your calibration file (bricks-cal.txt).

Calibrating the images

Start Stereo and load your images. It will probably be necessary to move the image windows and their zoom windows around to get a clear view. Select Load Calibration File in the Command window, and select the file, the select the Green tick (OK) button .

shot1

Now you can start selecting your calibration points, in the same order as in the calibration file. You can do one image, then the other, or you can select each point in turn, in each image.

shot2

When you have selected all the calibration points in each image, you can select Calibrate, in each image window, then select Cam Info to see the camera location data and the estimated errors. Selecting Cam Info acts as a toggle on the camera info window.

shot3

You can Remove All points or Remove last, as required, and re-do the calibration.
When satisfied with the calibration, select Remove All in each image window to start collecting points for a surface.

Collecting data points and surface generation


To collect data points to describe a surface, choose a surface which can be described by a regular array of points in each image. The surface doesn't have to be flat, it can go through a few contortions. The main thing is that there is a regular array of points that be located in each image.

shot4

In the left image window I have selected a 5 x 2 array of points which describes the left vertical surface of the left brick and continues across the top of the 3 bricks. The green crosses show the locations of the points and the red square shows the last point selected.
It is important to maintain a consistent order in selecting the points. The first row (left most 5 points) were  selected first, then the second row selected in the same order. Repeat the process in the second image, following the order of selection. When you have completed selecting all the points to define the surface, Select Triangulate Multiple Points (Surface) in the Command window. You will be asked to enter the width (5 for this example) and height (2), then press the green tick (OK). The data points will be written to the Data window.
Click your mouse left button in the data window (you should see the red cursor begin to blink), then enter Alt-R to display the surface in the Graphics window. You should have a file browser pop up asking for a filename to save the data.
The graphics window may appear blank, but you should see a small green dot in about the centre of the window. That is the data. Select Enlarge as often as required to get a suitable image size. Selecting New rend and Flat Tri will alter the way the surface is depicted. Holding the left mouse button and dragging will rotate the image.

shot5

The data in the data window are the x,y,z coordinates, as best as Stereo can determine them, for the points that you selected to describe the surface.
The last point shown should be 227, 318, 75 if the calibration and point selection were perfect. The data window shows this point at 240, 318, 97 (rounding to nearest integer).
This particular example is not one where high accuracy could be expected, as there are no distinct corners on the bricks, and one has to make an estimate of the location of corners where bricks abut.

You can repeat the process to define more surfaces. Select Remove All in each image window before adding more points.

Here I have added a 2 x 2 array. The points selected shown in the left image window and the new surface has been added to the previous.

shot7

Hopefully, this tutorial shows the basic steps that can be used to develop 3D data describing a surface.

Additional information

To see the effect of not following a consistent order of point selection when defining surface data, try altering the order for subsequent rows or just for the second image selection. 


Tutorial and photos - Terry Duell. Created August 2008