此页面由 AI 自动翻译。查看英文原版
最后更新

本页目录

  • 如何放置
  • 输入和输出
  • 用法
  • 功能示例
  • 参考
Claude CodeCodexCursor
Luxonis 智能体工具包为你常用的编程智能体加载 Luxonis 上下文与技能,更快地基于 OAK 开发应用。
安装工具包

BenchmarkIn

最后更新
Supported on:RVC2RVC4
BenchmarkIn 节点旨在接收消息并测量传入流的每秒帧数 (FPS) 和延迟。它定期生成性能报告,有助于对 DepthAI 管道进行基准测试和性能分析。

如何放置

Python

Python
1import depthai as dai
2
3pipeline = dai.Pipeline()
4benchmarkIn = pipeline.create(dai.node.BenchmarkIn)
5
6# 配置为每 100 条消息发送一次性能报告,并
7# 选择是否将报告记录为警告。
8benchmarkIn.sendReportEveryNMessages(100)
9benchmarkIn.logReportsAsWarnings(False)
10
11# 例如,将 NeuralNetwork 的输出链接到 BenchmarkIn:
12neuralNetwork = pipeline.create(dai.node.NeuralNetwork)
13neuralNetwork.out.link(benchmarkIn.input)

C++

C++
1#include "depthai/depthai.hpp"
2
3dai::Pipeline pipeline;
4auto benchmarkIn = pipeline.create<dai::node::BenchmarkIn>();
5
6// 配置 BenchmarkIn 为每 100 条消息发送一次报告,并
7// 决定是否将报告记录为警告。
8benchmarkIn->sendReportEveryNMessages(100);
9benchmarkIn->logReportsAsWarnings(false);
10
11// 例如,将 NeuralNetwork 的输出链接到 BenchmarkIn:
12auto neuralNetwork = pipeline.create<dai::node::NeuralNetwork>();
13neuralNetwork->out.link(benchmarkIn->input);

输入和输出

用法

BenchmarkIn 通常连接到另一个节点(例如,神经网络或相机节点)的输出,以便它可以监视数据流的性能。该节点定期发出 BenchmarkReport,其中包含 FPS 和延迟等性能指标。

Python

Python
1pipeline = dai.Pipeline()
2
3# 创建一个 BenchmarkIn 节点并配置它:
4benchmarkIn = pipeline.create(dai.node.BenchmarkIn)
5benchmarkIn.sendReportEveryNMessages(100)
6benchmarkIn.logReportsAsWarnings(False)
7
8# 示例:将 BenchmarkIn 连接到 NeuralNetwork 节点
9neuralNetwork = pipeline.create(dai.node.NeuralNetwork)
10neuralNetwork.out.link(benchmarkIn.input)
11
12# 创建一个输出队列以接收基准测试报告
13outputQueue = benchmarkIn.report.createOutputQueue()
14
15while pipeline.isRunning():
16    benchmarkReport = outputQueue.get()
17    print(f"FPS is {benchmarkReport.fps}")

C++

C++
1dai::Pipeline pipeline;
2auto benchmarkIn = pipeline.create<dai::node::BenchmarkIn>();
3benchmarkIn->sendReportEveryNMessages(100);
4benchmarkIn->logReportsAsWarnings(false);
5
6auto neuralNetwork = pipeline.create<dai::node::NeuralNetwork>();
7neuralNetwork->out.link(benchmarkIn->input);
8
9auto outputQueue = benchmarkIn->report.createOutputQueue();
10while(pipeline.isRunning()) {
11    auto benchmarkReport = outputQueue->get<dai::BenchmarkReport>();
12    std::cout << "FPS is " << benchmarkReport.fps << std::endl;
13}

功能示例

参考

class

dai::node::BenchmarkIn

variable
Input input
Receive messages as fast as possible
variable
Output passthrough
Passthrough for input messages (so the node can be placed between other nodes)
variable
Output report
Send a benchmark report when the set number of messages are received
function
void sendReportEveryNMessages(uint32_t n)
Specify how many messages to measure for each report
function
void setRunOnHost(bool runOnHost)
Specify whether to run on host or device By default, the node will run on device.
function
bool runOnHost()
Check if the node is set to run on host
function
void logReportsAsWarnings(bool logReportsAsWarnings)
Log the reports as warnings
function
void measureIndividualLatencies(bool attachLatencies)
Attach latencies to the report
function
void run()
inline function
DeviceNodeCRTP()
inline function
DeviceNodeCRTP(const std::shared_ptr< Device > & device)
inline function
DeviceNodeCRTP(std::unique_ptr< Properties > props)
inline function
DeviceNodeCRTP(std::unique_ptr< Properties > props, bool confMode)
inline function
DeviceNodeCRTP(const std::shared_ptr< Device > & device, std::unique_ptr< Properties > props, bool confMode)

需要帮助?

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