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