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/store/re_sdk_types/definitions/rerun/archetypes/encoded_depth_image.fbs".
3
4#pragma once
5
6#include "../collection.hpp"
7#include "../component_batch.hpp"
8#include "../component_column.hpp"
9#include "../components/blob.hpp"
10#include "../components/colormap.hpp"
11#include "../components/depth_meter.hpp"
12#include "../components/draw_order.hpp"
13#include "../components/fill_ratio.hpp"
14#include "../components/magnification_filter.hpp"
15#include "../components/media_type.hpp"
16#include "../components/value_range.hpp"
17#include "../result.hpp"
18
19#include <cstdint>
20#include <optional>
21#include <utility>
22#include <vector>
23
24namespace rerun::archetypes {
25 /// **Archetype**: A depth image encoded with a codec (e.g. RVL or PNG).
26 ///
27 /// Rerun also supports uncompressed depth images with the [`archetypes.DepthImage`](https://rerun.io/docs/reference/types/archetypes/depth_image).
28 ///
29 /// ## Example
30 ///
31 /// ### Encoded depth image
32 /// ![image](https://static.rerun.io/encoded_depth_image/d8180f8167278f9601808c360ba52eafaab52839/full.png)
33 ///
34 /// ```cpp
35 /// #include <rerun.hpp>
36 ///
37 /// #include <filesystem>
38 /// #include <fstream>
39 /// #include <iostream>
40 /// #include <vector>
41 ///
42 /// namespace fs = std::filesystem;
43 ///
44 /// int main(int argc, char* argv[]) {
45 /// if (argc <2) {
46 /// std::cerr <<"Usage: " <<argv[0] <<" <path_to_depth_image.[png|rvl]>" <<std::endl;
47 /// return 1;
48 /// }
49 ///
50 /// const auto rec = rerun::RecordingStream("rerun_example_encoded_depth_image");
51 /// rec.spawn().exit_on_failure();
52 ///
53 /// const auto depth_path = fs::path(argv[1]);
54 /// std::ifstream file(depth_path, std::ios::binary);
55 /// if (!file) {
56 /// std::cerr <<"Failed to open encoded depth image: " <<depth_path <<std::endl;
57 /// return 1;
58 /// }
59 ///
60 /// std::vector<uint8_t> bytes{
61 /// std::istreambuf_iterator<char>(file),
62 /// std::istreambuf_iterator<char>()};
63 /// // Determine media type based on file extension
64 /// rerun::components::MediaType media_type;
65 /// if (depth_path.extension() == ".png") {
66 /// media_type = rerun::components::MediaType::png();
67 /// } else {
68 /// media_type = rerun::components::MediaType::rvl();
69 /// }
70 ///
71 /// rec.log(
72 /// "depth/encoded",
73 /// rerun::archetypes::EncodedDepthImage()
74 /// .with_blob(rerun::components::Blob(
75 /// rerun::Collection<uint8_t>::take_ownership(std::move(bytes))
76 /// ))
77 /// .with_media_type(media_type)
78 /// .with_meter(0.001f)
79 /// );
80 /// }
81 /// ```
82 ///
83 /// ⚠ **This type is _unstable_ and may change significantly in a way that the data won't be backwards compatible.**
84 ///
86 /// The encoded depth payload.
87 ///
88 /// Supported are:
89 /// * single channel PNG
90 /// * RVL with ROS2 metadata (for details see <https://github.com/ros-perception/image_transport_plugins/tree/jazzy>)
91 std::optional<ComponentBatch> blob;
92
93 /// Media type of the blob, e.g.:
94 ///
95 /// * `application/rvl` (RVL-compressed 16-bit)
96 /// * `image/png`
97 std::optional<ComponentBatch> media_type;
98
99 /// Conversion from native units to meters (e.g. `0.001` for millimeters).
100 ///
101 /// If omitted, the Viewer defaults to `1.0` for floating-point depth formats and `1000.0` for integer formats (millimeters).
102 std::optional<ComponentBatch> meter;
103
104 /// Optional colormap for visualization of decoded depth.
105 std::optional<ComponentBatch> colormap;
106
107 /// Optional visualization range for depth values.
108 std::optional<ComponentBatch> depth_range;
109
110 /// Optional point fill ratio for point-cloud projection.
111 std::optional<ComponentBatch> point_fill_ratio;
112
113 /// Optional 2D draw order.
114 std::optional<ComponentBatch> draw_order;
115
116 /// Optional filter used when a texel is magnified (displayed larger than a screen pixel) in 2D views.
117 ///
118 /// The filter is applied to the scalar values *before* they are mapped to color via the colormap.
119 ///
120 /// Has no effect in 3D views.
121 std::optional<ComponentBatch> magnification_filter;
122
123 public:
124 /// The name of the archetype as used in `ComponentDescriptor`s.
125 static constexpr const char ArchetypeName[] = "rerun.archetypes.EncodedDepthImage";
126
127 /// `ComponentDescriptor` for the `blob` field.
128 static constexpr auto Descriptor_blob = ComponentDescriptor(
129 ArchetypeName, "EncodedDepthImage:blob",
131 );
132 /// `ComponentDescriptor` for the `media_type` field.
134 ArchetypeName, "EncodedDepthImage:media_type",
136 );
137 /// `ComponentDescriptor` for the `meter` field.
138 static constexpr auto Descriptor_meter = ComponentDescriptor(
139 ArchetypeName, "EncodedDepthImage:meter",
141 );
142 /// `ComponentDescriptor` for the `colormap` field.
144 ArchetypeName, "EncodedDepthImage:colormap",
146 );
147 /// `ComponentDescriptor` for the `depth_range` field.
149 ArchetypeName, "EncodedDepthImage:depth_range",
151 );
152 /// `ComponentDescriptor` for the `point_fill_ratio` field.
154 ArchetypeName, "EncodedDepthImage:point_fill_ratio",
156 );
157 /// `ComponentDescriptor` for the `draw_order` field.
159 ArchetypeName, "EncodedDepthImage:draw_order",
161 );
162 /// `ComponentDescriptor` for the `magnification_filter` field.
164 ArchetypeName, "EncodedDepthImage:magnification_filter",
166 );
167
168 public:
169 EncodedDepthImage() = default;
170 EncodedDepthImage(EncodedDepthImage&& other) = default;
171 EncodedDepthImage(const EncodedDepthImage& other) = default;
172 EncodedDepthImage& operator=(const EncodedDepthImage& other) = default;
173 EncodedDepthImage& operator=(EncodedDepthImage&& other) = default;
174
176 : blob(ComponentBatch::from_loggable(std::move(_blob), Descriptor_blob).value_or_throw()
177 ) {}
178
179 /// Update only some specific fields of a `EncodedDepthImage`.
181 return EncodedDepthImage();
182 }
183
184 /// Clear all the fields of a `EncodedDepthImage`.
186
187 /// The encoded depth payload.
188 ///
189 /// Supported are:
190 /// * single channel PNG
191 /// * RVL with ROS2 metadata (for details see <https://github.com/ros-perception/image_transport_plugins/tree/jazzy>)
193 blob = ComponentBatch::from_loggable(_blob, Descriptor_blob).value_or_throw();
194 return std::move(*this);
195 }
196
197 /// This method makes it possible to pack multiple `blob` in a single component batch.
198 ///
199 /// This only makes sense when used in conjunction with `columns`. `with_blob` should
200 /// be used when logging a single row's worth of data.
202 blob = ComponentBatch::from_loggable(_blob, Descriptor_blob).value_or_throw();
203 return std::move(*this);
204 }
205
206 /// Media type of the blob, e.g.:
207 ///
208 /// * `application/rvl` (RVL-compressed 16-bit)
209 /// * `image/png`
211 media_type =
212 ComponentBatch::from_loggable(_media_type, Descriptor_media_type).value_or_throw();
213 return std::move(*this);
214 }
215
216 /// This method makes it possible to pack multiple `media_type` in a single component batch.
217 ///
218 /// This only makes sense when used in conjunction with `columns`. `with_media_type` should
219 /// be used when logging a single row's worth of data.
222 ) && {
223 media_type =
224 ComponentBatch::from_loggable(_media_type, Descriptor_media_type).value_or_throw();
225 return std::move(*this);
226 }
227
228 /// Conversion from native units to meters (e.g. `0.001` for millimeters).
229 ///
230 /// If omitted, the Viewer defaults to `1.0` for floating-point depth formats and `1000.0` for integer formats (millimeters).
232 meter = ComponentBatch::from_loggable(_meter, Descriptor_meter).value_or_throw();
233 return std::move(*this);
234 }
235
236 /// This method makes it possible to pack multiple `meter` in a single component batch.
237 ///
238 /// This only makes sense when used in conjunction with `columns`. `with_meter` should
239 /// be used when logging a single row's worth of data.
241 ) && {
242 meter = ComponentBatch::from_loggable(_meter, Descriptor_meter).value_or_throw();
243 return std::move(*this);
244 }
245
246 /// Optional colormap for visualization of decoded depth.
248 colormap =
249 ComponentBatch::from_loggable(_colormap, Descriptor_colormap).value_or_throw();
250 return std::move(*this);
251 }
252
253 /// This method makes it possible to pack multiple `colormap` in a single component batch.
254 ///
255 /// This only makes sense when used in conjunction with `columns`. `with_colormap` should
256 /// be used when logging a single row's worth of data.
259 ) && {
260 colormap =
261 ComponentBatch::from_loggable(_colormap, Descriptor_colormap).value_or_throw();
262 return std::move(*this);
263 }
264
265 /// Optional visualization range for depth values.
268 .value_or_throw();
269 return std::move(*this);
270 }
271
272 /// This method makes it possible to pack multiple `depth_range` in a single component batch.
273 ///
274 /// This only makes sense when used in conjunction with `columns`. `with_depth_range` should
275 /// be used when logging a single row's worth of data.
278 ) && {
280 .value_or_throw();
281 return std::move(*this);
282 }
283
284 /// Optional point fill ratio for point-cloud projection.
286 const rerun::components::FillRatio& _point_fill_ratio
287 ) && {
290 .value_or_throw();
291 return std::move(*this);
292 }
293
294 /// This method makes it possible to pack multiple `point_fill_ratio` in a single component batch.
295 ///
296 /// This only makes sense when used in conjunction with `columns`. `with_point_fill_ratio` should
297 /// be used when logging a single row's worth of data.
299 const Collection<rerun::components::FillRatio>& _point_fill_ratio
300 ) && {
303 .value_or_throw();
304 return std::move(*this);
305 }
306
307 /// Optional 2D draw order.
309 draw_order =
310 ComponentBatch::from_loggable(_draw_order, Descriptor_draw_order).value_or_throw();
311 return std::move(*this);
312 }
313
314 /// This method makes it possible to pack multiple `draw_order` in a single component batch.
315 ///
316 /// This only makes sense when used in conjunction with `columns`. `with_draw_order` should
317 /// be used when logging a single row's worth of data.
320 ) && {
321 draw_order =
322 ComponentBatch::from_loggable(_draw_order, Descriptor_draw_order).value_or_throw();
323 return std::move(*this);
324 }
325
326 /// Optional filter used when a texel is magnified (displayed larger than a screen pixel) in 2D views.
327 ///
328 /// The filter is applied to the scalar values *before* they are mapped to color via the colormap.
329 ///
330 /// Has no effect in 3D views.
332 const rerun::components::MagnificationFilter& _magnification_filter
333 ) && {
335 _magnification_filter,
337 )
338 .value_or_throw();
339 return std::move(*this);
340 }
341
342 /// This method makes it possible to pack multiple `magnification_filter` in a single component batch.
343 ///
344 /// This only makes sense when used in conjunction with `columns`. `with_magnification_filter` should
345 /// be used when logging a single row's worth of data.
347 const Collection<rerun::components::MagnificationFilter>& _magnification_filter
348 ) && {
350 _magnification_filter,
352 )
353 .value_or_throw();
354 return std::move(*this);
355 }
356
357 /// Partitions the component data into multiple sub-batches.
358 ///
359 /// Specifically, this transforms the existing `ComponentBatch` data into `ComponentColumn`s
360 /// instead, via `ComponentBatch::partitioned`.
361 ///
362 /// This makes it possible to use `RecordingStream::send_columns` to send columnar data directly into Rerun.
363 ///
364 /// The specified `lengths` must sum to the total length of the component batch.
366
367 /// Partitions the component data into unit-length sub-batches.
368 ///
369 /// This is semantically similar to calling `columns` with `std::vector<uint32_t>(n, 1)`,
370 /// where `n` is automatically guessed.
372 };
373
374} // namespace rerun::archetypes
375
376namespace rerun {
377 /// \private
378 template <typename T>
379 struct AsComponents;
380
381 /// \private
382 template <>
383 struct AsComponents<archetypes::EncodedDepthImage> {
384 /// Serialize all set component batches.
385 static Result<Collection<ComponentBatch>> as_batches(
386 const archetypes::EncodedDepthImage& archetype
387 );
388 };
389} // namespace rerun
Generic collection of elements that are roughly contiguous in memory.
Definition collection.hpp:49
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
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:23
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:85
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:331
EncodedDepthImage with_colormap(const rerun::components::Colormap &_colormap) &&
Optional colormap for visualization of decoded depth.
Definition encoded_depth_image.hpp:247
EncodedDepthImage with_blob(const rerun::components::Blob &_blob) &&
The encoded depth payload.
Definition encoded_depth_image.hpp:192
std::optional< ComponentBatch > media_type
Media type of the blob, e.g.:
Definition encoded_depth_image.hpp:97
std::optional< ComponentBatch > colormap
Optional colormap for visualization of decoded depth.
Definition encoded_depth_image.hpp:105
std::optional< ComponentBatch > draw_order
Optional 2D draw order.
Definition encoded_depth_image.hpp:114
std::optional< ComponentBatch > point_fill_ratio
Optional point fill ratio for point-cloud projection.
Definition encoded_depth_image.hpp:111
static constexpr auto Descriptor_point_fill_ratio
ComponentDescriptor for the point_fill_ratio field.
Definition encoded_depth_image.hpp:153
static constexpr auto Descriptor_depth_range
ComponentDescriptor for the depth_range field.
Definition encoded_depth_image.hpp:148
static constexpr auto Descriptor_colormap
ComponentDescriptor for the colormap field.
Definition encoded_depth_image.hpp:143
static constexpr auto Descriptor_magnification_filter
ComponentDescriptor for the magnification_filter field.
Definition encoded_depth_image.hpp:163
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.
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:298
static constexpr auto Descriptor_media_type
ComponentDescriptor for the media_type field.
Definition encoded_depth_image.hpp:133
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:240
EncodedDepthImage with_draw_order(const rerun::components::DrawOrder &_draw_order) &&
Optional 2D draw order.
Definition encoded_depth_image.hpp:308
static constexpr auto Descriptor_draw_order
ComponentDescriptor for the draw_order field.
Definition encoded_depth_image.hpp:158
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:257
static constexpr auto Descriptor_meter
ComponentDescriptor for the meter field.
Definition encoded_depth_image.hpp:138
std::optional< ComponentBatch > meter
Conversion from native units to meters (e.g.
Definition encoded_depth_image.hpp:102
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:220
static constexpr auto Descriptor_blob
ComponentDescriptor for the blob field.
Definition encoded_depth_image.hpp:128
EncodedDepthImage with_meter(const rerun::components::DepthMeter &_meter) &&
Conversion from native units to meters (e.g.
Definition encoded_depth_image.hpp:231
static constexpr const char ArchetypeName[]
The name of the archetype as used in ComponentDescriptors.
Definition encoded_depth_image.hpp:125
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:121
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:201
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:285
EncodedDepthImage with_media_type(const rerun::components::MediaType &_media_type) &&
Media type of the blob, e.g.:
Definition encoded_depth_image.hpp:210
EncodedDepthImage with_depth_range(const rerun::components::ValueRange &_depth_range) &&
Optional visualization range for depth values.
Definition encoded_depth_image.hpp:266
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:346
std::optional< ComponentBatch > depth_range
Optional visualization range for depth values.
Definition encoded_depth_image.hpp:108
static EncodedDepthImage update_fields()
Update only some specific fields of a EncodedDepthImage.
Definition encoded_depth_image.hpp:180
std::optional< ComponentBatch > blob
The encoded depth payload.
Definition encoded_depth_image.hpp:91
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:318
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:276
Collection< ComponentColumn > columns()
Partitions the component data into unit-length sub-batches.
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:19
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