Skip to content

Update cpp/eigen_opencv README snippets #9463

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 23 additions & 2 deletions examples/cpp/eigen_opencv/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,32 @@ rec.log(
## Images
Images are logged using the [`Image`](https://www.rerun.io/docs/reference/types/archetypes/image) archetype. Two methods are demonstrated: logging images with a tensor buffer and logging images by passing a pointer to the image data.
```cpp
// Log image to rerun using the tensor buffer adapter defined in `collection_adapters.hpp`.
rec.log("image0", rerun::Image(tensor_shape(img), rerun::TensorBuffer::u8(img)));
// Log image to rerun by borrowing binary data into a `Collection` from a pointer.
rec.log(
"image0",
rerun::Image(
rerun::borrow(img.data, img.total() * img.elemSize()),
rerun::WidthHeight(
static_cast<uint32_t>(img.cols),
static_cast<uint32_t>(img.rows)
),
rerun::ColorModel::BGR
)
);

// Or by passing a pointer to the image data.
rec.log("image1", rerun::Image(tensor_shape(img), reinterpret_cast<const uint8_t*>(img.data)));
rec.log(
"image1",
rerun::Image(
reinterpret_cast<const uint8_t*>(img.data),
rerun::WidthHeight(
static_cast<uint32_t>(img.cols),
static_cast<uint32_t>(img.rows)
),
rerun::ColorModel::BGR
)
);
```

# Run the code
Expand Down
Loading