MessageDemux

The MessageDemux (Demultiplexer) node is used to separate a MessageGroup into individual outputs. It currently serves as way to demultiplex the output of Sync node.

How to Place It

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

Inputs and Outputs

               ┌───────────────────┐
input          │                   │
──────────────►│                   │
               │    MessageDemux   │        output1
               │                   ├───────────►
               │                   │        output2
               │                   ├───────────►
               │                   │        ...
               └───────────────────┘

Message types

  • input - MessageGroup

  • output1, output2, … - Individual output messages

Usage

The MessageDemux node is particularly useful for handling different types of data coming from a single source. For example, when the Sync node is used to synchronize the outputs of multiple nodes, the output of the Sync node is a MessageGroup containing all the messages from the synchronized nodes. The Demux node can be used to separate the messages into individual streams.

# Create sync node and set sync threshold
sync = pipeline.create(dai.node.Sync)
sync.setSyncThresholdMs(timedelta(milliseconds=100))

# Create demux node
demux = pipeline.create(dai.node.MessageDemux)

# Sync the outputs of multiple nodes
rgb.preview.link(sync.inputs["rgb"])
stereo.depth.link(sync.inputs["depth"])
script.outputs["out"].link(sync.inputs["script"])

sync.out.link(demux.input) # Sync output is a MessageGroup containing all the messages from the synchronized nodes

# Demux the MessageGroup into individual messages
demux.outputs["rgb"].link(xout1.input)
demux.outputs["depth"].link(xout2.input)
demux.outputs["script"].link(xout3.input)
// Create sync node and set sync threshold
auto sync = pipeline.create<dai::node::Sync>();
sync->setSyncThreshold(std::chrono::milliseconds(100));

// Create demux node
auto demux = pipeline.create<dai::node::MessageDemux>();

// Sync the outputs of multiple nodes
rgb.preview.link(sync->input["rgb"]);
stereo.depth.link(sync->input["depth"]);
script.outputs["out"].link(sync->input["script"]);

sync->out.link(demux->input); // Sync output is a MessageGroup containing all the messages from the synchronized nodes

// Demux the MessageGroup into individual messages
demux->outputs["rgb"].link(xout1.input);
demux->outputs["depth"].link(xout2.input);
demux->outputs["script"].link(xout3.input);

Examples of Functionality

Reference

class depthai.node.MessageDemux
class Connection

Connection between an Input and Output

class Id

Node identificator. Unique for every node on a single Pipeline

Properties

alias of depthai.MessageDemuxProperties

getAssetManager(*args, **kwargs)

Overloaded function.

  1. getAssetManager(self: depthai.Node) -> depthai.AssetManager

Get node AssetManager as a const reference

  1. getAssetManager(self: depthai.Node) -> depthai.AssetManager

Get node AssetManager as a const reference

getInputRefs(*args, **kwargs)

Overloaded function.

  1. getInputRefs(self: depthai.Node) -> List[depthai.Node.Input]

Retrieves reference to node inputs

  1. getInputRefs(self: depthai.Node) -> List[depthai.Node.Input]

Retrieves reference to node inputs

getInputs(self: depthai.Node) → List[depthai.Node.Input]

Retrieves all nodes inputs

getName(self: depthai.Node)str

Retrieves nodes name

getOutputRefs(*args, **kwargs)

Overloaded function.

  1. getOutputRefs(self: depthai.Node) -> List[depthai.Node.Output]

Retrieves reference to node outputs

  1. getOutputRefs(self: depthai.Node) -> List[depthai.Node.Output]

Retrieves reference to node outputs

getOutputs(self: depthai.Node) → List[depthai.Node.Output]

Retrieves all nodes outputs

getParentPipeline(*args, **kwargs)

Overloaded function.

  1. getParentPipeline(self: depthai.Node) -> depthai.Pipeline

  2. getParentPipeline(self: depthai.Node) -> depthai.Pipeline

property id

Id of node

property input

Input message of type MessageGroup

property outputs

A map of outputs, where keys are same as in the input MessageGroup

class dai::node::MessageDemux : public dai::NodeCRTP<Node, MessageDemux, MessageDemuxProperties>

Public Functions

MessageDemux(const std::shared_ptr<PipelineImpl> &par, int64_t nodeId)
MessageDemux(const std::shared_ptr<PipelineImpl> &par, int64_t nodeId, std::unique_ptr<Properties> props)

Public Members

Input input = {*this, "input", Input::Type::SReceiver, {{DatatypeEnum::MessageGroup, false}}}

Input message of type MessageGroup

OutputMap outputs

A map of outputs, where keys are same as in the input MessageGroup

Public Static Attributes

static constexpr const char *NAME = "MessageDemux"

Got questions?

Head over to Discussion Forum for technical support or any other questions you might have.