Stereo Vision: Triangulation

Luca Iocchi

Dipartimento di Informatica e Sistemistica
Università di Roma "La Sapienza", Italy.


1. Introduction

Triangulation in stereo analysis is the task of computing the 3D position of points in the images, given the disparity map and the geometry of the stereo setting.


2. Camera Model

The pinhole camera model is often used for 3D reconstruction.

The relation between the world coordinates of a point P(X,Y,Z) and the coordinates on the image plane (x,y) in a pinhole camera is

x = f * X / Z

y = f * Y / Z

where f is the focal distance of the lens.

2.1 From frame to image coordinates

A digitalized image is usually stored in a frame buffer, that can be seen as a matrix of pixels with W columns and H rows. Let (i,j) be the discrete frame coordinates of the image with origin in the upperleft corner, (Ox,Oy) be the focal point of the lens (the intersection between the optical axes and the image plane) in the frame coordinates, and (x,y) be the image coordinates.

Camera Coordinates

Image coordinates relate to frame coordinates in the following way:

x = ( i - Ox ) * Sx

y = ( j - Oy ) * Sy

where Sx,Sy are the horizontal and vertical distances of two adjacent pixels in the frame buffer.

2.2 Radial distortion

Lens distortion can be modelled by the following equations:

x = xd * ( 1 + k1 * rd^2 )

y = yd * ( 1 + k1 * rd^2 )

where (xd,yd) are the image coordinates of the distorted image, rd = SQRT(xd^2 + yd^2), and k1 is a constant depending on the distortion of the lens.

The relation between image and frame coordinates in presence of lens distortion is:

x = ( id - Ox ) * Sx * ( 1 + k1 * rd^2 )

y = ( jd - Oy ) * Sy * ( 1 + k1 * rd^2 )

2.3 Scanning and sampling

If the distances of two adjacent cells in the camera digitalization device are known (Px,Py), then the distances of pixels in the image are

Sx = ax * Px

Sy = Py

where ax is a scale factor due to the displacement in horizontal scanning and sampling frequencies. On the contrary, there is no displacement in vertical sampling.


3. Triangulation

The 3D position (X,Y,Z) of a point P, can be reconstructed from the perspective projection of P on the image planes of the cameras, once the relative position and orientation of the two cameras are known.

We choose the 3D world reference system to be the left camera reference system. The right camera is translated and rotated with respect from the left one, therefore six parameters describe this transformation.
The simplest case arise when the optical axes of two cameras are parallel, and the translation of the right camera is only along the X axis.

4.1 Geometry for parallel cameras

Let us consider the optical setting in the figure, that is also called standard model.

  1. L and R are two pinhole cameras with parallel optical axes. Let f be the focal length of both cameras.
  2. The baseline (that is the line connecting the two lens centers) is perpendicular to the optical axes. Let b be the distance between the two lens centers.
  3. XZ is the plane where the optical axes lie, XY plane is parallel to the image plane of both cameras, X axis equals the baseline and the origin O of (X,Y,Z) world reference system is the lens center of the left camera.

Stereo Triangulation

In this setting the equations of stereo triangulation are:

Z = ( b * f ) / ( x1 - x2 )

X = x1 * Z / f

Y = y1 * Z / f

4.2 Non-parallel cameras

In the general case, the right camera can be rotated with respect to the left one in three directions. In all this section we assume that rotation angles are small (small angle approximation).

Rotation around Y axis (theta)

In this case the optical axes are not parallel, but they both lie on the XZ plane, so they intersect in a point (0,0,Z0), that is called fixation point and could also be behind the cameras (Z0<0).
If theta is the rotation angle, then Z0 = b / tan(theta).

Under small angle approximation, we can still assume the right image plane to be parallel to the left image plane and hence to XY plane.

Non Parallel Stereo Triangulation

In this case we have:

Z = ( b * f ) / ( x1 - x2 + f * b / Z0 )

X = x1 * Z / f

Y = y1 * Z / f

Rotation around X axis (phi)

Rotation around X axis only affects the Y coordinate in reconstruction. Let phi be the rotation angle, then stereo triangulation is

Z = ( b * f ) / ( x1 - x2 )

X = x1 * Z / f

Y = y1 * Z / f + tan(phi) * Z

Rotation around Z axis (psi)

Rotation around optical axis is usually dealt with by rotating the image before applying matching and triangulation.
In the following the rotation angle of the right camera around its optical axis will be called psi.

4.3 General case

Given the translation vector T and rotation matrix R describing the transormation from left camera to right camera coordinates, the equation to solve for stereo triangulation is

p' = RT ( p - T )

where p and p' are the coordinates of P in the left and right camera coordinates respectively, and RT is the transpose (or the inverse) matrix of R.


Luca Iocchi. April 6 1998.

Go to:
Multiresolution Stereo Vision System
Stereo Camera Calibration
Hough Internal Calibration