mediapipe/docs/framework_concepts/packets.md
2023-04-03 15:12:06 -07:00

1.3 KiB

layout target title parent nav_order
forward https://developers.google.com/mediapipe/framework/framework_concepts/packets Packets Framework Concepts 3

Packets

{: .no_toc }

  1. TOC {:toc}

Attention: Thanks for your interest in MediaPipe! We have moved to https://developers.google.com/mediapipe as the primary developer documentation site for MediaPipe as of April 3, 2023.


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).

// 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>()