Rerun C++ SDK
Loading...
Searching...
No Matches
encoded_depth_image.hpp
1// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/cpp/mod.rs
2// Based on "crates/build/re_type_definitions/rerun/archetypes/encoded_depth_image.def.rs".
3
4#pragma once
5
6#include "../archetype_utils.hpp"
7#include "../collection.hpp"
8#include "../component_batch.hpp"
9#include "../component_column.hpp"
10#include "../components/blob.hpp"
11#include "../components/colormap.hpp"
12#include "../components/depth_meter.hpp"
13#include "../components/draw_order.hpp"
14#include "../components/fill_ratio.hpp"
15#include "../components/magnification_filter.hpp"
16#include "../components/media_type.hpp"
17#include "../components/value_range.hpp"
18#include "../result.hpp"
19
20#include <cstdint>
21#include <optional>
22#include <utility>
23#include <vector>
24
25namespace rerun::archetypes {
26 /// **Archetype**: A depth image encoded with a codec (e.g. RVL, PNG, or TIFF).
27 ///
28 /// Rerun also supports uncompressed depth images with the [`archetypes.DepthImage`](https://rerun.io/docs/reference/types/archetypes/depth_image).
29 ///
30 /// ## Example
31 ///
32 /// ### Encoded depth image
33 /// ![image](https://static.rerun.io/encoded_depth_image/d8180f8167278f9601808c360ba52eafaab52839/full.png)
34 ///
35 /// ```cpp
36 /// #include <rerun.hpp>
37 ///
38 /// #include <filesystem>
39 /// #include <fstream>
40 /// #include <iostream>
41 /// #include <vector>
42 ///
43 /// namespace fs = std::filesystem;
44 ///
45 /// int main(int argc, char* argv[]) {
46 /// if (argc <2) {
47 /// std::cerr <<"Usage: " <<argv[0] <<" <path_to_depth_image.[png|rvl]>"
48 /// <<std::endl;
49 /// return 1;
50 /// }
51 ///
52 /// const auto rec =
53 /// rerun::RecordingStream("rerun_example_encoded_depth_image");
54 /// rec.spawn().exit_on_failure();
55 ///
56 /// const auto depth_path = fs::path(argv[1]);
57 /// std::ifstream file(depth_path, std::ios::binary);
58 /// if (!file) {
59 /// std::cerr <<"Failed to open encoded depth image: " <<depth_path
60 /// <<std::endl;
61 /// return 1;
62 /// }
63 ///
64 /// std::vector<uint8_t> bytes{
65 /// std::istreambuf_iterator<char>(file),
66 /// std::istreambuf_iterator<char>()
67 /// };
68 /// // Determine media type based on file extension
69 /// rerun::MediaType media_type;
70 /// if (depth_path.extension() == ".png") {
71 /// media_type = rerun::MediaType::png();
72 /// } else {
73 /// media_type = rerun::MediaType::rvl();
74 /// }
75 ///
76 /// rec.log(
77 /// "depth/encoded",
78 /// rerun::archetypes::EncodedDepthImage()
79 /// .with_blob(rerun::components::Blob(
80 /// rerun::Collection<uint8_t>::take_ownership(std::move(bytes))
81 /// ))
82 /// .with_media_type(media_type)
83 /// .with_meter(0.001f)
84 /// );
85 /// }
86 /// ```
87 ///
88 /// ⚠ **This type is _unstable_ and may change significantly in a way that the data won't be backwards compatible.**
89 ///
91 /// The encoded depth payload.
92 ///
93 /// Supported are:
94 /// * single channel PNG
95 /// * single channel TIFF with `U8`, `U16`, or `F32` samples
96 /// * RVL with ROS2 metadata (for details see <https://github.com/ros-perception/image_transport_plugins/tree/jazzy>)
97 std::optional<ComponentBatch> blob;
98
99 /// Media type of the blob, e.g.:
100 ///
101 /// * `application/rvl` (RVL-compressed 16-bit)
102 /// * `image/png`
103 /// * `image/tiff`
104 std::optional<ComponentBatch> media_type;
105
106 /// Conversion from native units to meters (e.g. `0.001` for millimeters).
107 ///
108 /// If omitted, the Viewer defaults to `1.0` for floating-point depth formats and `1000.0` for integer formats (millimeters).
109 std::optional<ComponentBatch> meter;
110
111 /// Optional colormap for visualization of decoded depth.
112 std::optional<ComponentBatch> colormap;
113
114 /// Optional visualization range for depth values.
115 std::optional<ComponentBatch> depth_range;
116
117 /// Optional point fill ratio for point-cloud projection.
118 std::optional<ComponentBatch> point_fill_ratio;
119
120 /// Optional 2D draw order.
121 std::optional<ComponentBatch> draw_order;
122
123 /// Optional filter used when a texel is magnified (displayed larger than a screen pixel) in 2D views.
124 ///
125 /// The filter is applied to the scalar values *before* they are mapped to color via the colormap.
126 ///
127 /// Has no effect in 3D views.
128 std::optional<ComponentBatch> magnification_filter;
129
130 public:
131 /// The name of the archetype as used in `ComponentDescriptor`s.
132 static constexpr const char ArchetypeName[] = "rerun.archetypes.EncodedDepthImage";
133
134 /// `ComponentDescriptor` for the `blob` field.
135 static constexpr auto Descriptor_blob = ComponentDescriptor(
136 ArchetypeName, "EncodedDepthImage:blob",
138 );
139 /// `ComponentDescriptor` for the `media_type` field.
141 ArchetypeName, "EncodedDepthImage:media_type",
143 );
144 /// `ComponentDescriptor` for the `meter` field.
145 static constexpr auto Descriptor_meter = ComponentDescriptor(
146 ArchetypeName, "EncodedDepthImage:meter",
148 );
149 /// `ComponentDescriptor` for the `colormap` field.
151 ArchetypeName, "EncodedDepthImage:colormap",
153 );
154 /// `ComponentDescriptor` for the `depth_range` field.
156 ArchetypeName, "EncodedDepthImage:depth_range",
158 );
159 /// `ComponentDescriptor` for the `point_fill_ratio` field.
161 ArchetypeName, "EncodedDepthImage:point_fill_ratio",
163 );
164 /// `ComponentDescriptor` for the `draw_order` field.
166 ArchetypeName, "EncodedDepthImage:draw_order",
168 );
169 /// `ComponentDescriptor` for the `magnification_filter` field.
171 ArchetypeName, "EncodedDepthImage:magnification_filter",
173 );
174
175 public:
176 EncodedDepthImage() = default;
177 EncodedDepthImage(EncodedDepthImage&& other) = default;
178 EncodedDepthImage(const EncodedDepthImage& other) = default;
179 EncodedDepthImage& operator=(const EncodedDepthImage& other) = default;
180 EncodedDepthImage& operator=(EncodedDepthImage&& other) = default;
181
183 : blob(ComponentBatch::from_loggable(std::move(_blob), Descriptor_blob).value_or_throw()
184 ) {}
185
186 /// Update only some specific fields of a `EncodedDepthImage`.
188 return EncodedDepthImage();
189 }
190
191 /// Clear all the fields of a `EncodedDepthImage`.
193
194 /// The encoded depth payload.
195 ///
196 /// Supported are:
197 /// * single channel PNG
198 /// * single channel TIFF with `U8`, `U16`, or `F32` samples
199 /// * RVL with ROS2 metadata (for details see <https://github.com/ros-perception/image_transport_plugins/tree/jazzy>)
201 blob = ComponentBatch::from_loggable(_blob, Descriptor_blob).value_or_throw();
202 return std::move(*this);
203 }
204
205 /// This method makes it possible to pack multiple `blob` in a single component batch.
206 ///
207 /// This only makes sense when used in conjunction with `columns`. `with_blob` should
208 /// be used when logging a single row's worth of data.
210 blob = ComponentBatch::from_loggable(_blob, Descriptor_blob).value_or_throw();
211 return std::move(*this);
212 }
213
214 /// Media type of the blob, e.g.:
215 ///
216 /// * `application/rvl` (RVL-compressed 16-bit)
217 /// * `image/png`
218 /// * `image/tiff`
220 media_type =
221 ComponentBatch::from_loggable(_media_type, Descriptor_media_type).value_or_throw();
222 return std::move(*this);
223 }
224
225 /// This method makes it possible to pack multiple `media_type` in a single component batch.
226 ///
227 /// This only makes sense when used in conjunction with `columns`. `with_media_type` should
228 /// be used when logging a single row's worth of data.
231 ) && {
232 media_type =
233 ComponentBatch::from_loggable(_media_type, Descriptor_media_type).value_or_throw();
234 return std::move(*this);
235 }
236
237 /// Conversion from native units to meters (e.g. `0.001` for millimeters).
238 ///
239 /// If omitted, the Viewer defaults to `1.0` for floating-point depth formats and `1000.0` for integer formats (millimeters).
241 meter = ComponentBatch::from_loggable(_meter, Descriptor_meter).value_or_throw();
242 return std::move(*this);
243 }
244
245 /// This method makes it possible to pack multiple `meter` in a single component batch.
246 ///
247 /// This only makes sense when used in conjunction with `columns`. `with_meter` should
248 /// be used when logging a single row's worth of data.
250 ) && {
251 meter = ComponentBatch::from_loggable(_meter, Descriptor_meter).value_or_throw();
252 return std::move(*this);
253 }
254
255 /// Optional colormap for visualization of decoded depth.
257 colormap =
258 ComponentBatch::from_loggable(_colormap, Descriptor_colormap).value_or_throw();
259 return std::move(*this);
260 }
261
262 /// This method makes it possible to pack multiple `colormap` in a single component batch.
263 ///
264 /// This only makes sense when used in conjunction with `columns`. `with_colormap` should
265 /// be used when logging a single row's worth of data.
268 ) && {
269 colormap =
270 ComponentBatch::from_loggable(_colormap, Descriptor_colormap).value_or_throw();
271 return std::move(*this);
272 }
273
274 /// Optional visualization range for depth values.
277 .value_or_throw();
278 return std::move(*this);
279 }
280
281 /// This method makes it possible to pack multiple `depth_range` in a single component batch.
282 ///
283 /// This only makes sense when used in conjunction with `columns`. `with_depth_range` should
284 /// be used when logging a single row's worth of data.
287 ) && {
289 .value_or_throw();
290 return std::move(*this);
291 }
292
293 /// Optional point fill ratio for point-cloud projection.
295 const rerun::components::FillRatio& _point_fill_ratio
296 ) && {
299 .value_or_throw();
300 return std::move(*this);
301 }
302
303 /// This method makes it possible to pack multiple `point_fill_ratio` in a single component batch.
304 ///
305 /// This only makes sense when used in conjunction with `columns`. `with_point_fill_ratio` should
306 /// be used when logging a single row's worth of data.
308 const Collection<rerun::components::FillRatio>& _point_fill_ratio
309 ) && {
312 .value_or_throw();
313 return std::move(*this);
314 }
315
316 /// Optional 2D draw order.
318 draw_order =
319 ComponentBatch::from_loggable(_draw_order, Descriptor_draw_order).value_or_throw();
320 return std::move(*this);
321 }
322
323 /// This method makes it possible to pack multiple `draw_order` in a single component batch.
324 ///
325 /// This only makes sense when used in conjunction with `columns`. `with_draw_order` should
326 /// be used when logging a single row's worth of data.
329 ) && {
330 draw_order =
331 ComponentBatch::from_loggable(_draw_order, Descriptor_draw_order).value_or_throw();
332 return std::move(*this);
333 }
334
335 /// Optional filter used when a texel is magnified (displayed larger than a screen pixel) in 2D views.
336 ///
337 /// The filter is applied to the scalar values *before* they are mapped to color via the colormap.
338 ///
339 /// Has no effect in 3D views.
341 const rerun::components::MagnificationFilter& _magnification_filter
342 ) && {
344 _magnification_filter,
346 )
347 .value_or_throw();
348 return std::move(*this);
349 }
350
351 /// This method makes it possible to pack multiple `magnification_filter` in a single component batch.
352 ///
353 /// This only makes sense when used in conjunction with `columns`. `with_magnification_filter` should
354 /// be used when logging a single row's worth of data.
356 const Collection<rerun::components::MagnificationFilter>& _magnification_filter
357 ) && {
359 _magnification_filter,
361 )
362 .value_or_throw();
363 return std::move(*this);
364 }
365
366 /// Partitions the component data into multiple sub-batches.
367 ///
368 /// Specifically, this transforms the existing `ComponentBatch` data into `ComponentColumn`s
369 /// instead, via `ComponentBatch::partitioned`.
370 ///
371 /// This makes it possible to use `RecordingStream::send_columns` to send columnar data directly into Rerun.
372 ///
373 /// The specified `lengths` must sum to the total length of the component batch.
375 return detail::partition_batches(
376 {&blob,
377 &media_type,
378 &meter,
379 &colormap,
382 &draw_order,
384 lengths_
385 )
386 .value_or_throw();
387 }
388
389 /// Partitions the component data into unit-length sub-batches.
390 ///
391 /// This is semantically similar to calling `columns` with `std::vector<uint32_t>(n, 1)`,
392 /// where `n` is automatically guessed.
394 return detail::partition_batches_of_unit_length({&blob,
395 &media_type,
396 &meter,
397 &colormap,
400 &draw_order,
402 .value_or_throw();
403 }
404 };
405
406} // namespace rerun::archetypes
407
408namespace rerun {
409 /// \private
410 template <typename T>
411 struct AsComponents;
412
413 /// \private
414 template <>
415 struct AsComponents<archetypes::EncodedDepthImage> {
416 /// Serialize all set component batches.
417 static Result<Collection<ComponentBatch>> as_batches(
418 const archetypes::EncodedDepthImage& archetype
419 ) {
420 return detail::collect_batches(
421 {&archetype.blob,
422 &archetype.media_type,
423 &archetype.meter,
424 &archetype.colormap,
425 &archetype.depth_range,
426 &archetype.point_fill_ratio,
427 &archetype.draw_order,
428 &archetype.magnification_filter}
429 );
430 }
431 };
432} // namespace rerun
Generic collection of elements that are roughly contiguous in memory.
Definition collection.hpp:49
All built-in archetypes. See Types in the Rerun manual.
Definition rerun.hpp:90
Colormap
Component: Colormap for mapping scalar values within a given range to a color.
Definition colormap.hpp:28
MagnificationFilter
Component: Filter used when a single texel/pixel of an image is displayed larger than a single screen...
Definition magnification_filter.hpp:27
All Rerun C++ types and functions are in the rerun namespace or one of its nested namespaces.
Definition rerun.hpp:26
Arrow-encoded data of a single batch of components together with a component descriptor.
Definition component_batch.hpp:28
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
Archetype: A depth image encoded with a codec (e.g.
Definition encoded_depth_image.hpp:90
EncodedDepthImage with_magnification_filter(const rerun::components::MagnificationFilter &_magnification_filter) &&
Optional filter used when a texel is magnified (displayed larger than a screen pixel) in 2D views.
Definition encoded_depth_image.hpp:340
EncodedDepthImage with_colormap(const rerun::components::Colormap &_colormap) &&
Optional colormap for visualization of decoded depth.
Definition encoded_depth_image.hpp:256
EncodedDepthImage with_blob(const rerun::components::Blob &_blob) &&
The encoded depth payload.
Definition encoded_depth_image.hpp:200
std::optional< ComponentBatch > media_type
Media type of the blob, e.g.:
Definition encoded_depth_image.hpp:104
std::optional< ComponentBatch > colormap
Optional colormap for visualization of decoded depth.
Definition encoded_depth_image.hpp:112
std::optional< ComponentBatch > draw_order
Optional 2D draw order.
Definition encoded_depth_image.hpp:121
std::optional< ComponentBatch > point_fill_ratio
Optional point fill ratio for point-cloud projection.
Definition encoded_depth_image.hpp:118
static constexpr auto Descriptor_point_fill_ratio
ComponentDescriptor for the point_fill_ratio field.
Definition encoded_depth_image.hpp:160
static constexpr auto Descriptor_depth_range
ComponentDescriptor for the depth_range field.
Definition encoded_depth_image.hpp:155
static constexpr auto Descriptor_colormap
ComponentDescriptor for the colormap field.
Definition encoded_depth_image.hpp:150
static constexpr auto Descriptor_magnification_filter
ComponentDescriptor for the magnification_filter field.
Definition encoded_depth_image.hpp:170
static EncodedDepthImage clear_fields()
Clear all the fields of a EncodedDepthImage.
Collection< ComponentColumn > columns(const Collection< uint32_t > &lengths_)
Partitions the component data into multiple sub-batches.
Definition encoded_depth_image.hpp:374
EncodedDepthImage with_many_point_fill_ratio(const Collection< rerun::components::FillRatio > &_point_fill_ratio) &&
This method makes it possible to pack multiple point_fill_ratio in a single component batch.
Definition encoded_depth_image.hpp:307
static constexpr auto Descriptor_media_type
ComponentDescriptor for the media_type field.
Definition encoded_depth_image.hpp:140
EncodedDepthImage with_many_meter(const Collection< rerun::components::DepthMeter > &_meter) &&
This method makes it possible to pack multiple meter in a single component batch.
Definition encoded_depth_image.hpp:249
EncodedDepthImage with_draw_order(const rerun::components::DrawOrder &_draw_order) &&
Optional 2D draw order.
Definition encoded_depth_image.hpp:317
static constexpr auto Descriptor_draw_order
ComponentDescriptor for the draw_order field.
Definition encoded_depth_image.hpp:165
EncodedDepthImage with_many_colormap(const Collection< rerun::components::Colormap > &_colormap) &&
This method makes it possible to pack multiple colormap in a single component batch.
Definition encoded_depth_image.hpp:266
static constexpr auto Descriptor_meter
ComponentDescriptor for the meter field.
Definition encoded_depth_image.hpp:145
std::optional< ComponentBatch > meter
Conversion from native units to meters (e.g.
Definition encoded_depth_image.hpp:109
EncodedDepthImage with_many_media_type(const Collection< rerun::components::MediaType > &_media_type) &&
This method makes it possible to pack multiple media_type in a single component batch.
Definition encoded_depth_image.hpp:229
static constexpr auto Descriptor_blob
ComponentDescriptor for the blob field.
Definition encoded_depth_image.hpp:135
EncodedDepthImage with_meter(const rerun::components::DepthMeter &_meter) &&
Conversion from native units to meters (e.g.
Definition encoded_depth_image.hpp:240
static constexpr const char ArchetypeName[]
The name of the archetype as used in ComponentDescriptors.
Definition encoded_depth_image.hpp:132
std::optional< ComponentBatch > magnification_filter
Optional filter used when a texel is magnified (displayed larger than a screen pixel) in 2D views.
Definition encoded_depth_image.hpp:128
EncodedDepthImage with_many_blob(const Collection< rerun::components::Blob > &_blob) &&
This method makes it possible to pack multiple blob in a single component batch.
Definition encoded_depth_image.hpp:209
EncodedDepthImage with_point_fill_ratio(const rerun::components::FillRatio &_point_fill_ratio) &&
Optional point fill ratio for point-cloud projection.
Definition encoded_depth_image.hpp:294
EncodedDepthImage with_media_type(const rerun::components::MediaType &_media_type) &&
Media type of the blob, e.g.:
Definition encoded_depth_image.hpp:219
EncodedDepthImage with_depth_range(const rerun::components::ValueRange &_depth_range) &&
Optional visualization range for depth values.
Definition encoded_depth_image.hpp:275
EncodedDepthImage with_many_magnification_filter(const Collection< rerun::components::MagnificationFilter > &_magnification_filter) &&
This method makes it possible to pack multiple magnification_filter in a single component batch.
Definition encoded_depth_image.hpp:355
std::optional< ComponentBatch > depth_range
Optional visualization range for depth values.
Definition encoded_depth_image.hpp:115
static EncodedDepthImage update_fields()
Update only some specific fields of a EncodedDepthImage.
Definition encoded_depth_image.hpp:187
std::optional< ComponentBatch > blob
The encoded depth payload.
Definition encoded_depth_image.hpp:97
EncodedDepthImage 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 encoded_depth_image.hpp:327
EncodedDepthImage with_many_depth_range(const Collection< rerun::components::ValueRange > &_depth_range) &&
This method makes it possible to pack multiple depth_range in a single component batch.
Definition encoded_depth_image.hpp:285
Collection< ComponentColumn > columns()
Partitions the component data into unit-length sub-batches.
Definition encoded_depth_image.hpp:393
Component: A binary blob of data.
Definition blob.hpp:16
Component: The world->depth map scaling factor.
Definition depth_meter.hpp:24
Component: Draw order of 2D elements.
Definition draw_order.hpp:30
Component: How much a primitive fills out the available space.
Definition fill_ratio.hpp:19
Component: A standardized media type (RFC2046, formerly known as MIME types), encoded as a string.
Definition media_type.hpp:20
Component: Range of expected or valid values, specifying a lower and upper bound.
Definition value_range.hpp:18