chore: import upstream snapshot with attribution
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
<!--[metadata]
|
||||
title = "Incremental logging"
|
||||
tags = ["3D", "API example"]
|
||||
thumbnail = "https://static.rerun.io/incremental_logging/b7a2bd889b09c3840f56dc31bd6d677934ab3126/480w.png"
|
||||
thumbnail_dimensions = [480, 301]
|
||||
-->
|
||||
|
||||
Showcases how to incrementally log data belonging to the same archetype, and re-use some or all of it across frames.
|
||||
|
||||
<picture data-inline-viewer="examples/incremental_logging">
|
||||
<img src="https://static.rerun.io/incremental_logging/b7a2bd889b09c3840f56dc31bd6d677934ab3126/full.png" alt="">
|
||||
<source media="(max-width: 480px)" srcset="https://static.rerun.io/incremental_logging/b7a2bd889b09c3840f56dc31bd6d677934ab3126/480w.png">
|
||||
<source media="(max-width: 768px)" srcset="https://static.rerun.io/incremental_logging/b7a2bd889b09c3840f56dc31bd6d677934ab3126/768w.png">
|
||||
<source media="(max-width: 1024px)" srcset="https://static.rerun.io/incremental_logging/b7a2bd889b09c3840f56dc31bd6d677934ab3126/1024w.png">
|
||||
<source media="(max-width: 1200px)" srcset="https://static.rerun.io/incremental_logging/b7a2bd889b09c3840f56dc31bd6d677934ab3126/1200w.png">
|
||||
</picture>
|
||||
|
||||
To build it from a checkout of the repository (requires a Rust toolchain):
|
||||
```bash
|
||||
python examples/python/incremental_logging/increamental_logging.py
|
||||
```
|
||||
@@ -0,0 +1,62 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Showcases how to incrementally log data belonging to the same archetype, and re-use some or all of it across frames."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
|
||||
from numpy.random import default_rng
|
||||
|
||||
import rerun as rr
|
||||
|
||||
parser = argparse.ArgumentParser(description="Showcases how to incrementally log data belonging to the same archetype.")
|
||||
rr.script_add_args(parser)
|
||||
args = parser.parse_args()
|
||||
|
||||
|
||||
README = """\
|
||||
# Incremental Logging
|
||||
|
||||
This example showcases how to incrementally log data belonging to the same archetype, and re-use some or all of it across frames.
|
||||
|
||||
It was logged with the following code:
|
||||
```python
|
||||
# Only log colors and radii once.
|
||||
# Logging as static would also work (i.e. `static=True`).
|
||||
rr.set_time("frame_nr", sequence=0)
|
||||
rr.log("points", rr.Points3D.from_fields(colors=0xFF0000FF, radii=0.1))
|
||||
|
||||
rng = default_rng(12345)
|
||||
|
||||
# Then log only the points themselves each frame.
|
||||
#
|
||||
# They will automatically re-use the colors and radii logged at the beginning.
|
||||
for i in range(10):
|
||||
rr.set_time("frame_nr", sequence=i)
|
||||
rr.log("points", rr.Points3D.from_fields(positions=rng.uniform(-5, 5, size=[10, 3])))
|
||||
```
|
||||
|
||||
Move the time cursor around, and notice how the colors and radii from frame 0 are still picked up by later frames, while the points themselves keep changing every frame.
|
||||
"""
|
||||
|
||||
# ---
|
||||
|
||||
rr.script_setup(args, "rerun_example_incremental_logging")
|
||||
|
||||
rr.log("readme", rr.TextDocument(README, media_type=rr.MediaType.MARKDOWN), static=True)
|
||||
|
||||
# Only log colors and radii once.
|
||||
# Logging as static would also work (i.e. `static=True`).
|
||||
rr.set_time("frame_nr", sequence=0)
|
||||
rr.log("points", rr.Points3D.from_fields(colors=0xFF0000FF, radii=0.1))
|
||||
|
||||
rng = default_rng(12345)
|
||||
|
||||
# Then log only the points themselves each frame.
|
||||
#
|
||||
# They will automatically re-use the colors and radii logged at the beginning.
|
||||
for i in range(10):
|
||||
rr.set_time("frame_nr", sequence=i)
|
||||
rr.log("points", rr.Points3D.from_fields(positions=rng.uniform(-5, 5, size=[10, 3])))
|
||||
|
||||
rr.script_teardown(args)
|
||||
@@ -0,0 +1,12 @@
|
||||
[project]
|
||||
name = "incremental_logging"
|
||||
version = "0.1.0"
|
||||
readme = "README.md"
|
||||
dependencies = ["numpy", "rerun-sdk"]
|
||||
|
||||
[project.scripts]
|
||||
incremental_logging = "incremental_logging:main"
|
||||
|
||||
[build-system]
|
||||
requires = ["hatchling"]
|
||||
build-backend = "hatchling.build"
|
||||
Reference in New Issue
Block a user