User manual

Small Vision System User Manual 54
svsRIGHT
svsLEFTCOLOR
5.5.4 Stereo Calculation
These functions perform the stereo calculations. The svsCalcStereo function performs the full
stereo calculation from intensity images, including pre-filtering, correlation, and post-filtering. It does
not perform a warping step on the initial images to undistort them; to do this, first call the
svsWarpImage function.
void svsCalcStereo(short *dest, unsigned char *il,
unsigned char *ir, svsSP *sp)
Compute disparity based on the images given in il and ir, and put the result into dest.
Stereo parameters of the image are contained in ps. If ps is NULL, then the global variable
svsParams is used.
To work with the result disparity image (dest), you have to understand how the disparity
image is formatted. There are two issues: how disparities are encoded in pixels, and how
disparity pixels correspond spatially to the original image.
Pixels in the disparity image are short integers (16 bits). For a valid disparity measurement,
a pixel contains a value from 0 to 16n-1, where n is the number of disparities requested in
ps. The factor of 16 appears because disparities are always interpolated to 1/16 pixel. For a
typical disparity search range of 32, valid disparities are 0 to 511.
For pixels that are filtered by the texture measure or left/right check, two special values are
used. 0xFFFF (-1) indicates a texture below the threshold, and 0xFFFE (-2) indicates a
left/right check failure. All valid disparities are positive.
Because of windowing effects, the disparity image is smaller than the original intensity
images. For consistency, the dest array is the same size as the input images. The disparity
values are in the upper left corner of dest, using the same line width as the original image.
The disparity image is spatially registered with the left intensity image. To find
corresponding pixels, consult the following diagram.
The width, height, and offsets of the disparity image vary according to the stereo parameters
in sp. The width and height of the disparity image are affected by the number of disparities,
the size of the correlation window, and the external offsets of the images. The correct offsets
of the disparity image are given by the RESWIDTH, RESLEN, RESTOP, and RESLEFT
macros in src/svs.h. These macros take an svsSP pointer argument, the same one as
given to the svsCalcStereo function.