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, PNG, or TIFF).
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 /// * single channel TIFF with `U8`, `U16`, or `F32` samples
95 /// * RVL with ROS2 metadata (for details see <https://github.com/ros-perception/image_transport_plugins/tree/jazzy>)
96 std::optional<ComponentBatch> blob;
97
98 /// Media type of the blob, e.g.:
99 ///
100 /// * `application/rvl` (RVL-compressed 16-bit)
101 /// * `image/png`
102 /// * `image/tiff`
103 std::optional<ComponentBatch> media_type;
104
105 /// Conversion from native units to meters (e.g. `0.001` for millimeters).
106 ///
107 /// If omitted, the Viewer defaults to `1.0` for floating-point depth formats and `1000.0` for integer formats (millimeters).
108 std::optional<ComponentBatch> meter;
109
110 /// Optional colormap for visualization of decoded depth.
111 std::optional<ComponentBatch> colormap;
112
113 /// Optional visualization range for depth values.
114 std::optional<ComponentBatch> depth_range;
115
116 /// Optional point fill ratio for point-cloud projection.
117 std::optional<ComponentBatch> point_fill_ratio;
118
119 /// Optional 2D draw order.
120 std::optional<ComponentBatch> draw_order;
121
122 /// Optional filter used when a texel is magnified (displayed larger than a screen pixel) in 2D views.
123 ///
124 /// The filter is applied to the scalar values *before* they are mapped to color via the colormap.
125 ///
126 /// Has no effect in 3D views.
127 std::optional<ComponentBatch> magnification_filter;
128
129 public:
130 /// The name of the archetype as used in `ComponentDescriptor`s.
131 static constexpr const char ArchetypeName[] = "rerun.archetypes.EncodedDepthImage";
132
133 /// `ComponentDescriptor` for the `blob` field.
134 static constexpr auto Descriptor_blob = ComponentDescriptor(
135 ArchetypeName, "EncodedDepthImage:blob",
137 );
138 /// `ComponentDescriptor` for the `media_type` field.
140 ArchetypeName, "EncodedDepthImage:media_type",
142 );
143 /// `ComponentDescriptor` for the `meter` field.
144 static constexpr auto Descriptor_meter = ComponentDescriptor(
145 ArchetypeName, "EncodedDepthImage:meter",
147 );
148 /// `ComponentDescriptor` for the `colormap` field.
150 ArchetypeName, "EncodedDepthImage:colormap",
152 );
153 /// `ComponentDescriptor` for the `depth_range` field.
155 ArchetypeName, "EncodedDepthImage:depth_range",
157 );
158 /// `ComponentDescriptor` for the `point_fill_ratio` field.
160 ArchetypeName, "EncodedDepthImage:point_fill_ratio",
162 );
163 /// `ComponentDescriptor` for the `draw_order` field.
165 ArchetypeName, "EncodedDepthImage:draw_order",
167 );
168 /// `ComponentDescriptor` for the `magnification_filter` field.
170 ArchetypeName, "EncodedDepthImage:magnification_filter",
172 );
173
174 public:
175 EncodedDepthImage() = default;
176 EncodedDepthImage(EncodedDepthImage&& other) = default;
177 EncodedDepthImage(const EncodedDepthImage& other) = default;
178 EncodedDepthImage& operator=(const EncodedDepthImage& other) = default;
179 EncodedDepthImage& operator=(EncodedDepthImage&& other) = default;
180
182 : blob(ComponentBatch::from_loggable(std::move(_blob), Descriptor_blob).value_or_throw()
183 ) {}
184
185 /// Update only some specific fields of a `EncodedDepthImage`.
187 return EncodedDepthImage();
188 }
189
190 /// Clear all the fields of a `EncodedDepthImage`.
192
193 /// The encoded depth payload.
194 ///
195 /// Supported are:
196 /// * single channel PNG
197 /// * single channel TIFF with `U8`, `U16`, or `F32` samples
198 /// * RVL with ROS2 metadata (for details see <https://github.com/ros-perception/image_transport_plugins/tree/jazzy>)
200 blob = ComponentBatch::from_loggable(_blob, Descriptor_blob).value_or_throw();
201 return std::move(*this);
202 }
203
204 /// This method makes it possible to pack multiple `blob` in a single component batch.
205 ///
206 /// This only makes sense when used in conjunction with `columns`. `with_blob` should
207 /// be used when logging a single row's worth of data.
209 blob = ComponentBatch::from_loggable(_blob, Descriptor_blob).value_or_throw();
210 return std::move(*this);
211 }
212
213 /// Media type of the blob, e.g.:
214 ///
215 /// * `application/rvl` (RVL-compressed 16-bit)
216 /// * `image/png`
217 /// * `image/tiff`
219 media_type =
220 ComponentBatch::from_loggable(_media_type, Descriptor_media_type).value_or_throw();
221 return std::move(*this);
222 }
223
224 /// This method makes it possible to pack multiple `media_type` in a single component batch.
225 ///
226 /// This only makes sense when used in conjunction with `columns`. `with_media_type` should
227 /// be used when logging a single row's worth of data.
230 ) && {
231 media_type =
232 ComponentBatch::from_loggable(_media_type, Descriptor_media_type).value_or_throw();
233 return std::move(*this);
234 }
235
236 /// Conversion from native units to meters (e.g. `0.001` for millimeters).
237 ///
238 /// If omitted, the Viewer defaults to `1.0` for floating-point depth formats and `1000.0` for integer formats (millimeters).
240 meter = ComponentBatch::from_loggable(_meter, Descriptor_meter).value_or_throw();
241 return std::move(*this);
242 }
243
244 /// This method makes it possible to pack multiple `meter` in a single component batch.
245 ///
246 /// This only makes sense when used in conjunction with `columns`. `with_meter` should
247 /// be used when logging a single row's worth of data.
249 ) && {
250 meter = ComponentBatch::from_loggable(_meter, Descriptor_meter).value_or_throw();
251 return std::move(*this);
252 }
253
254 /// Optional colormap for visualization of decoded depth.
256 colormap =
257 ComponentBatch::from_loggable(_colormap, Descriptor_colormap).value_or_throw();
258 return std::move(*this);
259 }
260
261 /// This method makes it possible to pack multiple `colormap` in a single component batch.
262 ///
263 /// This only makes sense when used in conjunction with `columns`. `with_colormap` should
264 /// be used when logging a single row's worth of data.
267 ) && {
268 colormap =
269 ComponentBatch::from_loggable(_colormap, Descriptor_colormap).value_or_throw();
270 return std::move(*this);
271 }
272
273 /// Optional visualization range for depth values.
276 .value_or_throw();
277 return std::move(*this);
278 }
279
280 /// This method makes it possible to pack multiple `depth_range` in a single component batch.
281 ///
282 /// This only makes sense when used in conjunction with `columns`. `with_depth_range` should
283 /// be used when logging a single row's worth of data.
286 ) && {
288 .value_or_throw();
289 return std::move(*this);
290 }
291
292 /// Optional point fill ratio for point-cloud projection.
294 const rerun::components::FillRatio& _point_fill_ratio
295 ) && {
298 .value_or_throw();
299 return std::move(*this);
300 }
301
302 /// This method makes it possible to pack multiple `point_fill_ratio` in a single component batch.
303 ///
304 /// This only makes sense when used in conjunction with `columns`. `with_point_fill_ratio` should
305 /// be used when logging a single row's worth of data.
307 const Collection<rerun::components::FillRatio>& _point_fill_ratio
308 ) && {
311 .value_or_throw();
312 return std::move(*this);
313 }
314
315 /// Optional 2D draw order.
317 draw_order =
318 ComponentBatch::from_loggable(_draw_order, Descriptor_draw_order).value_or_throw();
319 return std::move(*this);
320 }
321
322 /// This method makes it possible to pack multiple `draw_order` in a single component batch.
323 ///
324 /// This only makes sense when used in conjunction with `columns`. `with_draw_order` should
325 /// be used when logging a single row's worth of data.
328 ) && {
329 draw_order =
330 ComponentBatch::from_loggable(_draw_order, Descriptor_draw_order).value_or_throw();
331 return std::move(*this);
332 }
333
334 /// Optional filter used when a texel is magnified (displayed larger than a screen pixel) in 2D views.
335 ///
336 /// The filter is applied to the scalar values *before* they are mapped to color via the colormap.
337 ///
338 /// Has no effect in 3D views.
340 const rerun::components::MagnificationFilter& _magnification_filter
341 ) && {
343 _magnification_filter,
345 )
346 .value_or_throw();
347 return std::move(*this);
348 }
349
350 /// This method makes it possible to pack multiple `magnification_filter` in a single component batch.
351 ///
352 /// This only makes sense when used in conjunction with `columns`. `with_magnification_filter` should
353 /// be used when logging a single row's worth of data.
355 const Collection<rerun::components::MagnificationFilter>& _magnification_filter
356 ) && {
358 _magnification_filter,
360 )
361 .value_or_throw();
362 return std::move(*this);
363 }
364
365 /// Partitions the component data into multiple sub-batches.
366 ///
367 /// Specifically, this transforms the existing `ComponentBatch` data into `ComponentColumn`s
368 /// instead, via `ComponentBatch::partitioned`.
369 ///
370 /// This makes it possible to use `RecordingStream::send_columns` to send columnar data directly into Rerun.
371 ///
372 /// The specified `lengths` must sum to the total length of the component batch.
374
375 /// Partitions the component data into unit-length sub-batches.
376 ///
377 /// This is semantically similar to calling `columns` with `std::vector<uint32_t>(n, 1)`,
378 /// where `n` is automatically guessed.
380 };
381
382} // namespace rerun::archetypes
383
384namespace rerun {
385 /// \private
386 template <typename T>
387 struct AsComponents;
388
389 /// \private
390 template <>
391 struct AsComponents<archetypes::EncodedDepthImage> {
392 /// Serialize all set component batches.
393 static Result<Collection<ComponentBatch>> as_batches(
394 const archetypes::EncodedDepthImage& archetype
395 );
396 };
397} // 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: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: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:339
EncodedDepthImage with_colormap(const rerun::components::Colormap &_colormap) &&
Optional colormap for visualization of decoded depth.
Definition encoded_depth_image.hpp:255
EncodedDepthImage with_blob(const rerun::components::Blob &_blob) &&
The encoded depth payload.
Definition encoded_depth_image.hpp:199
std::optional< ComponentBatch > media_type
Media type of the blob, e.g.:
Definition encoded_depth_image.hpp:103
std::optional< ComponentBatch > colormap
Optional colormap for visualization of decoded depth.
Definition encoded_depth_image.hpp:111
std::optional< ComponentBatch > draw_order
Optional 2D draw order.
Definition encoded_depth_image.hpp:120
std::optional< ComponentBatch > point_fill_ratio
Optional point fill ratio for point-cloud projection.
Definition encoded_depth_image.hpp:117
static constexpr auto Descriptor_point_fill_ratio
ComponentDescriptor for the point_fill_ratio field.
Definition encoded_depth_image.hpp:159
static constexpr auto Descriptor_depth_range
ComponentDescriptor for the depth_range field.
Definition encoded_depth_image.hpp:154
static constexpr auto Descriptor_colormap
ComponentDescriptor for the colormap field.
Definition encoded_depth_image.hpp:149
static constexpr auto Descriptor_magnification_filter
ComponentDescriptor for the magnification_filter field.
Definition encoded_depth_image.hpp:169
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:306
static constexpr auto Descriptor_media_type
ComponentDescriptor for the media_type field.
Definition encoded_depth_image.hpp:139
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:248
EncodedDepthImage with_draw_order(const rerun::components::DrawOrder &_draw_order) &&
Optional 2D draw order.
Definition encoded_depth_image.hpp:316
static constexpr auto Descriptor_draw_order
ComponentDescriptor for the draw_order field.
Definition encoded_depth_image.hpp:164
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:265
static constexpr auto Descriptor_meter
ComponentDescriptor for the meter field.
Definition encoded_depth_image.hpp:144
std::optional< ComponentBatch > meter
Conversion from native units to meters (e.g.
Definition encoded_depth_image.hpp:108
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:228
static constexpr auto Descriptor_blob
ComponentDescriptor for the blob field.
Definition encoded_depth_image.hpp:134
EncodedDepthImage with_meter(const rerun::components::DepthMeter &_meter) &&
Conversion from native units to meters (e.g.
Definition encoded_depth_image.hpp:239
static constexpr const char ArchetypeName[]
The name of the archetype as used in ComponentDescriptors.
Definition encoded_depth_image.hpp:131
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:127
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:208
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:293
EncodedDepthImage with_media_type(const rerun::components::MediaType &_media_type) &&
Media type of the blob, e.g.:
Definition encoded_depth_image.hpp:218
EncodedDepthImage with_depth_range(const rerun::components::ValueRange &_depth_range) &&
Optional visualization range for depth values.
Definition encoded_depth_image.hpp:274
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:354
std::optional< ComponentBatch > depth_range
Optional visualization range for depth values.
Definition encoded_depth_image.hpp:114
static EncodedDepthImage update_fields()
Update only some specific fields of a EncodedDepthImage.
Definition encoded_depth_image.hpp:186
std::optional< ComponentBatch > blob
The encoded depth payload.
Definition encoded_depth_image.hpp:96
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:326
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:284
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