DepthAI
  • DepthAI组件
    • AprilTags
    • 基准测试
    • 相机
    • 校准
    • DetectionNetwork
    • 事件
    • FeatureTracker
    • HostNodes
    • ImageAlign
    • ImageManip
    • IMU
    • 杂项
    • 模型库
    • NeuralDepth
    • NeuralNetwork
    • ObjectTracker
    • 点云
    • RecordReplay
    • RGBD
    • 脚本
    • SpatialDetectionNetwork
    • SpatialLocationCalculator
    • StereoDepth
    • 同步
    • VideoEncoder
    • 可视化器
    • VSLAM
    • 扭曲
    • RVC2 特有
  • 高级教程
  • API 参考
  • 工具
软件栈

本页目录

  • 演示
  • 管线
  • 源代码

基准测试相机

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}

需要帮助?

请前往 OAKChina 官网 获取技术支持或解答您的任何疑问。