此页面由 AI 自动翻译。查看英文原版
DepthAI
  • DepthAI 组件
    • AprilTags
    • 基准测试
    • 相机
    • 校准
    • 深度
    • 检测网络
    • 事件
    • 特征跟踪器
    • 网关
    • 主机节点
    • 图像对齐
    • 图像处理
    • IMU
    • 杂项
    • 模型库
    • 神经深度
    • 神经网络
    • 对象跟踪器
    • 点云
    • 记录回放
    • RGBD
    • 脚本
    • 空间检测网络
    • 空间位置计算器
    • 立体深度
    • 同步
    • ToF
    • 视频编码器
    • 可视化工具
    • VSLAM
    • 扭曲
    • RVC2-特定
  • 高级教程
  • API 参考
  • 工具
软件栈
最后更新

本页目录

  • 流水线
  • 源代码
Claude CodeCodexCursor
Luxonis 智能体工具包为你常用的编程智能体加载 Luxonis 上下文与技能,更快地基于 OAK 开发应用。
安装工具包

ToF Minimal

最后更新
Supported on:RVC2RVC4
此示例展示了一个最小的 ToF 流水线,并使用色图可视化深度。 有关架构和设置,请参阅 ToF 节点文档。此示例需要 DepthAI v3 API,请参阅 安装说明。

流水线

源代码

Python

Python
GitHub
1#!/usr/bin/env python3
2"""Minimal ToF script showing the main output stream.
3
4Displays depth.
5For more streams, see tof_all_queues.py.
6
7Press 'q' to quit.
8"""
9
10import cv2
11import depthai as dai
12
13FPS = 30.0
14
15
16def main():
17    pipeline = dai.Pipeline()
18
19    minDepth = 100.0
20    maxDepth = 7000.0
21
22    profile = dai.ToFConfig.Profile.MID_RANGE
23
24    tof = pipeline.create(dai.node.ToF).build(
25        boardSocket=dai.CameraBoardSocket.AUTO,
26        profile=profile,
27        fps=FPS,
28    )
29
30    depthOutputQueue = tof.depth.createOutputQueue()
31
32    with pipeline as p:
33        p.start()
34        while p.isRunning():
35            depth = depthOutputQueue.get()
36            cv2.imshow("depth", dai.utility.colorizeDepthFrame(depth, minDepth, maxDepth, useLog=True).getCvFrame())
37
38            if cv2.waitKey(1) == ord("q"):
39                break
40
41
42if __name__ == "__main__":
43    main()

C++

1#include <opencv2/opencv.hpp>
2
3#include "depthai/depthai.hpp"
4
5constexpr float FPS = 30.0f;
6int main() {
7    auto device = std::make_shared<dai::Device>();
8    dai::Pipeline pipeline(device);
9
10    constexpr float minDepth = 100.0f;
11    constexpr float maxDepth = 7000.0f;
12
13    auto profile = dai::ToFConfig::Profile::MID_RANGE;
14
15    auto tof = pipeline.create<dai::node::ToF>()->build(dai::CameraBoardSocket::AUTO, profile, FPS);
16
17    auto depthOutputQueue = tof->depth.createOutputQueue();
18
19    pipeline.start();
20    while(pipeline.isRunning()) {
21        auto depth = depthOutputQueue->get<dai::ImgFrame>();
22        cv::imshow("depth", dai::utility::colorizeDepthFrame(*depth, minDepth, maxDepth, cv::COLORMAP_JET, true).getCvFrame());
23
24        if(cv::waitKey(1) == 'q') {
25            break;
26        }
27    }
28
29    return 0;
30}

需要帮助?

请访问讨论论坛以获取技术支持或您可能有的任何其他问题。