Rerun C++ SDK
Loading...
Searching...
No Matches
rerun::archetypes::Image Struct Reference

Archetype: A monochrome or color image. More...

#include <rerun/archetypes/image.hpp>

Public Types

using IndicatorComponent = components::IndicatorComponent< IndicatorComponentName >
 Indicator component, used to identify the archetype when converting to a list of components.
 

Public Member Functions

 Image (Collection< datatypes::TensorDimension > shape, datatypes::TensorBuffer buffer)
 New Image from height/width/channel and tensor buffer.
 
 Image (rerun::components::TensorData data_)
 New depth image from tensor data.
 
template<typename TElement >
 Image (Collection< datatypes::TensorDimension > shape, const TElement *data_)
 New image from dimensions and pointer to image data.
 
 Image (Image &&other)=default
 
Image with_draw_order (rerun::components::DrawOrder _draw_order) &&
 An optional floating point value that specifies the 2D drawing order.
 
size_t num_instances () const
 Returns the number of primary instances of this archetype.
 

Public Attributes

rerun::components::TensorData data
 The image data. Should always be a rank-2 or rank-3 tensor.
 
std::optional< rerun::components::DrawOrderdraw_order
 An optional floating point value that specifies the 2D drawing order.
 

Static Public Attributes

static constexpr const char IndicatorComponentName [] = "rerun.components.ImageIndicator"
 

Detailed Description

Archetype: A monochrome or color image.

The shape of the TensorData must be mappable to:

  • A HxW tensor, treated as a grayscale image.
  • A HxWx3 tensor, treated as an RGB image.
  • A HxWx4 tensor, treated as an RGBA image.

Leading and trailing unit-dimensions are ignored, so that 1x640x480x3x1 is treated as a 640x480x3 RGB image.

Since the underlying rerun::datatypes::TensorData uses rerun::Collection internally, data can be passed in without a copy from raw pointers or by reference from std::vector/std::array/c-arrays. If needed, this "borrow-behavior" can be extended by defining your own rerun::CollectionAdapter.

Example

image_simple:

image

#include <rerun.hpp>
#include <vector>
int main() {
const auto rec = rerun::RecordingStream("rerun_example_image_simple");
rec.spawn().exit_on_failure();
// Create a synthetic image.
const int HEIGHT = 200;
const int WIDTH = 300;
std::vector<uint8_t> data(WIDTH * HEIGHT * 3, 0);
for (size_t i = 0; i <data.size(); i += 3) {
data[i] = 255;
}
for (size_t y = 50; y <150; ++y) {
for (size_t x = 50; x <150; ++x) {
data[(y * WIDTH + x) * 3 + 0] = 0;
data[(y * WIDTH + x) * 3 + 1] = 255;
data[(y * WIDTH + x) * 3 + 2] = 0;
}
}
rec.log("image", rerun::Image({HEIGHT, WIDTH, 3}, data));
}
A RecordingStream handles everything related to logging data into Rerun.
Definition recording_stream.hpp:57
Archetype: A monochrome or color image.
Definition image.hpp:66
rerun::components::TensorData data
The image data. Should always be a rank-2 or rank-3 tensor.
Definition image.hpp:68

Constructor & Destructor Documentation

◆ Image() [1/3]

rerun::archetypes::Image::Image ( Collection< datatypes::TensorDimension shape,
datatypes::TensorBuffer  buffer 
)
inlineexplicit

New Image from height/width/channel and tensor buffer.

Parameters
shapeShape of the image. Calls Error::handle() if the shape is not rank 2 or 3. Sets the dimension names to "height", "width" and "channel" if they are not specified.
bufferThe tensor buffer containing the image data.

◆ Image() [2/3]

rerun::archetypes::Image::Image ( rerun::components::TensorData  data_)
explicit

New depth image from tensor data.

Parameters
data_The tensor buffer containing the image data. Sets the dimension names to "height", "width" and "channel" if they are not specified. Calls Error::handle() if the shape is not rank 2 or 3.

◆ Image() [3/3]

template<typename TElement >
rerun::archetypes::Image::Image ( Collection< datatypes::TensorDimension shape,
const TElement *  data_ 
)
inlineexplicit

New image from dimensions and pointer to image data.

Type must be one of the types supported by rerun::datatypes::TensorData.

Parameters
shapeShape of the image. Calls Error::handle() if the shape is not rank 2 or 3. Sets the dimension names to "height", "width" and "channel" if they are not specified. Determines the number of elements expected to be in data.
data_Target of the pointer must outlive the archetype.

Member Function Documentation

◆ with_draw_order()

Image rerun::archetypes::Image::with_draw_order ( rerun::components::DrawOrder  _draw_order) &&
inline

An optional floating point value that specifies the 2D drawing order.

Objects with higher values are drawn on top of those with lower values.

Member Data Documentation

◆ draw_order

std::optional<rerun::components::DrawOrder> rerun::archetypes::Image::draw_order

An optional floating point value that specifies the 2D drawing order.

Objects with higher values are drawn on top of those with lower values.


The documentation for this struct was generated from the following file: