# MessageGroup

MessageGroup 消息类型是一种通用容器，用于在 DepthAI 流水线中将任意 DepthAI 消息的地图组合在一起。它是
[Sync](https://docs.luxonis.com/software-v3/depthai/depthai-components/nodes/sync.md) 节点的主要输出，有效同步各种输入流，同时也是
[MessageDemux](https://docs.luxonis.com/software-v3/depthai/depthai-components/nodes/message_demux.md) 节点的输入，用于后续拆解和处理。

## 创建 MessageGroup

MessageGroup 可以由 Sync 节点自动创建，因为它会根据时间戳对齐和分组来自不同源的消息。或者，也可以在主机应用程序或
[Script](https://docs.luxonis.com/software-v3/depthai/depthai-components/nodes/script.md) 节点中手动构建，以便创建自定义的 DepthAI 消息分组。

## 参考

### dai::MessageGroup

Kind: class

MessageGroup message. Carries multiple messages in one.

#### std::map< std::string, std::shared_ptr< ADatatype > > group

Kind: variable

#### ~MessageGroup()

Kind: function

#### std::shared_ptr< ADatatype > operator[](const std::string & name)

Kind: function

Group.

#### std::shared_ptr< T > get(const std::string & name)

Kind: function

#### std::shared_ptr< ADatatype > get(const std::string & name)

Kind: function

#### void add(const std::string & name, const std::shared_ptr< ADatatype > & value)

Kind: function

#### std::map< std::string, std::shared_ptr< ADatatype > >::iterator begin()

Kind: function

#### std::map< std::string, std::shared_ptr< ADatatype > >::iterator end()

Kind: function

#### bool isSynced(int64_t thresholdNs)

Kind: function

True if all messages in the group are in the interval parameters: thresholdNs: Maximal interval between messages

#### int64_t getIntervalNs()

Kind: function

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

#### int64_t getNumMessages()

Kind: function

#### std::vector< std::string > getMessageNames()

Kind: function

Gets the names of messages in the group

#### void serialize(std::vector< std::uint8_t > & metadata, DatatypeEnum & datatype)

Kind: function

#### DatatypeEnum getDatatype()

Kind: function

Get the datatype of this specific message.

return: DatatypeEnum

#### DEPTHAI_SERIALIZE(MessageGroup, group, Buffer::ts, Buffer::tsDevice, Buffer::tsSystem, Buffer::sequenceNum)

Kind: function

### 需要帮助？

请前往 [OAKChina 官网](https://www.oakchina.cn/) 获取技术支持或解答您的任何疑问。
