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

本页目录

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

MessageDemux

Supported on:RVC2RVC4
MessageDemux(多路分离器)节点用于将 MessageGroup 分离成独立的输出。它目前用作分离 Sync 节点输出的一种方式。

如何放置

Python

Python
1pipeline = dai.Pipeline()
2demux = pipeline.create(dai.node.MessageDemux)

C++

C++
1dai::Pipeline pipeline;
2auto demux = pipeline.create<dai::node::MessageDemux>();

输入和输出

用法

MessageDemux 节点特别适用于处理来自单个源的不同类型的数据。 例如,当使用 Sync 节点同步多个节点的输出时,Sync 节点的输出是一个 MessageGroup,其中包含来自同步节点的全部消息。Demux 节点可用于将消息分离成单独的流。

Python

Python
1# 创建 sync 节点并设置同步阈值
2sync = pipeline.create(dai.node.Sync)
3sync.setSyncThresholdMs(timedelta(milliseconds=100))
4
5# 创建 demux 节点
6demux = pipeline.create(dai.node.MessageDemux)
7
8# 同步多个节点的输出
9rgb.preview.link(sync.inputs["rgb"])
10stereo.depth.link(sync.inputs["depth"])
11script.outputs["out"].link(sync.inputs["script"])
12
13sync.out.link(demux.input) # Sync 输出是一个包含来自同步节点的全部消息的 MessageGroup
14
15# 将 MessageGroup 解复用到单独的消息
16demux.outputs["rgb"].link(xout1.input)
17demux.outputs["depth"].link(xout2.input)
18demux.outputs["script"].link(xout3.input)

C++

C++
1// 创建 sync 节点并设置同步阈值
2auto sync = pipeline.create<dai::node::Sync>();
3sync->setSyncThreshold(std::chrono::milliseconds(100));
4
5// 创建 demux 节点
6auto demux = pipeline.create<dai::node::MessageDemux>();
7
8// 同步多个节点的输出
9rgb.preview.link(sync->input["rgb"]);
10stereo.depth.link(sync->input["depth"]);
11script.outputs["out"].link(sync->input["script"]);
12
13sync->out.link(demux->input); // Sync 输出是一个包含来自同步节点的全部消息的 MessageGroup
14
15// 将 MessageGroup 解复用到单独的消息
16demux->outputs["rgb"].link(xout1.input);
17demux->outputs["depth"].link(xout2.input);
18demux->outputs["script"].link(xout3.input);

功能示例

参考

class

dai::node::MessageDemux

variable
Input input
Input message of type MessageGroup
variable
OutputMap outputs
A map of outputs, where keys are same as in the input MessageGroup
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()
function
void setProcessor(ProcessorType type)
Specify on which processor the node should run. RVC2 only.
Parameters
  • type: Processor type - Leon CSS or Leon MSS
function
ProcessorType getProcessor()
Get on which processor the node should run
Returns
Processor type - Leon CSS or Leon MSS
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 获取技术支持或提出您可能有的任何其他问题。