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
input1
,input2
, … - any message type from Messagesout
- MessageGroup
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.out.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);
// ...
Examples of Functionality¶
Reference¶
-
class
depthai.node.
Sync
-
class
Id
Node identificator. Unique for every node on a single Pipeline
-
getAssetManager
(*args, **kwargs) Overloaded function.
getAssetManager(self: depthai.Node) -> depthai.AssetManager
getAssetManager(self: depthai.Node) -> depthai.AssetManager
-
getInputRefs
(*args, **kwargs) Overloaded function.
getInputRefs(self: depthai.Node) -> list[depthai.Node.Input]
getInputRefs(self: depthai.Node) -> list[depthai.Node.Input]
-
getInputs
(self: depthai.Node) → list[depthai.Node.Input]
-
getName
(self: depthai.Node) → str
-
getOutputRefs
(*args, **kwargs) Overloaded function.
getOutputRefs(self: depthai.Node) -> list[depthai.Node.Output]
getOutputRefs(self: depthai.Node) -> list[depthai.Node.Output]
-
getOutputs
(self: depthai.Node) → list[depthai.Node.Output]
-
getParentPipeline
(*args, **kwargs) Overloaded function.
getParentPipeline(self: depthai.Node) -> depthai.Pipeline
getParentPipeline(self: depthai.Node) -> depthai.Pipeline
-
getSyncAttempts
(self: depthai.node.Sync) → int
-
getSyncThreshold
(self: depthai.node.Sync) → datetime.timedelta
-
setSyncAttempts
(self: depthai.node.Sync, maxDataSize: int) → None
-
setSyncThreshold
(self: depthai.node.Sync, syncThreshold: datetime.timedelta) → None
-
class
-
class
dai::node
::
Sync
: public dai::NodeCRTP<Node, Sync, SyncProperties>¶ Public Functions
-
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"¶
-
void