depth、amplitude 和 intensity,以及平台特定的 rawDepth (RVC2) 或 confidence (RVC4) 输出。检测到的平台在启动时打印。有关完整的输出/架构参考,请参阅 ToF 节点文档。此示例需要 DepthAI v3 API,请参阅 安装说明。
源代码
Python
PythonGitHub
1#!/usr/bin/env python3
2"""Simple ToF script showing all main ToF output queues.
3
4RVC2 displays: depth, amplitude, intensity, rawDepth.
5RVC4 displays: depth, amplitude, intensity, confidence.
6
7Press 'q' to quit.
8"""
9
10import cv2
11import depthai as dai
12
13FPS = 30.0
14
15
16def normalizeFrame(frame):
17 return cv2.normalize(frame, None, 0, 255, cv2.NORM_MINMAX, cv2.CV_8U)
18
19
20def main():
21 pipeline = dai.Pipeline()
22
23 minDepth = 100.0
24 maxDepth = 7000.0
25
26 profile = dai.ToFConfig.Profile.MID_RANGE
27
28 tof = pipeline.create(dai.node.ToF).build(
29 boardSocket=dai.CameraBoardSocket.AUTO,
30 profile=profile,
31 fps=FPS,
32 )
33
34 with pipeline as p:
35 device = p.getDefaultDevice()
36 isRVC2 = device.getPlatform() == dai.Platform.RVC2
37
38 outputQueues = {
39 "depth": tof.depth.createOutputQueue(maxSize=1, blocking=False),
40 "amplitude": tof.amplitude.createOutputQueue(maxSize=1, blocking=False),
41 "intensity": tof.intensity.createOutputQueue(maxSize=1, blocking=False),
42 }
43 if isRVC2:
44 outputQueues["rawDepth"] = tof.rawDepth.createOutputQueue(maxSize=1, blocking=False)
45 else:
46 outputQueues["confidence"] = tof.confidence.createOutputQueue(maxSize=1, blocking=False)
47
48 platformName = "RVC2" if isRVC2 else "RVC4"
49 print(f"Detected {platformName} - showing queues: {', '.join(outputQueues)}")
50
51 p.start()
52 while p.isRunning():
53 for name, queue in outputQueues.items():
54 frame = queue.tryGet()
55 if frame is None:
56 continue
57
58 if name in {"depth", "rawDepth"}:
59 display = dai.utility.colorizeDepthFrame(frame, minDepth, maxDepth, useLog=True).getCvFrame()
60 else:
61 display = normalizeFrame(frame.getCvFrame())
62 cv2.imshow(name, display)
63
64 if cv2.waitKey(1) == ord("q"):
65 break
66
67
68if __name__ == "__main__":
69 main()需要帮助?
请访问讨论论坛以获取技术支持或您可能有的任何其他问题。