This article details how users can determine the depth of a pixel based on the disparity image.

To determine the 3d position of a pixel in a disparity image, use one of the following:

triclopsRCD8ToXYZ()

triclopsRCD16ToXYZ()

triclopsRCDFloatToXYZ()

triclopsRCD8ToXYZ() is used when subpixel interpolation disabled and the user obtains a disparity value from the 8 bit TriclopsImage structure.

triclopsRCD16ToXYZ() is used when subpixel interpolation is enabled and the user obtains a disparity value from the 16 bit TriclopsImage16 structure.

triclopsRCDFloatToXYZ() is used when one obtains the disparity measure from other means, such as doing your own feature-based stereo.

The underlying equation that performs this conversion is:

Z = fB/d

where Z = distance along the camera Z axis f = focal length (in pixels) B = baseline (in metres) d = disparity (in pixels)

After Z is determined, X and Y can be calculated using the usual projective camera equations:

X = uZ/f Y = vZ/f

where u and v are the pixel location in the 2D image X, Y, Z is the real 3d position

Note: u and v are not the same as row and column. You must account for the image center. You can get the image center using the triclopsGetImageCenter() function. Then you find u and v by:

u = col - centerCol v = row - centerRow

Note: If u, v, f, and d are all in pixels and X,Y,Z are all in the meters, the units will always work i.e. pixel/pixel = no-unit-ratio = m/m.

How accurate is it?

Accuracy for stereo vision is difficult to exactly quantify, since the accuracy depends on the accuracy of the correlation match, which can depend on the image texture. However, a good "rule of thumb" is to expect a 0.2 matching error in disparity matching. The stereo vision calibration process minimizes the RMS pixel error between the observed and predicted locations of a set of calibration points, as dictated by the camera’s intrinsic and extrinsic values. The calibration of Digiclops and Bumblebee systems is usually within 0.08 pixels RMS error; the rest of the error is attributed to the stereo matching algorithm.

To determine the error at a particular Z value, do the following:

Assume Z = 1.0m

d = fB/Z

Since fB is a constant, you can determine the d value for this Z.

The error in Z would be:

delta Z = |Z - Z'|

where Z' = fB/(d+e) where e is the error in matching. So the whole equation works out to: