VPI - Vision Programming Interface

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.
      Declares functions that implement stereo disparity estimation algorithms.
    2. Define the input rectified stereo pair.
      VPIImage left = /*...*/;
      VPIImage right = /*...*/;
      struct VPIImageImpl * VPIImage
      A handle to an image.
      Definition: Types.h:197
    3. Create the output disparity image.
      int32_t w, h;
      vpiImageGetSize(left, &w, &h);
      VPIImage disparity;
      vpiImageCreate(w, h, VPI_IMAGE_FORMAT_U16, 0, &disparity);
      @ VPI_IMAGE_FORMAT_U16
      Single plane with one 16-bit unsigned integer channel.
      Definition: ImageFormat.h:110
      VPIStatus vpiImageCreate(int32_t width, int32_t height, VPIImageFormat fmt, uint32_t flags, VPIImage *img)
      Create an empty image instance with the specified flags.
      VPIStatus vpiImageGetSize(VPIImage img, int32_t *width, int32_t *height)
      Get the image size in pixels.
    4. Create the payload that will contain all temporary buffers needed for processing. It'll be created on the CUDA backend.
      VPIPayload stereo;
      struct VPIPayloadImpl * VPIPayload
      A handle to an algorithm payload.
      Definition: Types.h:209
      VPIStatus vpiCreateStereoDisparityEstimator(uint32_t backends, int32_t imageWidth, int32_t imageHeight, VPIImageFormat inputFormat, const VPIStereoDisparityEstimatorCreationParams *params, VPIPayload *payload)
      Creates payload for vpiSubmitStereoDisparityEstimator.
      @ VPI_BACKEND_CUDA
      CUDA backend.
      Definition: Types.h:92
    5. Create the stream where the algorithm will be submitted for execution.
      VPIStream stream;
      vpiStreamCreate(0, &stream);
      struct VPIStreamImpl * VPIStream
      A handle to a stream.
      Definition: Types.h:191
      VPIStatus vpiStreamCreate(uint32_t flags, VPIStream *stream)
      Create a stream instance.
  2. Processing phase
    1. Define the configuration parameters needed for algorithm execution.
      params.windowSize = 5;
      params.maxDisparity = 64;
      int32_t windowSize
      Width of Census Transform window for disparity features.
      int32_t maxDisparity
      Maximum disparity for matching search.
      Structure that defines the parameters for vpiSubmitStereoDisparityEstimator.
    2. Submit the payload for execution on the backend associated with it.
      vpiSubmitStereoDisparityEstimator(stream, VPI_BACKEND_CUDA, stereo, left, right, disparity, NULL, &params);
      VPIStatus vpiSubmitStereoDisparityEstimator(VPIStream stream, uint32_t backend, VPIPayload payload, VPIImage left, VPIImage right, VPIImage disparity, VPIImage confidenceMap, const VPIStereoDisparityEstimatorParams *params)
      Runs stereo processing on a pair of images and outputs a disparity map.
    3. Optionally, wait until the processing is done.
      vpiStreamSync(stream);
      VPIStatus vpiStreamSync(VPIStream stream)
      Blocks the calling thread until all submitted commands in this stream queue are done (queue is empty)...
  3. Cleanup phase
    1. Free resources held by the stream, the payload and the input and ouput images.
      vpiImageDestroy(disparity);
      void vpiImageDestroy(VPIImage img)
      Destroy an image instance.
      void vpiPayloadDestroy(VPIPayload payload)
      Deallocates the payload object and all associated resources.
      void vpiStreamDestroy(VPIStream stream)
      Destroy a stream instance and deallocate all HW resources.

Consult the Stereo Disparity Sample for a complete example.

For more information, see Stereo Disparity Estimator in the "API Reference" section of VPI - Vision Programming Interface.

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 Benchmark.

 - 

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.