如何放置
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)输入与输出
使用
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}")功能示例
参考
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 官网 获取技术支持或解答您的任何疑问。