How is depth determined from a disparity image?
KB Number: 10102
Last Revision Date: 3/5/2014 3:13:13 PM
Created Date: 3/5/2014 3:13:13 PM
This article details how users can determine the depth of a pixel based on the disparity image.
The easy answer is one should use one of:
to determine the 3d position of a pixel in a disparity image.
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
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
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 PGR 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:
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 then be:
delta Z = |Z - Z'|
Z' = fB/(d+e) where e is the error in matching. So the whole equation works out to:
delta Z = | fB/d - fB/(d+e) |