ON THIS PAGE

  • How to place it
  • Inputs and Outputs
  • Usage
  • Reference
  • Examples of functionality

GPUStereo

Supported on:RVC4
GPUStereo computes disparity and depth from a synchronized stereo pair on the RVC4 GPU. It accepts either live camera outputs or already-rectified frames, with built-in rectification enabled by default.

How to place it

GPUStereo is a device node, so create the pipeline with a dai.Device instance.

Python

Python
1import depthai as dai
2
3device = dai.Device()
4if not device.isGpuStereoSupported():
5    raise RuntimeError("GPUStereo is not supported on this device.")
6
7with dai.Pipeline(device) as pipeline:
8    cam_left = pipeline.create(dai.node.Camera).build(dai.CameraBoardSocket.CAM_B)
9    cam_right = pipeline.create(dai.node.Camera).build(dai.CameraBoardSocket.CAM_C)
10
11    gpu = pipeline.create(dai.node.GPUStereo)
12    cam_left.requestFullResolutionOutput().link(gpu.left)
13    cam_right.requestFullResolutionOutput().link(gpu.right)

C++

C++
1#include <depthai/depthai.hpp>
2
3auto device = std::make_shared<dai::Device>();
4if(!device->isGpuStereoSupported()) {
5    throw std::runtime_error("GPUStereo is not supported on this device.");
6}
7
8dai::Pipeline pipeline(device);
9auto camLeft = pipeline.create<dai::node::Camera>();
10auto camRight = pipeline.create<dai::node::Camera>();
11camLeft->build(dai::CameraBoardSocket::CAM_B);
12camRight->build(dai::CameraBoardSocket::CAM_C);
13
14auto gpu = pipeline.create<dai::node::GPUStereo>();
15camLeft->requestFullResolutionOutput()->link(gpu->left);
16camRight->requestFullResolutionOutput()->link(gpu->right);

Inputs and Outputs

  • disparity outputs RAW16 disparity data.
  • depth outputs RAW16 depth data in the configured depth unit, millimeters by default.
  • confidenceMap outputs an 8-bit confidence map where lower values indicate lower-confidence matches.

Usage

The public startup configuration for GPUStereo is intentionally small in 3.7.1. initialConfig exposes confidenceThreshold, and you can disable internal rectification when providing already-rectified inputs.

Python

Python
1import depthai as dai
2
3device = dai.Device()
4
5with dai.Pipeline(device) as pipeline:
6    cam_left = pipeline.create(dai.node.Camera).build(dai.CameraBoardSocket.CAM_B)
7    cam_right = pipeline.create(dai.node.Camera).build(dai.CameraBoardSocket.CAM_C)
8
9    gpu = pipeline.create(dai.node.GPUStereo)
10    cam_left.requestFullResolutionOutput().link(gpu.left)
11    cam_right.requestFullResolutionOutput().link(gpu.right)
12
13    gpu.initialConfig.setConfidenceThreshold(25)
14    # If your inputs are already rectified, disable internal rectification.
15    # gpu.setRectification(False)
16
17    disp_q = gpu.disparity.createOutputQueue()
18    depth_q = gpu.depth.createOutputQueue()

C++

C++
1#include <depthai/depthai.hpp>
2
3auto device = std::make_shared<dai::Device>();
4dai::Pipeline pipeline(device);
5
6auto camLeft = pipeline.create<dai::node::Camera>();
7auto camRight = pipeline.create<dai::node::Camera>();
8camLeft->build(dai::CameraBoardSocket::CAM_B);
9camRight->build(dai::CameraBoardSocket::CAM_C);
10
11auto gpu = pipeline.create<dai::node::GPUStereo>();
12camLeft->requestFullResolutionOutput()->link(gpu->left);
13camRight->requestFullResolutionOutput()->link(gpu->right);
14
15gpu->initialConfig->setConfidenceThreshold(25);
16// If your inputs are already rectified, disable internal rectification.
17// gpu->setRectification(false);
18
19auto dispQ = gpu->disparity.createOutputQueue();
20auto depthQ = gpu->depth.createOutputQueue();

Reference

class

dai::node::GPUStereo

#include GPUStereo.hpp
variable
Subnode< Sync > sync
variable
Subnode< MessageDemux > messageDemux
variable
std::unique_ptr< Subnode< Rectification > > rectification
variable
Input & left
variable
Input & right
variable
Input leftInternal
variable
Input rightInternal
variable
Output disparity
Outputs ImgFrame message that carries RAW16 encoded disparity data.
variable
Output depth
Outputs ImgFrame message that carries RAW16 encoded (0..65535) depth data in depth units (millimeter by default).Non-determined / invalid depth values are set to 0
variable
Output confidenceMap
Outputs ImgFrame message that carries RAW8 confidence map. Lower values mean lower confidence of the calculated disparity value. Note: postprocessing steps like LR-check/median filter are not applied to confidence map.
variable
std::shared_ptr< GPUStereoConfig > initialConfig
Initial config to use for GPUStereo.Use this to configure startup parameters before the pipeline starts. Note: Only
function
GPUStereo()
function
std::shared_ptr< GPUStereo > build(Output & left, Output & right)
function
GPUStereo & setRectification(bool enable)
function
void buildInternal()

Examples of functionality

  • GPUStereo - Run GPU-accelerated stereo on RVC4 and visualize the disparity output.

Need assistance?

Head over to Discussion Forum for technical support or any other questions you might have.