Packets
数据包
Calculators communicate by sending and receiving packets. Typically a single packet is sent along each input stream at each input timestamp. A packet can contain any kind of data, such as a single frame of video or a single integer detection count.
计算器通过发送和接收数据包进行通信。典型地,在每个输入时间戳沿着每个输入流发送单个分组。数据包可以包含任何类型的数据,例如单个视频帧或单个整数检测计数。
Creating a packet
创建数据包
Packets are generally created with mediapipe::MakePacket<T>()
or mediapipe::Adopt()
(from packet.h).
数据包通常使用mediapipe::MakePacket<T>()或mediapipe::Adopt()(来自packet.h)创建。
// Create a packet containing some new data.
Packet p = MakePacket<MyDataClass>("constructor_argument");
// Make a new packet with the same data and a different timestamp.
Packet p2 = p.At(Timestamp::PostStream());
or:
或
// Create some new data.
auto data = absl::make_unique<MyDataClass>("constructor_argument");
// Create a packet to own the data.
Packet p = Adopt(data.release()).At(Timestamp::PostStream());
Data within a packet is accessed with Packet::Get<T>()
使用packet::Get<T>()访问数据包中的数据