此页面由 AI 自动翻译。查看英文原版
DepthAI
  • DepthAI 组件
    • AprilTags
    • 基准测试
    • Camera
    • 校准
    • DetectionNetwork
    • Events
    • FeatureTracker
    • Gate
    • HostNodes
    • ImageAlign
    • ImageManip
    • IMU
    • 杂项
    • 模型动物园
    • NeuralDepth
    • NeuralNetwork
    • ObjectTracker
    • 点云
    • RecordReplay
    • RGBD
    • Script
    • SpatialDetectionNetwork
    • SpatialLocationCalculator
    • StereoDepth
    • Sync
    • VideoEncoder
    • Visualizer
    • Warp
    • RVC2-specific
  • 高级教程
  • API 参考
  • 工具
软件栈

本页目录

  • 演示
  • 流水线
  • 源代码

基准测试相机

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

演示

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}

需要帮助?

请前往 Discussion Forum 获取技术支持或提出您可能有的任何其他问题。