VPI - Vision Programming Interface

4.0 Release

Multi-Stream Stereo Disparity

Overview

The Multi-Stream Stereo Disparity application demonstrates high-performance stereo processing by utilizing multiple VPI streams concurrently. This sample shows how to process stereo pair images across multiple streams to measure throughput and performance characteristics of the stereo disparity algorithm when running in parallel.

The application loads left and right stereo images, converts them from BGR8 to NV12_BL format through an intermediate Y8_ER conversion, and processes them through multiple VPI streams simultaneously. It measures overall throughput, timing per frame, and can optionally save all processed results.

The C++ implementation provides comprehensive benchmarking capabilities with configurable stream counts and iterations, while the Python version demonstrates the basic multi-stream concept with a simplified interface.

Instructions

The command line parameters differ between the C++ and Python implementations:

C++ Implementation (main.cpp)

<left_image> <right_image> <num_streams> <iterations> [save_outputs]

where

  • left_image: left input image of a rectified stereo pair
  • right_image: right input image of a rectified stereo pair
  • num_streams: number of parallel streams to use for processing
  • iterations: number of processing iterations per stream
  • save_outputs: true to save all input/output images, false for performance mode (optional, defaults to false)

Python Implementation (main.py)

<left> <right>

where

  • left: rectified left input image from a stereo pair
  • right: rectified right input image from a stereo pair

Here are some examples:

  • C++
    ./vpi_sample_20_multistream_stereo ../assets/chair_stereo_left_960.png ../assets/chair_stereo_right_960.png 4 50
    ./vpi_sample_20_multistream_stereo ../assets/chair_stereo_left_960.png ../assets/chair_stereo_right_960.png 8 100 true
  • Python
    python3 main.py ../assets/chair_stereo_left_960.png ../assets/chair_stereo_right_960.png

The C++ examples process the provided stereo pair using 4 streams for 50 iterations (first) and 8 streams for 100 iterations with output saving enabled (second). The Python example demonstrates basic multi-stream processing and saves a single disparity result as disparity.jpg.

Features

  • Multi-Stream Processing: Utilizes multiple VPI streams for concurrent stereo processing
  • Performance Benchmarking: C++ versions measure throughput (FPS), total processing time, and per-frame timing
  • Flexible Input: Accepts PNG, JPEG, and other stereo pair images via command line arguments
  • Multiple Processing Models:
    • Standard multi-stream processing (main.cpp)
    • Simplified Python demonstration (main.py)
  • Format Conversion: Demonstrates BGR8 to NV12_BL conversion pipeline via intermediate Y8_ER format
  • Output Saving: Optional mode in C++ versions to save all disparity results per stream and iteration
  • Configurable Parameters: C++ versions support adjustable stream count and iteration parameters
  • Cross-Language Support: Available in both C++ and Python implementations

Results

C++ Implementation (main.cpp)

The C++ applications print detailed performance metrics including total processing time, average time per frame, and throughput in FPS.

When save_outputs is enabled (set to "true"), the application generates a result per stream and per iteration as follows:

  • Disparity results: stream_XX_iter_YYYY_disparity.png
  • Confidence results: stream_XX_iter_YYYY_confidence.png

Python Implementation (main.py)

The Python application generates a single output file:

  • Disparity result: disparity.jpg

Source Code

For convenience, here's the code that is also installed in the samples directory.

Language:
27 import sys
28 import vpi
29 import numpy as np
30 from PIL import Image
31 from argparse import ArgumentParser
32 
33 
34 def process_arguments():
35  parser = ArgumentParser()
36  parser.add_argument('left', help='Rectified left input image from a stereo pair')
37  parser.add_argument('right', help='Rectified right input image from a stereo pair')
38  return parser.parse_args()
39 
40 
41 def process_stereo_pair(args):
42  """
43  Process stereo image pair to generate disparity map.
44 
45  This is the full script of the python code referenced in the Boston Dynamics Blog (link here)
46 
47  Args:
48  args: Parsed command-line arguments containing left and right image paths
49 
50  Raises:
51  FileNotFoundError: If input images cannot be found
52  ValueError: If images are invalid or incompatible
53  RuntimeError: If VPI operations fail
54  """
55  # The VPIStream object is the main entry point to the API. It is loosely based on CUDA's
56  # cudaStream_t. This object represents a FIFO command queue which stores a list of commands
57  # to be executed by some backend. Here, we create two streams - the left stream handles format
58  # conversion for the left image as well as the actual stereo disparity operation, and the right
59  # stream handles format conversion for the right image.
60  streamLeft = vpi.Stream()
61  streamRight = vpi.Stream()
62 
63  # VPI's Python API natively utilizes numpy as the memory backend for storing images.
64  # Here, we load the stereo image pair into numpy arrays and then wrap them as VPI images.
65  try:
66  left_img = np.asarray(Image.open(args.left))
67  right_img = np.asarray(Image.open(args.right))
68  except FileNotFoundError as e:
69  raise FileNotFoundError(f"Could not open image file: {e}")
70  except Exception as e:
71  raise ValueError(f"Error loading images: {e}")
72 
73  try:
74  left = vpi.asimage(left_img)
75  right = vpi.asimage(right_img)
76  except Exception as e:
77  raise RuntimeError(f"Failed to create VPI images: {e}")
78 
79  # We now submit the image conversion operations in parallel on two different streams.
80  try:
81  left = left.convert(vpi.Format.Y8_ER, scale=1, stream=streamLeft, backend=vpi.Backend.CPU)
82  left = left.convert(vpi.Format.NV12_BL, scale=1, stream=streamLeft, backend=vpi.Backend.VIC)
83  right = right.convert(vpi.Format.Y8_ER, scale=1, stream=streamRight, backend=vpi.Backend.CPU)
84  right = right.convert(vpi.Format.NV12_BL, scale=1, stream=streamRight, backend=vpi.Backend.VIC)
85  except Exception as e:
86  raise RuntimeError(f"Image format conversion failed: {e}")
87 
88  # After converting the images to the correct format, we now want to submit the StereoDisparity
89  # operation. We are going to submit this on streamRight, which means that it will naturally wait
90  # for the right image to be done converting before running. But what about the left image?
91  # VPI provides synchronization operations to handle cases just like this - here we can use the
92  # most simple one. We call streamLeft.sync(), which will block the calling thread until
93  # leftStream is done processing and we can then submit the Stereo Disparity operation safely.
94  try:
95  streamLeft.sync()
96  disparityS16 = vpi.stereodisp(
97  left, right, backend=vpi.Backend.OFA | vpi.Backend.PVA | vpi.Backend.VIC, stream=streamRight
98  )
99  except Exception as e:
100  raise RuntimeError(f"Stereo disparity computation failed: {e}")
101 
102  # After some post-processing steps, we are done! We can then utilize VPI's zero-copy mapping
103  # to OpenCV to create a nice OpenCV visualization of our resulting disparity map.
104  try:
105  disparityU8 = disparityS16.convert(
106  vpi.Format.U8, scale=255.0 / (32 * 128), stream=streamRight, backend=vpi.Backend.CPU
107  )
108  streamRight.sync()
109  Image.fromarray(disparityU8.cpu()).save('./disparity.jpg')
110  except Exception as e:
111  raise RuntimeError(f"Failed to save disparity output: {e}")
112 
113 
114 def main():
115  """Main entry point for stereo disparity processing."""
116  try:
117  # Verify VPI can be used before processing arguments
118  # This prevents core dumps from VPI initialization issues
119  try:
120  _ = vpi.Stream()
121  except Exception as e:
122  print(f"Error: VPI initialization failed: {e}", file=sys.stderr)
123  print("Please check VPI installation and hardware support.", file=sys.stderr)
124  return 1
125 
126  args = process_arguments()
127  process_stereo_pair(args)
128  return 0
129  except FileNotFoundError as e:
130  print(f"Error: {e}", file=sys.stderr)
131  return 1
132  except ValueError as e:
133  print(f"Error: {e}", file=sys.stderr)
134  return 1
135  except RuntimeError as e:
136  print(f"Error: {e}", file=sys.stderr)
137  return 1
138  except Exception as e:
139  print(f"Unexpected error: {e}", file=sys.stderr)
140  return 1
141 
142 
143 if __name__ == '__main__':
144  sys.exit(main())
145 
0 /*
1 * Copyright (c) 2025, NVIDIA CORPORATION. All rights reserved.
2 *
3 * Redistribution and use in source and binary forms, with or without
4 * modification, are permitted provided that the following conditions
5 * are met:
6 * * Redistributions of source code must retain the above copyright
7 * notice, this list of conditions and the following disclaimer.
8 * * Redistributions in binary form must reproduce the above copyright
9 * notice, this list of conditions and the following disclaimer in the
10 * documentation and/or other materials provided with the distribution.
11 * * Neither the name of NVIDIA CORPORATION nor the names of its
12 * contributors may be used to endorse or promote products derived
13 * from this software without specific prior written permission.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
16 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
19 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
22 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
23 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27 
28 #include <opencv2/core/version.hpp>
29 #if CV_MAJOR_VERSION >= 3
30 # include <opencv2/imgcodecs.hpp>
31 #else
32 # include <opencv2/contrib/contrib.hpp> // for colormap
33 # include <opencv2/highgui/highgui.hpp>
34 #endif
35 
36 #include <opencv2/imgproc/imgproc.hpp>
37 #include <vpi/OpenCVInterop.hpp>
38 
39 #include <vpi/Event.h>
40 #include <vpi/Image.h>
41 #include <vpi/Status.h>
42 #include <vpi/Stream.h>
44 #include <vpi/algo/Rescale.h>
46 
47 #include <algorithm>
48 #include <cctype>
49 #include <cstring>
50 #include <iostream>
51 #include <sstream>
52 #include <thread>
53 
54 #define CHECK_STATUS(STMT) \
55  do \
56  { \
57  VPIStatus status = (STMT); \
58  if (status != VPI_SUCCESS) \
59  { \
60  char buffer[VPI_MAX_STATUS_MESSAGE_LENGTH]; \
61  vpiGetLastStatusMessage(buffer, sizeof(buffer)); \
62  std::ostringstream ss; \
63  ss << "line " << __LINE__ << " " << vpiStatusGetName(status) << ": " << buffer; \
64  throw std::runtime_error(ss.str()); \
65  } \
66  } while (0);
67 
68 int main(int argc, char *argv[])
69 {
70  // OpenCV image that will be wrapped by a VPIImage.
71  // Define it here so that it's destroyed *after* wrapper is destroyed
72  cv::Mat cvImageLeft, cvImageRight;
73 
74  try
75  {
76  // =============================
77  // Parse command line parameters
78  if (argc != 5 && argc != 6)
79  {
80  throw std::runtime_error(std::string("Usage: ") + argv[0] + " " +
81  "<left_image> <right_image> <num_streams> <iterations> [save_outputs:true|false]");
82  }
83 
84  std::string strLeftFileName = argv[1];
85  std::string strRightFileName = argv[2];
86  int numStreams = std::stoi(argv[3]);
87  int itersPerStream = std::stoi(argv[4]);
88  bool saveOutput = false;
89 
90  if (argc == 6)
91  {
92  std::string arg5(argv[5]);
93  std::transform(arg5.begin(), arg5.end(), arg5.begin(), ::tolower);
94  saveOutput = (arg5 == "true");
95  }
96 
97  if (numStreams <= 0 || itersPerStream <= 0)
98  {
99  throw std::runtime_error("Number of streams and iterations must be positive.");
100  }
101 
102  // =====================
103  // Load the input images
104  cvImageLeft = cv::imread(strLeftFileName);
105  if (cvImageLeft.empty())
106  {
107  throw std::runtime_error("Can't open '" + strLeftFileName + "'");
108  }
109  cvImageRight = cv::imread(strRightFileName);
110  if (cvImageRight.empty())
111  {
112  throw std::runtime_error("Can't open '" + strRightFileName + "'");
113  }
114 
115  // ====================
116  // Stereo algorithm parameters
117  constexpr int MAX_DISPARITY_VALUE = 128;
118  constexpr int STEREO_WINDOW_SIZE = 5;
119 
120  // ====================
121  // Declare VPI Objects
122  int totalIterations = itersPerStream * numStreams;
123  std::vector<VPIImage> leftInputs(numStreams), rightInputs(numStreams), leftTmps(numStreams),
124  rightTmps(numStreams);
125  std::vector<VPIImage> leftOuts(numStreams), rightOuts(numStreams);
126  std::vector<VPIImage> disparities, confidences;
127  std::vector<VPIPayload> stereoPayloads(numStreams);
128  std::vector<VPIStream> streamsLeft(numStreams), streamsRight(numStreams);
129  std::vector<VPIEvent> events(numStreams);
130  int width = cvImageLeft.cols;
131  int height = cvImageLeft.rows;
132  const uint64_t supportedBackends = VPI_BACKEND_VIC | VPI_BACKEND_OFA | VPI_BACKEND_PVA;
133  VPIStereoDisparityEstimatorCreationParams stereoPayloadParams;
135  CHECK_STATUS(vpiInitStereoDisparityEstimatorCreationParams(&stereoPayloadParams));
136  CHECK_STATUS(vpiInitStereoDisparityEstimatorParams(&stereoParams));
137  stereoPayloadParams.maxDisparity = MAX_DISPARITY_VALUE;
138  stereoParams.maxDisparity = MAX_DISPARITY_VALUE;
139  stereoParams.windowSize = STEREO_WINDOW_SIZE;
141 
142  // ====================
143  // Initialize VPI Objects
144  for (int i = 0; i < numStreams; i++)
145  {
146  CHECK_STATUS(vpiImageCreateWrapperOpenCVMat(cvImageLeft, 0, &leftInputs[i]));
147  CHECK_STATUS(vpiImageCreateWrapperOpenCVMat(cvImageRight, 0, &rightInputs[i]));
148  CHECK_STATUS(vpiStreamCreate(0, &streamsLeft[i]));
149  CHECK_STATUS(vpiStreamCreate(0, &streamsRight[i]));
150  CHECK_STATUS(vpiImageCreate(width, height, VPI_IMAGE_FORMAT_Y8_ER, 0, &leftTmps[i]));
151  CHECK_STATUS(vpiImageCreate(width, height, VPI_IMAGE_FORMAT_NV12_BL, 0, &leftOuts[i]));
152  CHECK_STATUS(vpiImageCreate(width, height, VPI_IMAGE_FORMAT_Y8_ER, 0, &rightTmps[i]));
153  CHECK_STATUS(vpiImageCreate(width, height, VPI_IMAGE_FORMAT_NV12_BL, 0, &rightOuts[i]));
154  CHECK_STATUS(vpiCreateStereoDisparityEstimator(supportedBackends, width, height, VPI_IMAGE_FORMAT_NV12_BL,
155  &stereoPayloadParams, &stereoPayloads[i]));
156  CHECK_STATUS(vpiEventCreate(0, &events[i]));
157  }
158  int outCount = saveOutput ? (numStreams * itersPerStream) : numStreams;
159  disparities.resize(outCount);
160  confidences.resize(outCount);
161  for (int i = 0; i < outCount; i++)
162  {
163  CHECK_STATUS(vpiImageCreate(width, height, VPI_IMAGE_FORMAT_S16, 0, &disparities[i]));
164  CHECK_STATUS(vpiImageCreate(width, height, VPI_IMAGE_FORMAT_U16, 0, &confidences[i]));
165  }
166 
167  // ====================
168  // Perform format conversion
169  for (int i = 0; i < numStreams; i++)
170  {
171  CHECK_STATUS(
172  vpiSubmitConvertImageFormat(streamsLeft[i], VPI_BACKEND_CPU, leftInputs[i], leftTmps[i], NULL));
173  CHECK_STATUS(vpiSubmitConvertImageFormat(streamsLeft[i], VPI_BACKEND_VIC, leftTmps[i], leftOuts[i], NULL));
174  CHECK_STATUS(vpiEventRecord(events[i], streamsLeft[i]));
175  CHECK_STATUS(
176  vpiSubmitConvertImageFormat(streamsRight[i], VPI_BACKEND_CPU, rightInputs[i], rightTmps[i], NULL));
177  CHECK_STATUS(
178  vpiSubmitConvertImageFormat(streamsRight[i], VPI_BACKEND_VIC, rightTmps[i], rightOuts[i], NULL));
179  CHECK_STATUS(vpiStreamWaitEvent(streamsRight[i], events[i]));
180  }
181  for (int i = 0; i < numStreams; i++)
182  {
183  CHECK_STATUS(vpiStreamSync(streamsLeft[i]));
184  CHECK_STATUS(vpiStreamSync(streamsRight[i]));
185  }
186 
187  // ====================
188  // Start Benchmarking
189  auto benchmarkStart = std::chrono::high_resolution_clock::now();
190  for (int iter = 0; iter < itersPerStream; iter++)
191  {
192  for (int i = 0; i < numStreams; i++)
193  {
194  int dispIdx = saveOutput ? (i * itersPerStream + iter) : i;
195  CHECK_STATUS(vpiSubmitStereoDisparityEstimator(streamsRight[i], supportedBackends, stereoPayloads[i],
196  leftOuts[i], rightOuts[i], disparities[dispIdx],
197  confidences[dispIdx], &stereoParams));
198  }
199  }
200  // ====================
201  // End Benchmarking
202  for (int i = 0; i < numStreams; i++)
203  {
204  CHECK_STATUS(vpiStreamSync(streamsRight[i]));
205  }
206  auto benchmarkEnd = std::chrono::high_resolution_clock::now();
207  int64_t totalTime =
208  std::chrono::duration_cast<std::chrono::microseconds>(benchmarkEnd - benchmarkStart).count();
209 
210  // ====================
211  // Save Outputs
212  if (saveOutput)
213  {
214  for (int i = 0; i < numStreams * itersPerStream; i++)
215  {
216  VPIImageData dispData, confData;
217  cv::Mat cvDisparity, cvDisparityColor, cvConfidence, cvMask;
218  CHECK_STATUS(
220  vpiImageDataExportOpenCVMat(dispData, &cvDisparity);
221  cvDisparity.convertTo(cvDisparity, CV_8UC1, 255.0 / (32 * stereoParams.maxDisparity), 0);
222  applyColorMap(cvDisparity, cvDisparityColor, cv::COLORMAP_JET);
223  CHECK_STATUS(vpiImageUnlock(disparities[i]));
224  std::ostringstream fpStream;
225  fpStream << "stream_" << i / itersPerStream << "_iter_" << i % itersPerStream << "_disparity.png";
226  imwrite(fpStream.str(), cvDisparityColor);
227 
228  // Confidence output (U16 -> scale to 8-bit and save)
229  CHECK_STATUS(
231  vpiImageDataExportOpenCVMat(confData, &cvConfidence);
232  cvConfidence.convertTo(cvConfidence, CV_8UC1, 255.0 / 65535.0, 0);
233  CHECK_STATUS(vpiImageUnlock(confidences[i]));
234  std::ostringstream fpStreamConf;
235  fpStreamConf << "stream_" << i / itersPerStream << "_iter_" << i % itersPerStream << "_confidence.png";
236  imwrite(fpStreamConf.str(), cvConfidence);
237  }
238  }
239 
240  // ====================
241  // Clean Up VPI Objects
242  // NOTE: This sample uses explicit cleanup for simplicity. In production code,
243  // use RAII wrappers for VPI resources to ensure automatic cleanup even if
244  // exceptions occur during processing.
245  for (int i = 0; i < numStreams; i++)
246  {
247  CHECK_STATUS(vpiStreamSync(streamsLeft[i]));
248  CHECK_STATUS(vpiStreamSync(streamsRight[i]));
249  vpiStreamDestroy(streamsLeft[i]);
250  vpiStreamDestroy(streamsRight[i]);
251  vpiImageDestroy(rightInputs[i]);
252  vpiImageDestroy(leftInputs[i]);
253  vpiImageDestroy(leftTmps[i]);
254  vpiImageDestroy(leftOuts[i]);
255  vpiImageDestroy(rightTmps[i]);
256  vpiImageDestroy(rightOuts[i]);
257  vpiPayloadDestroy(stereoPayloads[i]);
258  vpiEventDestroy(events[i]);
259  }
260  // Destroy all disparity and confidence images
261  for (int i = 0; i < (int)disparities.size(); i++)
262  {
263  vpiImageDestroy(disparities[i]);
264  }
265  for (int i = 0; i < (int)confidences.size(); i++)
266  {
267  vpiImageDestroy(confidences[i]);
268  }
269 
270  // ====================
271  // Output benchmarking data
272  double totalTimeSeconds = totalTime / 1000000.0;
273  double avgTimePerFrame = totalTimeSeconds / totalIterations;
274  double throughputFPS = totalIterations / totalTimeSeconds;
275 
276  std::cout << "\n" << std::string(70, '=') << std::endl;
277  std::cout << "SIMPLE MULTI-STREAM RESULTS" << std::endl;
278  std::cout << std::string(70, '=') << std::endl;
279  std::cout << "Total time: " << totalTimeSeconds << " seconds" << std::endl;
280  std::cout << "Avg time per frame: " << (avgTimePerFrame * 1000) << " ms" << std::endl;
281  std::cout << "THROUGHPUT: " << throughputFPS << " FPS" << std::endl;
282  std::cout << std::string(70, '=') << std::endl;
283 
284  return 0;
285  }
286  catch (std::exception &e)
287  {
288  std::cerr << e.what() << std::endl;
289  return 1;
290  }
291 }
Declares functions that handle image format conversion.
Functions and structures for dealing with VPI events.
#define VPI_IMAGE_FORMAT_NV12_BL
YUV420sp 8-bit block-linear format with limited range.
Definition: ImageFormat.h:210
#define VPI_IMAGE_FORMAT_U16
Single plane with one 16-bit unsigned integer channel.
Definition: ImageFormat.h:111
#define VPI_IMAGE_FORMAT_S16
Single plane with one 16-bit signed integer channel.
Definition: ImageFormat.h:120
#define VPI_IMAGE_FORMAT_Y8_ER
Single plane with one pitch-linear 8-bit unsigned integer channel with full-range luma (grayscale) in...
Definition: ImageFormat.h:159
Functions and structures for dealing with VPI images.
Functions for handling OpenCV interoperability with VPI.
Declares functions that implement the Rescale algorithm.
Declaration of VPI status codes handling functions.
Declares functions that implement stereo disparity estimation algorithms.
Declares functions dealing with VPI streams.
VPIStatus vpiSubmitConvertImageFormat(VPIStream stream, uint64_t backend, VPIImage input, VPIImage output, const VPIConvertImageFormatParams *params)
Converts the image contents to the desired format, with optional scaling and offset.
VPIStatus vpiEventRecord(VPIEvent event, VPIStream stream)
Captures in the event the contents of the stream command queue at the time of this call.
VPIStatus vpiEventCreate(uint64_t flags, VPIEvent *event)
Create an event instance.
void vpiEventDestroy(VPIEvent event)
Destroy an event instance as well as all resources it owns.
void vpiImageDestroy(VPIImage img)
Destroy an image instance.
VPIStatus vpiImageLockData(VPIImage img, VPILockMode mode, VPIImageBufferType bufType, VPIImageData *data)
Acquires the lock on an image object and returns the image contents.
VPIStatus vpiImageCreate(int32_t width, int32_t height, VPIImageFormat fmt, uint64_t flags, VPIImage *img)
Create an empty image instance with the specified flags.
VPIStatus vpiImageUnlock(VPIImage img)
Releases the lock on an image object.
@ VPI_IMAGE_BUFFER_HOST_PITCH_LINEAR
Host-accessible with planes in pitch-linear memory layout.
Definition: Image.h:176
Stores information about image characteristics and content.
Definition: Image.h:238
VPIStatus vpiImageCreateWrapperOpenCVMat(const cv::Mat &mat, VPIImageFormat fmt, uint64_t flags, VPIImage *img)
Wraps a cv::Mat in an VPIImage with the given image format.
VPIStatus vpiImageDataExportOpenCVMat(const VPIImageData &imgData, cv::Mat *mat)
Fills an existing cv::Mat with data from VPIImageData coming from a locked VPIImage.
void vpiPayloadDestroy(VPIPayload payload)
Deallocates the payload object and all associated resources.
int32_t maxDisparity
Maximum disparity for matching search.
VPIStereoDisparityConfidenceType confidenceType
Computation type to produce the confidence output.
int32_t windowSize
Represents the median filter size on OFA+PVA+VIC backend or census transform window size (other backe...
int32_t maxDisparity
Maximum disparity for matching search.
VPIStatus vpiInitStereoDisparityEstimatorCreationParams(VPIStereoDisparityEstimatorCreationParams *params)
Initializes VPIStereoDisparityEstimatorCreationParams with default values.
VPIStatus vpiCreateStereoDisparityEstimator(uint64_t backends, int32_t imageWidth, int32_t imageHeight, VPIImageFormat inputFormat, const VPIStereoDisparityEstimatorCreationParams *params, VPIPayload *payload)
Creates payload for vpiSubmitStereoDisparityEstimator.
VPIStatus vpiInitStereoDisparityEstimatorParams(VPIStereoDisparityEstimatorParams *params)
Initializes VPIStereoDisparityEstimatorParams with default values.
VPIStatus vpiSubmitStereoDisparityEstimator(VPIStream stream, uint64_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.
@ VPI_STEREO_CONFIDENCE_RELATIVE
The U16 confidence value of a pixel is given by: [ 1 - abs(D_lr - D_rl) / D_lr ] * 0xFFFF.
Structure that defines the parameters for vpiCreateStereoDisparityEstimator.
Structure that defines the parameters for vpiSubmitStereoDisparityEstimator.
VPIStatus vpiStreamWaitEvent(VPIStream stream, VPIEvent event)
Pushes a command that blocks the processing of all future commands submitted to the stream until the ...
VPIStatus vpiStreamSync(VPIStream stream)
Blocks the calling thread until all submitted commands in this stream queue are done (queue is empty)...
void vpiStreamDestroy(VPIStream stream)
Destroy a stream instance and deallocate all HW resources.
VPIStatus vpiStreamCreate(uint64_t flags, VPIStream *stream)
Create a stream instance.
@ VPI_BACKEND_PVA
PVA backend.
Definition: Types.h:94
@ VPI_BACKEND_OFA
OFA backend.
Definition: Types.h:96
@ VPI_BACKEND_VIC
VIC backend.
Definition: Types.h:95
@ VPI_BACKEND_CPU
CPU backend.
Definition: Types.h:92
@ VPI_LOCK_READ
Lock memory only for reading.
Definition: Types.h:621