GPUStereo
Supported on:RVC4
device.isGpuStereoSupported(), feeds full-resolution stereo camera outputs into the node, and visualizes the disparity stream.This example requires the DepthAI v3 API, see installation instructions.What it shows
- Runtime capability check with
device.isGpuStereoSupported() - Full-resolution
Cameraoutputs linked intoGPUStereo initialConfig.setConfidenceThreshold(25)startup configuration- Disparity visualization from the
disparityoutput queue
Source code
Python
PythonGitHub
1#!/usr/bin/env python3
2import cv2
3import depthai as dai
4import numpy as np
5
6device = dai.Device()
7if not device.isGpuStereoSupported():
8 print("Exiting GPUStereo example: GPUStereo is not supported on this device.")
9 raise SystemExit(0)
10
11with dai.Pipeline(device) as pipeline:
12 camLeft = pipeline.create(dai.node.Camera).build(dai.CameraBoardSocket.CAM_B)
13 camRight = pipeline.create(dai.node.Camera).build(dai.CameraBoardSocket.CAM_C)
14
15 gpu = pipeline.create(dai.node.GPUStereo)
16 camLeft.requestFullResolutionOutput().link(gpu.left)
17 camRight.requestFullResolutionOutput().link(gpu.right)
18 gpu.initialConfig.setConfidenceThreshold(25)
19
20 dispQ = gpu.disparity.createOutputQueue()
21
22 with pipeline:
23 pipeline.start()
24 while pipeline.isRunning():
25 frame = dispQ.get()
26 d = frame.getFrame().astype(np.float32)
27 d = cv2.normalize(d, None, 0, 255, cv2.NORM_MINMAX).astype(np.uint8)
28 cv2.imshow("GPUStereo Disparity", cv2.applyColorMap(d, cv2.COLORMAP_JET))
29 if cv2.waitKey(1) == ord("q"):
30 breakSimilar samples
- Stereo Depth - Classical stereo depth with a larger configuration surface.
- Neural Assisted Stereo - Fuse neural depth with classical stereo on RVC4.
Need assistance?
Head over to Discussion Forum for technical support or any other questions you might have.