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

Archetype: An image made up of integer components::ClassIds. More...

#include <rerun/archetypes/segmentation_image.hpp>

Public Types

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

Public Member Functions

template<typename TElement >
 SegmentationImage (const TElement *pixels, WidthHeight resolution)
 Constructs image from pointer + resolution, inferring the datatype from the pointer type.
 
template<typename TElement >
 SegmentationImage (Collection< TElement > pixels, WidthHeight resolution)
 Constructs image from pixel data + resolution with datatype inferred from the passed collection.
 
 SegmentationImage (const void *bytes, WidthHeight resolution, datatypes::ChannelDatatype datatype)
 Constructs image from pixel data + resolution with explicit datatype.
 
 SegmentationImage (Collection< uint8_t > bytes, WidthHeight resolution, datatypes::ChannelDatatype datatype)
 Constructs image from pixel data + resolution + datatype.
 
 SegmentationImage (SegmentationImage &&other)=default
 
 SegmentationImage (const SegmentationImage &other)=default
 
SegmentationImageoperator= (const SegmentationImage &other)=default
 
SegmentationImageoperator= (SegmentationImage &&other)=default
 
SegmentationImage with_buffer (const rerun::components::ImageBuffer &_buffer) &&
 The raw image data.
 
SegmentationImage with_many_buffer (const Collection< rerun::components::ImageBuffer > &_buffer) &&
 This method makes it possible to pack multiple buffer in a single component batch.
 
SegmentationImage with_format (const rerun::components::ImageFormat &_format) &&
 The format of the image.
 
SegmentationImage with_many_format (const Collection< rerun::components::ImageFormat > &_format) &&
 This method makes it possible to pack multiple format in a single component batch.
 
SegmentationImage with_opacity (const rerun::components::Opacity &_opacity) &&
 Opacity of the image, useful for layering the segmentation image on top of another image.
 
SegmentationImage with_many_opacity (const Collection< rerun::components::Opacity > &_opacity) &&
 This method makes it possible to pack multiple opacity in a single component batch.
 
SegmentationImage with_draw_order (const rerun::components::DrawOrder &_draw_order) &&
 An optional floating point value that specifies the 2D drawing order.
 
SegmentationImage with_many_draw_order (const Collection< rerun::components::DrawOrder > &_draw_order) &&
 This method makes it possible to pack multiple draw_order in a single component batch.
 
Collection< ComponentColumncolumns (const Collection< uint32_t > &lengths_)
 Partitions the component data into multiple sub-batches.
 
Collection< ComponentColumncolumns ()
 Partitions the component data into unit-length sub-batches.
 

Static Public Member Functions

static SegmentationImage update_fields ()
 Update only some specific fields of a SegmentationImage.
 
static SegmentationImage clear_fields ()
 Clear all the fields of a SegmentationImage.
 

Public Attributes

std::optional< ComponentBatchbuffer
 The raw image data.
 
std::optional< ComponentBatchformat
 The format of the image.
 
std::optional< ComponentBatchopacity
 Opacity of the image, useful for layering the segmentation image on top of another image.
 
std::optional< ComponentBatchdraw_order
 An optional floating point value that specifies the 2D drawing order.
 

Static Public Attributes

static constexpr const char IndicatorComponentName []
 
static constexpr const char ArchetypeName [] = "rerun.archetypes.SegmentationImage"
 The name of the archetype as used in ComponentDescriptors.
 
static constexpr auto Descriptor_buffer
 ComponentDescriptor for the buffer field.
 
static constexpr auto Descriptor_format
 ComponentDescriptor for the format field.
 
static constexpr auto Descriptor_opacity
 ComponentDescriptor for the opacity field.
 
static constexpr auto Descriptor_draw_order
 ComponentDescriptor for the draw_order field.
 

Detailed Description

Archetype: An image made up of integer components::ClassIds.

Each pixel corresponds to a components::ClassId that will be mapped to a color based on annotation context.

In the case of floating point images, the label will be looked up based on rounding to the nearest integer value.

See also archetypes::AnnotationContext to associate each class with a color and a label.

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_segmentation_image");
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_static(
"/",
rerun::AnnotationInfo(1, "red", rerun::Rgba32(255, 0, 0)),
rerun::AnnotationInfo(2, "green", rerun::Rgba32(0, 255, 0)),
})
);
rec.log("image", rerun::SegmentationImage(data.data(), {WIDTH, HEIGHT}));
}
A RecordingStream handles everything related to logging data into Rerun.
Definition recording_stream.hpp:60
Archetype: The annotation context provides additional information on how to display entities.
Definition annotation_context.hpp:67
Archetype: An image made up of integer components::ClassIds.
Definition segmentation_image.hpp:74
Datatype: Annotation info annotating a class id or key-point id.
Definition annotation_info.hpp:26
Datatype: An RGBA color with unmultiplied/separate alpha, in sRGB gamma space with linear alpha.
Definition rgba32.hpp:28

Constructor & Destructor Documentation

◆ SegmentationImage() [1/4]

template<typename TElement >
rerun::archetypes::SegmentationImage::SegmentationImage ( const TElement *  pixels,
WidthHeight  resolution 
)
inline

Constructs image from pointer + resolution, inferring the datatype from the pointer type.

Parameters
pixelsThe raw image data. ⚠️ Does not take ownership of the data, the caller must ensure the data outlives the image. The number of elements is assumed to be W * H.
resolutionThe resolution of the image as {width, height}.

◆ SegmentationImage() [2/4]

template<typename TElement >
rerun::archetypes::SegmentationImage::SegmentationImage ( Collection< TElement >  pixels,
WidthHeight  resolution 
)
inline

Constructs image from pixel data + resolution with datatype inferred from the passed collection.

Parameters
pixelsThe raw image data. If the data does not outlive the image, use std::move or create the rerun::Collection explicitly ahead of time with rerun::Collection::take_ownership. The length of the data should be W * H.
resolutionThe resolution of the image as {width, height}.

◆ SegmentationImage() [3/4]

rerun::archetypes::SegmentationImage::SegmentationImage ( const void *  bytes,
WidthHeight  resolution,
datatypes::ChannelDatatype  datatype 
)
inline

Constructs image from pixel data + resolution with explicit datatype.

Borrows data from a pointer (i.e. data must outlive the image!).

Parameters
bytesThe raw image data. ⚠️ Does not take ownership of the data, the caller must ensure the data outlives the image. The byte size of the data is assumed to be W * H * datatype.size
resolutionThe resolution of the image as {width, height}.
datatypeHow the data should be interpreted.

◆ SegmentationImage() [4/4]

rerun::archetypes::SegmentationImage::SegmentationImage ( Collection< uint8_t >  bytes,
WidthHeight  resolution,
datatypes::ChannelDatatype  datatype 
)
inline

Constructs image from pixel data + resolution + datatype.

Parameters
bytesThe raw image data as bytes. If the data does not outlive the image, use std::move or create the rerun::Collection explicitly ahead of time with rerun::Collection::take_ownership. The length of the data should be W * H.
resolutionThe resolution of the image as {width, height}.
datatypeHow the data should be interpreted.

Member Function Documentation

◆ with_many_buffer()

SegmentationImage rerun::archetypes::SegmentationImage::with_many_buffer ( const Collection< rerun::components::ImageBuffer > &  _buffer) &&
inline

This method makes it possible to pack multiple buffer in a single component batch.

This only makes sense when used in conjunction with columns. with_buffer should be used when logging a single row's worth of data.

◆ with_many_format()

SegmentationImage rerun::archetypes::SegmentationImage::with_many_format ( const Collection< rerun::components::ImageFormat > &  _format) &&
inline

This method makes it possible to pack multiple format in a single component batch.

This only makes sense when used in conjunction with columns. with_format should be used when logging a single row's worth of data.

◆ with_opacity()

SegmentationImage rerun::archetypes::SegmentationImage::with_opacity ( const rerun::components::Opacity _opacity) &&
inline

Opacity of the image, useful for layering the segmentation image on top of another image.

Defaults to 0.5 if there's any other images in the scene, otherwise 1.0.

◆ with_many_opacity()

SegmentationImage rerun::archetypes::SegmentationImage::with_many_opacity ( const Collection< rerun::components::Opacity > &  _opacity) &&
inline

This method makes it possible to pack multiple opacity in a single component batch.

This only makes sense when used in conjunction with columns. with_opacity should be used when logging a single row's worth of data.

◆ with_draw_order()

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

◆ with_many_draw_order()

SegmentationImage rerun::archetypes::SegmentationImage::with_many_draw_order ( const Collection< rerun::components::DrawOrder > &  _draw_order) &&
inline

This method makes it possible to pack multiple draw_order in a single component batch.

This only makes sense when used in conjunction with columns. with_draw_order should be used when logging a single row's worth of data.

◆ columns() [1/2]

Collection< ComponentColumn > rerun::archetypes::SegmentationImage::columns ( const Collection< uint32_t > &  lengths_)

Partitions the component data into multiple sub-batches.

Specifically, this transforms the existing ComponentBatch data into ComponentColumns instead, via ComponentBatch::partitioned.

This makes it possible to use RecordingStream::send_columns to send columnar data directly into Rerun.

The specified lengths must sum to the total length of the component batch.

◆ columns() [2/2]

Collection< ComponentColumn > rerun::archetypes::SegmentationImage::columns ( )

Partitions the component data into unit-length sub-batches.

This is semantically similar to calling columns with std::vector<uint32_t>(n, 1), where n is automatically guessed.

Member Data Documentation

◆ opacity

std::optional<ComponentBatch> rerun::archetypes::SegmentationImage::opacity

Opacity of the image, useful for layering the segmentation image on top of another image.

Defaults to 0.5 if there's any other images in the scene, otherwise 1.0.

◆ draw_order

std::optional<ComponentBatch> 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"

◆ Descriptor_buffer

constexpr auto rerun::archetypes::SegmentationImage::Descriptor_buffer
staticconstexpr
Initial value:
= ComponentDescriptor(
ArchetypeName, "buffer",
Loggable<rerun::components::ImageBuffer>::Descriptor.component_name
)
static constexpr const char ArchetypeName[]
The name of the archetype as used in ComponentDescriptors.
Definition segmentation_image.hpp:98

ComponentDescriptor for the buffer field.

◆ Descriptor_format

constexpr auto rerun::archetypes::SegmentationImage::Descriptor_format
staticconstexpr
Initial value:
= ComponentDescriptor(
ArchetypeName, "format",
Loggable<rerun::components::ImageFormat>::Descriptor.component_name
)

ComponentDescriptor for the format field.

◆ Descriptor_opacity

constexpr auto rerun::archetypes::SegmentationImage::Descriptor_opacity
staticconstexpr
Initial value:
= ComponentDescriptor(
ArchetypeName, "opacity",
Loggable<rerun::components::Opacity>::Descriptor.component_name
)

ComponentDescriptor for the opacity field.

◆ Descriptor_draw_order

constexpr auto rerun::archetypes::SegmentationImage::Descriptor_draw_order
staticconstexpr
Initial value:
= ComponentDescriptor(
ArchetypeName, "draw_order",
Loggable<rerun::components::DrawOrder>::Descriptor.component_name
)

ComponentDescriptor for the draw_order field.


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