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

本页目录

  • 如何放置
  • 输入和输出
  • 用法
  • 功能示例
  • 参考

BenchmarkOut

Supported on:RVC2RVC4
BenchmarkOut 节点会监听第一个传入的消息,然后以指定的帧率(FPS)重复发送该消息的副本。 这在需要模拟连续输入流时非常有用,可以帮助您测试管道的性能。

如何放置

Python

Python
1import depthai as dai
2
3pipeline = dai.Pipeline()
4benchmarkOut = pipeline.create(dai.node.BenchmarkOut)
5
6# 选择节点是在主机上运行还是在设备上运行
7benchmarkOut.setRunOnHost(False)
8# 设置所需的输出帧率(FPS)
9benchmarkOut.setFps(30)
10
11# 要初始化,请发送单个输入消息(例如,一个 ImgFrame)
12inputQueue = benchmarkOut.input.createInputQueue()
13# 根据需要创建和配置初始帧
14initialFrame = dai.ImgFrame()
15inputQueue.send(initialFrame)

C++

C++
1#include "depthai/depthai.hpp"
2
3dai::Pipeline pipeline;
4auto benchmarkOut = pipeline.create<dai::node::BenchmarkOut>();
5
6// 选择是在主机上运行还是在设备上运行,并设置输出 FPS
7benchmarkOut->setRunOnHost(false);
8benchmarkOut->setFps(30);
9
10// 要初始化节点,请发送单个帧
11auto inputQueue = benchmarkOut->input.createInputQueue();
12dai::ImgFrame initialFrame;
13// 根据需要初始化 initialFrame...
14inputQueue->send(initialFrame);

输入和输出

用法

Python

Python
1pipeline = dai.Pipeline()
2benchmarkOut = pipeline.create(dai.node.BenchmarkOut)
3benchmarkOut.setRunOnHost(True)
4benchmarkOut.setFps(30)
5
6# 发送单个帧以初始化输出流。
7inputQueue = benchmarkOut.input.createInputQueue()
8initialFrame = dai.ImgFrame()
9# (根据需要初始化 initialFrame)
10inputQueue.send(initialFrame)
11
12# 示例:将 BenchmarkOut 的输出链接到 BenchmarkIn 节点以进行性能测量。
13benchmarkIn = pipeline.create(dai.node.BenchmarkIn)
14benchmarkOut.out.link(benchmarkIn.input)
15
16outputQueue = benchmarkIn.report.createOutputQueue()
17while pipeline.isRunning():
18    benchmarkReport = outputQueue.get()
19    print(f"FPS is {benchmarkReport.fps}")

C++

C++
1#include "depthai/depthai.hpp"
2
3dai::Pipeline pipeline;
4auto benchmarkOut = pipeline.create<dai::node::BenchmarkOut>();
5benchmarkOut->setRunOnHost(true);
6benchmarkOut->setFps(30);
7
8// 发送单个帧以初始化流
9auto inputQueue = benchmarkOut->input.createInputQueue();
10dai::ImgFrame initialFrame;
11// 根据需要初始化 initialFrame...
12inputQueue->send(initialFrame);
13
14// 示例:将 BenchmarkOut 的输出链接到 BenchmarkIn 节点以测量性能。
15auto benchmarkIn = pipeline.create<dai::node::BenchmarkIn>();
16benchmarkOut->out.link(benchmarkIn->input);
17
18auto outputQueue = benchmarkIn->report.createOutputQueue();
19while(pipeline.isRunning()) {
20    auto benchmarkReport = outputQueue->get<dai::BenchmarkReport>();
21    std::cout << "FPS is " << benchmarkReport.fps << std::endl;
22}

功能示例

参考

class

dai::node::BenchmarkOut

variable
Output out
Send messages out as fast as possible
variable
Input input
Message that will be sent repeatedly
function
void setNumMessagesToSend(int num)
Sets number of messages to send, by default send messages indefinitely
Parameters
  • num: number of messages to send
function
void setFps(float fps)
Set FPS at which the node is sending out messages. 0 means as fast as possible
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 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)

需要帮助?

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