You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
memory_recording() has a drain API, but the way it's structured it makes more sense for it to return self-contained RRD files.
Other usages (in rust), also take advantage of the fact that it exposes APIs to directly consume buffered messages, rather than a raw stream of bytes.
The call to drain also incurs non-trivial overhead since we lazily do the encode at this step rather than eagerly encoding in a dedicated thread as with the File/Tcp sinks.
The text was updated successfully, but these errors were encountered:
…ded bytes (#6242)
### What
- Resolves: #6241
This effectively combines the guts of FileSink and MemorySink. Like the
FileSink, this runs file-encoding on its own thread so that all we need
to do when we're ready to read is move out the bytes.
The downside relative to memory_sink is the stream is a singular RRD.
You have no way of accessing information about individual messages,
draining from the backlog, etc.
This is designed to be as easy as possible to wire into a gradio output
stream.
Example usage in a Gradio Component:
```python
@rr.thread_local_stream("rerun_example_live")
def start_stream_direct(state):
state['streaming'] = True
cap = cv2.VideoCapture(0)
frame_nr = 0
stream = rr.binary_stream()
while state.get('streaming', False):
ret, img = cap.read()
frame_time_ms = cap.get(cv2.CAP_PROP_POS_MSEC)
if frame_time_ms != 0:
rr.set_time_nanos("frame_time", int(frame_time_ms * 1_000_000))
rr.set_time_sequence("frame_nr", frame_nr)
frame_nr += 1
print("Processing frame", frame_nr)
img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
# Log the original image
rr.log("image/rgb", rr.Image(img).compress())
# Convert to grayscale
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
rr.log("image/gray", rr.Image(gray).compress())
# Run the canny edge detector
canny = cv2.Canny(gray, 50, 200)
rr.log("image/canny", rr.Image(canny).compress())
yield stream.read()
```
### Checklist
* [x] I have read and agree to [Contributor
Guide](https://github.com/rerun-io/rerun/blob/main/CONTRIBUTING.md) and
the [Code of
Conduct](https://github.com/rerun-io/rerun/blob/main/CODE_OF_CONDUCT.md)
* [x] I've included a screenshot or gif (if applicable)
* [x] I have tested the web demo (if applicable):
* Using examples from latest `main` build:
[rerun.io/viewer](https://rerun.io/viewer/pr/6242?manifest_url=https://app.rerun.io/version/main/examples_manifest.json)
* Using full set of examples from `nightly` build:
[rerun.io/viewer](https://rerun.io/viewer/pr/6242?manifest_url=https://app.rerun.io/version/nightly/examples_manifest.json)
* [x] The PR title and labels are set such as to maximize their
usefulness for the next release's CHANGELOG
* [x] If applicable, add a new check to the [release
checklist](https://github.com/rerun-io/rerun/blob/main/tests/python/release_checklist)!
- [PR Build Summary](https://build.rerun.io/pr/6242)
- [Recent benchmark results](https://build.rerun.io/graphs/crates.html)
- [Wasm size tracking](https://build.rerun.io/graphs/sizes.html)
To run all checks from `main`, comment on the PR with `@rerun-bot
full-check`.
memory_recording()
has adrain
API, but the way it's structured it makes more sense for it to return self-contained RRD files.Other usages (in rust), also take advantage of the fact that it exposes APIs to directly consume buffered messages, rather than a raw stream of bytes.
The call to drain also incurs non-trivial overhead since we lazily do the encode at this step rather than eagerly encoding in a dedicated thread as with the File/Tcp sinks.
The text was updated successfully, but these errors were encountered: