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

本页目录

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

基准测试相机

最后更新
Supported on:RVC2RVC4
此示例展示了 BenchmarkIn 节点的工作原理。它测量了某个消息流的 FPS 和延迟,在本例中是来自相机的视频流。默认情况下,节点将聚合 50 条消息,然后打印(固件警告)FPS 和延迟。 在本例中,即 33.3ms (30fps) * 50 条消息 = 1.665 秒。

演示

Command Line
1Benchmark $ python3.9 benchmark_camera.py
2[18443010211F850E00] [1.1] [3.367] [BenchmarkIn(1)] [warning] FPS: 30.019516
3[18443010211F850E00] [1.1] [3.367] [BenchmarkIn(1)] [warning] Messages took 1.6655831 s
4[18443010211F850E00] [1.1] [3.367] [BenchmarkIn(1)] [warning] Average latency: 0.010152339 s
5[18443010211F850E00] [1.1] [5.067] [BenchmarkIn(1)] [warning] FPS: 30.000103
6[18443010211F850E00] [1.1] [5.067] [BenchmarkIn(1)] [warning] Messages took 1.6666609 s
7[18443010211F850E00] [1.1] [5.067] [BenchmarkIn(1)] [warning] Average latency: 0.010102791 s
8[18443010211F850E00] [1.1] [6.767] [BenchmarkIn(1)] [warning] FPS: 30.000868
此示例需要 DepthAI v3 API,请参阅 安装说明。

流水线

源代码

Python

Python
GitHub
1#!/usr/bin/env python3
2import depthai as dai
3import time
4
5# Create pipeline
6with dai.Pipeline() as pipeline:
7    # Create the nodes
8    cam = pipeline.create(dai.node.Camera).build()
9    benchmarkIn = pipeline.create(dai.node.BenchmarkIn)
10    # benchmarkIn.setRunOnHost(True) # The node can also run on host and include the transfer limitation, default is False
11    output = cam.requestFullResolutionOutput()
12    output.link(benchmarkIn.input)
13
14    pipeline.start()
15    while pipeline.isRunning():
16        time.sleep(1) # Let the logger print out the FPS

C++

1#include <atomic>
2#include <chrono>
3#include <csignal>
4#include <depthai/depthai.hpp>
5#include <thread>
6
7std::atomic<bool> quitEvent(false);
8
9void signalHandler(int) {
10    quitEvent = true;
11}
12
13int main() {
14    signal(SIGTERM, signalHandler);
15    signal(SIGINT, signalHandler);
16
17    // Create pipeline
18    dai::Pipeline pipeline;
19
20    // Create the nodes
21    auto cam = pipeline.create<dai::node::Camera>()->build();
22    auto benchmarkIn = pipeline.create<dai::node::BenchmarkIn>();
23    // benchmarkIn->setRunOnHost(true); // The node can also run on host and include the transfer limitation, default is False
24    auto* output = cam->requestFullResolutionOutput();
25    output->link(benchmarkIn->input);
26
27    pipeline.start();
28    while(pipeline.isRunning() && !quitEvent) {
29        std::this_thread::sleep_for(std::chrono::seconds(1));  // Let the logger print out the FPS
30    }
31
32    pipeline.stop();
33    pipeline.wait();
34
35    return 0;
36}

需要帮助?

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