2020-06-06 01:49:27 +02:00
|
|
|
---
|
2023-02-28 01:10:16 +01:00
|
|
|
layout: forward
|
|
|
|
target: https://developers.google.com/mediapipe/framework/framework_concepts/packets
|
2020-06-06 01:49:27 +02:00
|
|
|
title: Packets
|
|
|
|
parent: Framework Concepts
|
|
|
|
nav_order: 3
|
|
|
|
---
|
2019-06-17 01:03:25 +02:00
|
|
|
|
2020-06-06 01:49:27 +02:00
|
|
|
# Packets
|
|
|
|
{: .no_toc }
|
|
|
|
|
|
|
|
1. TOC
|
|
|
|
{:toc}
|
|
|
|
---
|
2019-06-17 01:03:25 +02:00
|
|
|
|
2023-04-04 00:12:06 +02:00
|
|
|
**Attention:** *Thanks for your interest in MediaPipe! We have moved to
|
|
|
|
[https://developers.google.com/mediapipe](https://developers.google.com/mediapipe)
|
|
|
|
as the primary developer documentation site for MediaPipe as of April 3, 2023.*
|
|
|
|
|
|
|
|
----
|
|
|
|
|
2021-03-25 23:01:44 +01:00
|
|
|
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.
|
2019-06-17 01:03:25 +02:00
|
|
|
|
2020-06-06 01:49:27 +02:00
|
|
|
## Creating a packet
|
|
|
|
|
2021-03-25 23:01:44 +01:00
|
|
|
Packets are generally created with `mediapipe::MakePacket<T>()` or
|
|
|
|
`mediapipe::Adopt()` (from packet.h).
|
2019-06-17 01:03:25 +02:00
|
|
|
|
|
|
|
```c++
|
2021-03-25 23:01:44 +01:00
|
|
|
// Create a packet containing some new data.
|
|
|
|
Packet p = MakePacket<MyDataClass>("constructor_argument");
|
2019-06-17 01:03:25 +02:00
|
|
|
// Make a new packet with the same data and a different timestamp.
|
|
|
|
Packet p2 = p.At(Timestamp::PostStream());
|
|
|
|
```
|
|
|
|
|
2021-03-25 23:01:44 +01:00
|
|
|
or:
|
|
|
|
|
|
|
|
```c++
|
|
|
|
// 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());
|
|
|
|
```
|
|
|
|
|
2019-06-17 01:03:25 +02:00
|
|
|
Data within a packet is accessed with `Packet::Get<T>()`
|