Skip to content

Commit 51a2a10

Browse files
authored
Update cpp/eigen_opencv README snippets (#9463)
* Replaced snippet using `rerun::TensorBuffer::u8` with `rerun::borrow` * Changed `reinterpret_cast` snippet to use an existing constructor ### Related Closes #9459 ### What Brings snippets in the README up-to-date with the current API for the [cpp/eigen_opencv](https://github.com/rerun-io/rerun/tree/main/examples/cpp/eigen_opencv) example.
1 parent f3ce7af commit 51a2a10

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

examples/cpp/eigen_opencv/README.md

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,31 @@ rec.log(
6464
## Images
6565
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.
6666
```cpp
67-
// Log image to rerun using the tensor buffer adapter defined in `collection_adapters.hpp`.
68-
rec.log("image0", rerun::Image(tensor_shape(img), rerun::TensorBuffer::u8(img)));
67+
// Log image to rerun by borrowing binary data into a `Collection` from a pointer.
68+
rec.log(
69+
"image0",
70+
rerun::Image(
71+
rerun::borrow(img.data, img.total() * img.elemSize()),
72+
rerun::WidthHeight(
73+
static_cast<uint32_t>(img.cols),
74+
static_cast<uint32_t>(img.rows)
75+
),
76+
rerun::ColorModel::BGR
77+
)
78+
);
6979

7080
// Or by passing a pointer to the image data.
71-
rec.log("image1", rerun::Image(tensor_shape(img), reinterpret_cast<const uint8_t*>(img.data)));
81+
rec.log(
82+
"image1",
83+
rerun::Image(
84+
reinterpret_cast<const uint8_t*>(img.data),
85+
rerun::WidthHeight(
86+
static_cast<uint32_t>(img.cols),
87+
static_cast<uint32_t>(img.rows)
88+
),
89+
rerun::ColorModel::BGR
90+
)
91+
);
7292
```
7393

7494
# Run the code

0 commit comments

Comments
 (0)