6#include "../collection.hpp"
7#include "../component_batch.hpp"
8#include "../component_column.hpp"
9#include "../components/draw_order.hpp"
10#include "../components/image_buffer.hpp"
11#include "../components/image_format.hpp"
12#include "../components/opacity.hpp"
13#include "../image_utils.hpp"
14#include "../result.hpp"
75 std::optional<ComponentBatch>
buffer;
78 std::optional<ComponentBatch>
format;
93 static constexpr const char ArchetypeName[] =
"rerun.archetypes.SegmentationImage";
123 template <
typename TElement>
126 reinterpret_cast<const uint8_t*>(pixels), resolution, get_datatype(pixels)} {}
135 template <
typename TElement>
137 :
SegmentationImage{pixels.to_uint8(), resolution, get_datatype(pixels.data())} {}
166 if (bytes.
size() != image_format.num_bytes()) {
168 ErrorCode::InvalidTensorDimension,
169 "SegmentationImage buffer has the wrong size. Got " +
170 std::to_string(bytes.
size()) +
" bytes, expected " +
171 std::to_string(image_format.num_bytes())
175 *
this = std::move(*this).with_buffer(bytes).with_format(image_format);
198 return std::move(*
this);
208 return std::move(*
this);
214 return std::move(*
this);
224 return std::move(*
this);
232 return std::move(*
this);
242 return std::move(*
this);
252 return std::move(*
this);
264 return std::move(*
this);
288 template <
typename T>
Generic collection of elements that are roughly contiguous in memory.
Definition collection.hpp:49
size_t size() const
Returns the number of instances in this collection.
Definition collection.hpp:291
Status outcome object (success or error) returned for fallible operations.
Definition error.hpp:99
void handle() const
Handle this error based on the set log handler.
A class for representing either a usable value, or an error.
Definition result.hpp:14
All built-in archetypes. See Types in the Rerun manual.
Definition rerun.hpp:76
ChannelDatatype
Datatype: The innermost datatype of an image.
Definition channel_datatype.hpp:26
All Rerun C++ types and functions are in the rerun namespace or one of its nested namespaces.
Definition rerun.hpp:23
Collection< TElement > borrow(const TElement *data, size_t num_instances=1)
Borrows binary data into a Collection from a pointer.
Definition collection.hpp:462
static Result< ComponentBatch > from_loggable(const rerun::Collection< T > &components, const ComponentDescriptor &descriptor)
Creates a new component batch from a collection of component instances.
Definition component_batch.hpp:46
A ComponentDescriptor fully describes the semantics of a column of data.
Definition component_descriptor.hpp:16
The Loggable trait is used by all built-in implementation of rerun::AsComponents to serialize a colle...
Definition loggable.hpp:11
The width and height of an image.
Definition image_utils.hpp:13
Archetype: An image made up of integer components::ClassIds.
Definition segmentation_image.hpp:73
SegmentationImage with_many_buffer(const Collection< rerun::components::ImageBuffer > &_buffer) &&
This method makes it possible to pack multiple buffer in a single component batch.
Definition segmentation_image.hpp:205
Collection< ComponentColumn > columns()
Partitions the component data into unit-length sub-batches.
std::optional< ComponentBatch > opacity
Opacity of the image, useful for layering the segmentation image on top of another image.
Definition segmentation_image.hpp:83
SegmentationImage with_buffer(const rerun::components::ImageBuffer &_buffer) &&
The raw image data.
Definition segmentation_image.hpp:196
SegmentationImage with_many_format(const Collection< rerun::components::ImageFormat > &_format) &&
This method makes it possible to pack multiple format in a single component batch.
Definition segmentation_image.hpp:221
Collection< ComponentColumn > columns(const Collection< uint32_t > &lengths_)
Partitions the component data into multiple sub-batches.
SegmentationImage(Collection< uint8_t > bytes, WidthHeight resolution, datatypes::ChannelDatatype datatype)
Constructs image from pixel data + resolution + datatype.
Definition segmentation_image.hpp:162
std::optional< ComponentBatch > buffer
The raw image data.
Definition segmentation_image.hpp:75
SegmentationImage with_draw_order(const rerun::components::DrawOrder &_draw_order) &&
An optional floating point value that specifies the 2D drawing order.
Definition segmentation_image.hpp:249
static SegmentationImage clear_fields()
Clear all the fields of a SegmentationImage.
std::optional< ComponentBatch > draw_order
An optional floating point value that specifies the 2D drawing order.
Definition segmentation_image.hpp:89
static constexpr auto Descriptor_buffer
ComponentDescriptor for the buffer field.
Definition segmentation_image.hpp:96
SegmentationImage(Collection< TElement > pixels, WidthHeight resolution)
Constructs image from pixel data + resolution with datatype inferred from the passed collection.
Definition segmentation_image.hpp:136
static constexpr auto Descriptor_format
ComponentDescriptor for the format field.
Definition segmentation_image.hpp:101
static constexpr auto Descriptor_opacity
ComponentDescriptor for the opacity field.
Definition segmentation_image.hpp:106
SegmentationImage(const TElement *pixels, WidthHeight resolution)
Constructs image from pointer + resolution, inferring the datatype from the pointer type.
Definition segmentation_image.hpp:124
SegmentationImage with_many_opacity(const Collection< rerun::components::Opacity > &_opacity) &&
This method makes it possible to pack multiple opacity in a single component batch.
Definition segmentation_image.hpp:239
std::optional< ComponentBatch > format
The format of the image.
Definition segmentation_image.hpp:78
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.
Definition segmentation_image.hpp:259
SegmentationImage(const void *bytes, WidthHeight resolution, datatypes::ChannelDatatype datatype)
Constructs image from pixel data + resolution with explicit datatype.
Definition segmentation_image.hpp:146
static constexpr auto Descriptor_draw_order
ComponentDescriptor for the draw_order field.
Definition segmentation_image.hpp:111
static constexpr const char ArchetypeName[]
The name of the archetype as used in ComponentDescriptors.
Definition segmentation_image.hpp:93
static SegmentationImage update_fields()
Update only some specific fields of a SegmentationImage.
Definition segmentation_image.hpp:188
SegmentationImage with_opacity(const rerun::components::Opacity &_opacity) &&
Opacity of the image, useful for layering the segmentation image on top of another image.
Definition segmentation_image.hpp:230
SegmentationImage with_format(const rerun::components::ImageFormat &_format) &&
The format of the image.
Definition segmentation_image.hpp:212
Component: Draw order of 2D elements.
Definition draw_order.hpp:19
Component: A buffer that is known to store image data.
Definition image_buffer.hpp:18
Component: Degree of transparency ranging from 0.0 (fully transparent) to 1.0 (fully opaque).
Definition opacity.hpp:17