Sync

The Sync node is used for synchronizing multiple input streams based on their timestamps. It outputs a grouped message containing synchronized frames from the input streams. The output message is a MessageGroup containing synchronized messages from all the input streams. These can be demultiplexed using the MessageDemux node.

How to Place it

pipeline = dai.Pipeline()
sync = pipeline.create(dai.node.Sync)
dai::Pipeline pipeline;
auto sync = pipeline.create<dai::node::Sync>();

Inputs and Outputs

               ┌───────────────────┐
input1         │                   │
──────────────►│                   │
input2         │                   │        out
──────────────►│      Sync         ├───────────►
               │                   │
...            │                   │
──────────────►│                   │
               └───────────────────┘

Message types

Message Synchronization

The Sync node aligns incoming messages based on their timestamps. The synchronization criteria and behavior can be configured using the depthai.node.Sync.setSyncThreshold and depthai.node.Sync.setSyncAttempts method. More info in the API Reference.

                            ┌──────────────────────┐
                            │  Get all messages    │
                            │  connected to the    │
                            │     Sync node        │
                            └──────────────────────┘
                                        |
                                        v
                            ┌──────────────────────┐
                            │ Check if messages    │
                            │ are synced (min and  │
                            │ max timestamp diff   │<----------------+
                            │ < threshold)         │                 |
                            └──────────────────────┘                 |
                                        |                            |
┌────────────────────┐                  |                  ┌──────────────────────┐
│    Combine into    │     if synced    |   if not synced  │  Get message with    │
│    MessageGroup    │<-----------------+----------------->│ the oldest timestamp │
└────────────────────┘                                     └──────────────────────┘
          |
          v
  ┌───────────────┐
  │      Out      │
  └───────────────┘

Usage

pipeline = dai.Pipeline()
sync = pipeline.create(dai.node.Sync)

# Configure threshold for timestamp alignment
sync.setSyncThreshold(timedelta(milliseconds=50))

# Configure inputs to be synchronized
camRgb.video.link(sync.inputs["input1"])
stereo.depth.link(sync.inputs["input2"])

sync.output.link(xout.input)
# ...
dai::Pipeline pipeline;
auto sync = pipeline.create<dai::node::Sync>();

// Configure threshold for timestamp alignment
sync->setSyncThreshold(std::chrono::milliseconds(50));

// Configure inputs to be synchronized
camRgb.video.link(sync->input["input1"]);
stereo.depth.link(sync->input["input2"]);

sync->out.link(xout.input);
// ...

Reference

class depthai.node.Sync
class Connection

Connection between an Input and Output

class Id

Node identificator. Unique for every node on a single Pipeline

Properties

alias of depthai.SyncProperties

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

getSyncAttempts(self: depthai.node.Sync)int

Gets the number of sync attempts

getSyncThreshold(self: depthai.node.Sync)datetime.timedelta

Gets the maximal interval between messages in the group in milliseconds

property id

Id of node

property inputs

A map of inputs

property out

Output message of type MessageGroup

setSyncAttempts(self: depthai.node.Sync, maxDataSize: int)None

Set the number of attempts to get the specified max interval between messages in the group

Parameter syncAttempts:

Number of attempts to get the specified max interval between messages in the group: - if syncAttempts = 0 then the node sends a message as soon at the group is filled - if syncAttempts > 0 then the node will make syncAttemts attempts to synchronize before sending out a message - if syncAttempts = -1 (default) then the node will only send a message if successfully synchronized

setSyncThreshold(self: depthai.node.Sync, syncThreshold: datetime.timedelta)None

Set the maximal interval between messages in the group

Parameter syncThreshold:

Maximal interval between messages in the group

class dai::node::Sync : public dai::NodeCRTP<Node, Sync, SyncProperties>

Public Functions

Sync(const std::shared_ptr<PipelineImpl> &par, int64_t nodeId)
Sync(const std::shared_ptr<PipelineImpl> &par, int64_t nodeId, std::unique_ptr<Properties> props)
void setSyncThreshold(std::chrono::nanoseconds syncThreshold)

Set the maximal interval between messages in the group

Parameters
  • syncThreshold: Maximal interval between messages in the group

void setSyncAttempts(int syncAttempts)

Set the number of attempts to get the specified max interval between messages in the group

Parameters
  • syncAttempts: Number of attempts to get the specified max interval between messages in the group:

    • if syncAttempts = 0 then the node sends a message as soon at the group is filled

    • if syncAttempts > 0 then the node will make syncAttemts attempts to synchronize before sending out a message

    • if syncAttempts = -1 (default) then the node will only send a message if successfully synchronized

std::chrono::nanoseconds getSyncThreshold() const

Gets the maximal interval between messages in the group in milliseconds

int getSyncAttempts() const

Gets the number of sync attempts

Public Members

InputMap inputs

A map of inputs

Output out = {*this, "out", Output::Type::MSender, {{DatatypeEnum::MessageGroup, false}}}

Output message of type MessageGroup

Public Static Attributes

static constexpr const char *NAME = "Sync"

Got questions?

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