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

Archetype: An image made up of integer class-ids. More...

#include <rerun/archetypes/segmentation_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

 SegmentationImage (Collection< datatypes::TensorDimension > shape, datatypes::TensorBuffer buffer)
 New segmentation image from height/width and tensor buffer.
 
 SegmentationImage (components::TensorData data_)
 New segmentation image from tensor data.
 
template<typename TElement >
 SegmentationImage (Collection< datatypes::TensorDimension > shape, const TElement *data_)
 New segmentation image from dimensions and pointer to segmentation image data.
 
 SegmentationImage (SegmentationImage &&other)=default
 
SegmentationImage 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 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 []
 

Detailed Description

Archetype: An image made up of integer class-ids.

The shape of the TensorData must be mappable to an HxW tensor. Each pixel corresponds to a depth value in units specified by meter.

Leading and trailing unit-dimensions are ignored, so that 1x640x480x1 is treated as a 640x480 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

Simple segmentation image

image

#include <rerun.hpp>
#include <algorithm> // std::fill_n
#include <vector>
int main() {
const auto rec = rerun::RecordingStream("rerun_example_annotation_context_connections");
rec.spawn().exit_on_failure();
// Create a segmentation image
const int HEIGHT = 8;
const int WIDTH = 12;
std::vector<uint8_t> data(WIDTH * HEIGHT, 0);
for (auto y = 0; y <4; ++y) { // top half
std::fill_n(data.begin() + y * WIDTH, 6, static_cast<uint8_t>(1)); // left half
}
for (auto y = 4; y <8; ++y) { // bottom half
std::fill_n(data.begin() + y * WIDTH + 6, 6, static_cast<uint8_t>(2)); // right half
}
// create an annotation context to describe the classes
rec.log_timeless(
"/",
rerun::AnnotationInfo(1, "red", rerun::Rgba32(255, 0, 0)),
rerun::AnnotationInfo(2, "green", rerun::Rgba32(0, 255, 0)),
})
);
rec.log("image", rerun::SegmentationImage({HEIGHT, WIDTH}, data));
}
A RecordingStream handles everything related to logging data into Rerun.
Definition recording_stream.hpp:57
Archetype: The AnnotationContext provides additional information on how to display entities.
Definition annotation_context.hpp:63
Archetype: An image made up of integer class-ids.
Definition segmentation_image.hpp:70
rerun::components::TensorData data
The image data. Should always be a rank-2 tensor.
Definition segmentation_image.hpp:72
Datatype: Annotation info annotating a class id or key-point id.
Definition annotation_info.hpp:25
Datatype: An RGBA color with unmultiplied/separate alpha, in sRGB gamma space with linear alpha.
Definition rgba32.hpp:27

Constructor & Destructor Documentation

◆ SegmentationImage() [1/3]

rerun::archetypes::SegmentationImage::SegmentationImage ( Collection< datatypes::TensorDimension shape,
datatypes::TensorBuffer  buffer 
)
inline

New segmentation image from height/width and tensor buffer.

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

◆ SegmentationImage() [2/3]

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

New segmentation image from tensor data.

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

◆ SegmentationImage() [3/3]

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

New segmentation image from dimensions and pointer to segmentation 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. 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()

SegmentationImage rerun::archetypes::SegmentationImage::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::SegmentationImage::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.

◆ IndicatorComponentName

constexpr const char rerun::archetypes::SegmentationImage::IndicatorComponentName[]
staticconstexpr
Initial value:
=
"rerun.components.SegmentationImageIndicator"

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