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