MessageGroup

The MessageGroup message type is a versatile container used in DepthAI pipelines to group together a map of arbitrary DepthAI messages. It serves as the primary output of the Sync node, effectively synchronizing various input streams, and acts as the input to the MessageDemux node for subsequent disaggregation and processing.

Creating MessageGroup

MessageGroup can be created automatically by the Sync node as it aligns and groups messages from different sources based on their timestamps. Alternatively, it can be manually constructed in a host application or within a Script node to create custom groupings of DepthAI messages.

Reference

class depthai.MessageGroup

MessageGroup message. Carries multiple messages in one.

getData(self: object) → numpy.ndarray[numpy.uint8]

Get non-owning reference to internal buffer

Returns

Reference to internal buffer

getIntervalNs(self: depthai.MessageGroup)int

Retrieves interval between the first and the last message in the group.

getMessageNames(self: depthai.MessageGroup) → List[str]

Gets the names of messages in the group

getNumMessages(self: depthai.MessageGroup)int
getRaw(self: depthai.ADatatype)depthai.RawBuffer
getSequenceNum(self: depthai.MessageGroup)int

Retrieves sequence number

getTimestamp(self: depthai.MessageGroup)datetime.timedelta

Retrieves timestamp related to dai::Clock::now()

getTimestampDevice(self: depthai.MessageGroup)datetime.timedelta

Retrieves timestamp directly captured from device’s monotonic clock, not synchronized to host time. Used mostly for debugging

isSynced(self: depthai.MessageGroup, arg0: int)bool

True if all messages in the group are in the interval

Parameter thresholdNs:

Maximal interval between messages

setData(*args, **kwargs)

Overloaded function.

  1. setData(self: depthai.Buffer, arg0: List[int]) -> None

Parameter data:

Copies data to internal buffer

  1. setData(self: depthai.Buffer, arg0: numpy.ndarray[numpy.uint8]) -> None

Parameter data:

Copies data to internal buffer

setSequenceNum(self: depthai.MessageGroup, arg0: int)depthai.MessageGroup

Retrieves image sequence number

setTimestamp(self: depthai.MessageGroup, arg0: datetime.timedelta)depthai.MessageGroup

Sets image timestamp related to dai::Clock::now()

setTimestampDevice(self: depthai.MessageGroup, arg0: datetime.timedelta)depthai.MessageGroup

Sets image timestamp related to dai::Clock::now()

class dai::MessageGroup : public dai::Buffer

MessageGroup message. Carries multiple messages in one.

Public Functions

MessageGroup()

Construct MessageGroup message.

MessageGroup(std::shared_ptr<RawMessageGroup> ptr)
~MessageGroup() = default
std::shared_ptr<ADatatype> operator[](const std::string &name)

Group.

template<typename T>
std::shared_ptr<T> get(const std::string &name)
void add(const std::string &name, const std::shared_ptr<ADatatype> &value)
template<typename T>
void add(const std::string &name, const T &value)
std::unordered_map<std::string, std::shared_ptr<ADatatype>>::iterator begin()
std::unordered_map<std::string, std::shared_ptr<ADatatype>>::iterator end()
bool isSynced(int64_t thresholdNs) const

True if all messages in the group are in the interval

Parameters
  • thresholdNs: Maximal interval between messages

int64_t getIntervalNs() const

Retrieves interval between the first and the last message in the group.

int64_t getNumMessages() const
std::vector<std::string> getMessageNames() const

Gets the names of messages in the group

MessageGroup &setTimestamp(std::chrono::time_point<std::chrono::steady_clock, std::chrono::steady_clock::duration> timestamp)

Sets image timestamp related to dai::Clock::now()

MessageGroup &setTimestampDevice(std::chrono::time_point<std::chrono::steady_clock, std::chrono::steady_clock::duration> timestamp)

Sets image timestamp related to dai::Clock::now()

MessageGroup &setSequenceNum(int64_t sequenceNum)

Retrieves image sequence number

Private Functions

std::shared_ptr<RawBuffer> serialize() const override

Private Members

RawMessageGroup &rawGrp
std::unordered_map<std::string, std::shared_ptr<ADatatype>> group

Got questions?

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