VPI - Vision Programming Interface

0.1.0 Release

Stereo Disparity Estimator

Overview

Given a pair of rectified images from a stereo camera, the Stereo Disparity algorithm uses high-quality dense stereo matching to produce an output image of the same resolution as the input with left-right disparity information. This allows for inferring the depth of the scene captured by the left and right images.

Left imageRight image
Disparity map

Implementation

The stereo disparity estimator uses semi-global matching algorithm to compute the disparity. We deviate from the original algorithm by using as cost function the hamming distance of the census transforms of the stereo pair.

Usage

  1. Initialization phase
    1. Include the header that defines the needed functions and structures.
    2. Define the stream on which the algorithm will be executed, the input stereo pair, composed of two images, and the output disparity image.
      VPIStream stream = /*...*/;
      VPIImage left = /*...*/;
      VPIImage right = /*...*/;
    3. Create the payload that will contain all temporary buffers needed for processing.
      VPIPayload stereo;
      vpiCreateStereoDisparityEstimator(stream, 480, 270, VPI_IMAGE_TYPE_Y16, 64, &stereo);
  2. Processing phase
    1. Define the configuration parameters needed for algorithm execution.
      params.windowSize = 5;
      params.maxDisparity = 64;
    2. Submit the payload for execution on the stream associated with it.
      vpiSubmitStereoDisparityEstimator(stereo, left, right, disparity, &params);
    3. Optionally, wait until the processing is done.
      vpiStreamSync(stream);
  3. Cleanup phase
    1. Free resources held by the payload.

Consult the Stereo Disparity Sample for a complete example.

Limitations and Constraints

Constraints for specific backends superceed the ones specified for all backends.

All Backends

  • Left and right input images must have same type and dimensions.
  • Output image dimensions must match input's.
  • Left and right input images must have type VPI_IMAGE_TYPE_Y16.
  • Output disparity images must have type VPI_IMAGE_TYPE_Y16.
  • Maximum disparity parameter passed to algorithm submission must be the same as defined during payload creation.
  • Input image dimensions must match what is defined during payload creation.

PVA

  • Input and output image dimensions must be 480x270.
  • windowSize must be 5.
  • maxDisparity must be 64.

References

vpiCreateStereoDisparityEstimator
VPIStatus vpiCreateStereoDisparityEstimator(VPIStream stream, uint32_t imageWidth, uint32_t imageHeight, const VPIImageType inputType, const uint32_t maxDisparity, VPIPayload *payload)
Creates payload for vpiSubmitStereoDisparityEstimator.
vpiStreamSync
VPIStatus vpiStreamSync(VPIStream stream)
Blocks the calling thread until all submitted commands in this stream queue are done (queue is empty)...
vpiSubmitStereoDisparityEstimator
VPIStatus vpiSubmitStereoDisparityEstimator(VPIPayload payload, VPIImage left, VPIImage right, VPIImage disparity, const VPIStereoDisparityEstimatorParams *params)
Runs stereo processing on a pair of images, outputs a disparity map.
StereoDisparityEstimator.h
VPI_IMAGE_TYPE_Y16
unsigned 16-bit grayscale/luma.
Definition: Types.h:176
VPIStereoDisparityEstimatorParams::windowSize
uint32_t windowSize
width of Census Transform window for disparity features.
Definition: StereoDisparityEstimator.h:82
VPIImage
struct VPIImageImpl * VPIImage
Definition: Types.h:153
VPIStereoDisparityEstimatorParams::maxDisparity
uint32_t maxDisparity
Maximum disparity for matching search.
Definition: StereoDisparityEstimator.h:83
VPIStereoDisparityEstimatorParams
Structure that defines the parameters for vpiCreateStereoDisparityEstimator.
Definition: StereoDisparityEstimator.h:80
VPIPayload
struct VPIPayloadImpl * VPIPayload
A handle to an algorithm payload.
Definition: Types.h:164
vpiPayloadDestroy
void vpiPayloadDestroy(VPIPayload payload)
Deallocates the payload object and all associated resources.
VPIStream
struct VPIStreamImpl * VPIStream
Definition: Types.h:147