# 缓冲区

就是一个简单的老式缓冲区。所有其他消息都派生自 Buffer 类。

## 参考

### dai::Buffer

Kind: class

Base message - buffer of binary data.

#### int64_t sequenceNum

Kind: variable

#### Timestamp ts

Kind: variable

#### Timestamp tsDevice

Kind: variable

#### std::optional< Timestamp > tsSystem

Kind: variable

#### Buffer()

Kind: function

#### Buffer(size_t size)

Kind: function

#### Buffer(long fd)

Kind: function

#### Buffer(long fd, size_t size)

Kind: function

#### ~Buffer()

Kind: function

#### 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

#### span< uint8_t > getData()

Kind: function

Get non-owning reference to internal buffer.

return: Reference to internal buffer

#### span< const uint8_t > getData()

Kind: function

#### void setData(const std::vector< std::uint8_t > & data)

Kind: function

parameters: data: Copies data to internal buffer

#### void setData(const long fd)

Kind: function

#### void setData(std::vector< std::uint8_t > && data)

Kind: function

parameters: data: Moves data to internal buffer

#### std::chrono::time_point< std::chrono::steady_clock, std::chrono::steady_clock::duration > getTimestamp()

Kind: function

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

#### std::chrono::time_point< std::chrono::steady_clock, std::chrono::steady_clock::duration > getTimestampDevice()

Kind: function

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

#### std::optional< std::chrono::time_point< std::chrono::system_clock, std::chrono::system_clock::duration > >
getTimestampSystem()

Kind: function

Retrieves timestamp directly captured from device's system clock, that can be synchronized using PTP

#### void setTimestamp(std::chrono::time_point< std::chrono::steady_clock, std::chrono::steady_clock::duration > timestamp)

Kind: function

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

#### void setTimestampDevice(std::chrono::time_point< std::chrono::steady_clock, std::chrono::steady_clock::duration > timestamp)

Kind: function

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

#### void setTimestampSystem(std::optional< std::chrono::time_point< std::chrono::system_clock,
std::chrono::system_clock::duration >> timestamp)

Kind: function

Sets optional system_clock timestamp (device system clock; may be PTP-synchronized).

#### int64_t getSequenceNum()

Kind: function

Retrieves image sequence number

#### void setSequenceNum(int64_t sequenceNum)

Kind: function

Sets image sequence number

#### void setBufferMetadataFrom(const Buffer * other)

Kind: function

Copies all metadata from another buffer

#### void setBufferMetadataFrom(const std::shared_ptr< Buffer > & other)

Kind: function

Copies all metadata from another buffer

#### span< const uint8_t > getRecordData()

Kind: function

#### dai::VisualizeType getVisualizationMessage()

Kind: function

Get visualizable message return: Visualizable message, either ImgFrame , ImgAnnotations or std::monostate (None)

#### DEPTHAI_SERIALIZE(Buffer, sequenceNum, ts, tsDevice, tsSystem)

Kind: function

### 需要帮助？

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