VPI - Vision Programming Interface

0.4.4 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 input rectified stereo pair.
      VPIImage left = /*...*/;
      VPIImage right = /*...*/;
    3. Create the output disparity image.
      uint32_t w, h;
      vpiImageGetSize(left, &w, &h);
      VPIImage disparity;
      vpiImageCreate(w, h, VPI_IMAGE_FORMAT_U16, 0, &disparity);
    4. Create the payload that will contain all temporary buffers needed for processing. It'll be created on the CUDA backend.
    5. Create the stream where the algorithm will be submitted for execution.
      VPIStream stream;
      vpiStreamCreate(0, &stream);
  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 backend associated with it.
      vpiSubmitStereoDisparityEstimator(stream, stereo, left, right, disparity, &params);
    3. Optionally, wait until the processing is done.
      vpiStreamSync(stream);
  3. Cleanup phase
    1. Free resources held by the stream, the payload and the input and ouput images.

Consult the Stereo Disparity Sample for a complete example.

For more details, consult the Stereo Disparity Estimator API reference.

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.
  • Output disparity images must have type VPI_IMAGE_FORMAT_U16.
  • 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.

CUDA and CPU

PVA

  • Only available on Jetson Xavier devices.
  • Left and right accepted input image types:
  • Input and output image dimensions must be 480x270.
  • windowSize must be 5.
  • maxDisparity must be 64.

VIC

  • Not implemented.

Performance

For information on how to use the performance table below, see Algorithm Performance Tables.
Before comparing measurements, consult Comparing Algorithm Elapsed Times.
For further information on how performance was benchmarked, see Performance Measurement.

 - 

References

  • Hirschmüller, Heiko (2005). "Accurate and efficient stereo processing by semi-global matching and mutual information".
    IEEE Conference on Computer Vision and Pattern Recognition. pp. 807–814.
  • Zabih, Ramin; Woodfill, John (1994). "Non-parametric local transforms for computing visual correspondence".
    European conference on computer vision. pp. 151–158.
vpiStreamCreate
VPIStatus vpiStreamCreate(uint32_t flags, VPIStream *stream)
Create a stream instance.
vpiSubmitStereoDisparityEstimator
VPIStatus vpiSubmitStereoDisparityEstimator(VPIStream stream, VPIPayload payload, VPIImage left, VPIImage right, VPIImage disparity, const VPIStereoDisparityEstimatorParams *params)
Runs stereo processing on a pair of images and outputs a disparity map.
VPI_IMAGE_FORMAT_U16
@ VPI_IMAGE_FORMAT_U16
Single plane with one 16-bit unsigned integer channel.
Definition: ImageFormat.h:105
vpiPayloadDestroy
void vpiPayloadDestroy(VPIPayload payload)
Deallocates the payload object and all associated resources.
vpiStreamSync
VPIStatus vpiStreamSync(VPIStream stream)
Blocks the calling thread until all submitted commands in this stream queue are done (queue is empty)...
VPI_BACKEND_CUDA
@ VPI_BACKEND_CUDA
CUDA backend.
Definition: Types.h:91
VPIStream
struct VPIStreamImpl * VPIStream
A handle to a stream.
Definition: Types.h:190
vpiCreateStereoDisparityEstimator
VPIStatus vpiCreateStereoDisparityEstimator(VPIBackend backend, uint32_t imageWidth, uint32_t imageHeight, const VPIImageFormat inputFormat, const uint32_t maxDisparity, VPIPayload *payload)
Creates payload for vpiSubmitStereoDisparityEstimator.
vpiStreamDestroy
void vpiStreamDestroy(VPIStream stream)
Destroy a stream instance and deallocate all HW resources.
vpiImageCreate
VPIStatus vpiImageCreate(uint32_t width, uint32_t height, VPIImageFormat fmt, uint32_t flags, VPIImage *img)
Create an empty image instance with the specified flags.
vpiImageDestroy
void vpiImageDestroy(VPIImage img)
Destroy an image instance.
StereoDisparity.h
Declares functions that implement stereo disparity estimation algorithms.
VPIStereoDisparityEstimatorParams::windowSize
uint32_t windowSize
Width of Census Transform window for disparity features.
Definition: StereoDisparity.h:83
VPIImage
struct VPIImageImpl * VPIImage
A handle to an image.
Definition: Types.h:196
vpiImageGetSize
VPIStatus vpiImageGetSize(VPIImage img, uint32_t *width, uint32_t *height)
Get the image size in pixels.
VPIPayload
struct VPIPayloadImpl * VPIPayload
A handle to an algorithm payload.
Definition: Types.h:208
VPIStereoDisparityEstimatorParams::maxDisparity
uint32_t maxDisparity
Maximum disparity for matching search.
Definition: StereoDisparity.h:84
VPIStereoDisparityEstimatorParams
Structure that defines the parameters for vpiCreateStereoDisparityEstimator.
Definition: StereoDisparity.h:82