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