Skip to content

Commit

Permalink
Add custom data example
Browse files Browse the repository at this point in the history
Signed-off-by: Miguel A. Cabrera Minagorri <devgorri@gmail.com>
  • Loading branch information
miguelaeh committed Jan 31, 2024
1 parent 0f27539 commit 9c0bb71
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
3 changes: 3 additions & 0 deletions examples/custom-data/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Pass custom data between stages

Check [this guide](https://www.pipeless.ai/docs/v1/examples/custom-data) to run the example step by step.
19 changes: 19 additions & 0 deletions examples/custom-data/process.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
def hook(frame_data, _):
# Add data to the frame that you can later recover from hooks of subsequent stages. You can also recover it from subsequent hooks of the same stage.
# You can use any kind of data.
# Integers: frame_data['user_data'] = 100
# Floats: frame_data['user_data'] = 100.5
# Strings: frame_data['user_data'] = "Hello!"
# Heterogeneus arrays: frame_data['user_data'] = ["string", 13, 34.6]
# Heterogeneus Dictionaries (IMPORTANT: all keys must be strings):
frame_data['user_data'] = {
"key1": 0,
"key2": [1, "3"],
"key3": { "inner1": "hola" }
}

# In a later hook you can obtain the data like:
# my_data = frame_data['user_data']

# To connect stages simply give the list to Pipeless when adding a stream:
# pipeless add stream --input-uri "file:///home/user/my/path.mp4" --output-uri "screen" --frame-path "stage1,stage2"

0 comments on commit 9c0bb71

Please sign in to comment.