本页目录

  • 如何放置
  • 输入与输出
  • 使用
  • 功能示例
  • 参考

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// 选择在主机上运行还是在设备上运行,并设置输出帧率
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 为 {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 为 " << 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)

需要帮助?

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