Rerun C++ SDK
Loading...
Searching...
No Matches
annotation_context.hpp
1// DO NOT EDIT! This file was auto-generated by crates/re_types_builder/src/codegen/cpp/mod.rs
2// Based on "crates/re_types/definitions/rerun/archetypes/annotation_context.fbs".
3
4#pragma once
5
6#include "../collection.hpp"
7#include "../components/annotation_context.hpp"
8#include "../data_cell.hpp"
9#include "../indicator_component.hpp"
10#include "../result.hpp"
11
12#include <cstdint>
13#include <utility>
14#include <vector>
15
16namespace rerun::archetypes {
17 /// **Archetype**: The `AnnotationContext` provides additional information on how to display entities.
18 ///
19 /// Entities can use `ClassId`s and `KeypointId`s to provide annotations, and
20 /// the labels and colors will be looked up in the appropriate
21 /// `AnnotationContext`. We use the *first* annotation context we find in the
22 /// path-hierarchy when searching up through the ancestors of a given entity
23 /// path.
24 ///
25 /// ## Example
26 ///
27 /// ### Segmentation
28 /// ![image](https://static.rerun.io/annotation_context_segmentation/0e21c0a04e456fec41d16b0deaa12c00cddf2d9b/full.png)
29 ///
30 /// ```cpp
31 /// #include <rerun.hpp>
32 ///
33 /// #include <algorithm> // fill_n
34 /// #include <vector>
35 ///
36 /// int main() {
37 /// const auto rec = rerun::RecordingStream("rerun_example_annotation_context_connections");
38 /// rec.spawn().exit_on_failure();
39 ///
40 /// // create an annotation context to describe the classes
41 /// rec.log_timeless(
42 /// "segmentation",
43 /// rerun::AnnotationContext({
44 /// rerun::AnnotationInfo(1, "red", rerun::Rgba32(255, 0, 0)),
45 /// rerun::AnnotationInfo(2, "green", rerun::Rgba32(0, 255, 0)),
46 /// })
47 /// );
48 ///
49 /// // create a segmentation image
50 /// const int HEIGHT = 200;
51 /// const int WIDTH = 300;
52 /// std::vector<uint8_t> data(WIDTH * HEIGHT, 0);
53 /// for (auto y = 50; y <100; ++y) {
54 /// std::fill_n(data.begin() + y * WIDTH + 50, 70, static_cast<uint8_t>(1));
55 /// }
56 /// for (auto y = 100; y <180; ++y) {
57 /// std::fill_n(data.begin() + y * WIDTH + 130, 150, static_cast<uint8_t>(2));
58 /// }
59 ///
60 /// rec.log("segmentation/image", rerun::SegmentationImage({HEIGHT, WIDTH}, std::move(data)));
61 /// }
62 /// ```
64 /// List of class descriptions, mapping class indices to class names, colors etc.
66
67 public:
68 static constexpr const char IndicatorComponentName[] =
69 "rerun.components.AnnotationContextIndicator";
70
71 /// Indicator component, used to identify the archetype when converting to a list of components.
73
74 public:
75 AnnotationContext() = default;
76 AnnotationContext(AnnotationContext&& other) = default;
77
79 : context(std::move(_context)) {}
80
81 /// Returns the number of primary instances of this archetype.
82 size_t num_instances() const {
83 return 1;
84 }
85 };
86
87} // namespace rerun::archetypes
88
89namespace rerun {
90 /// \private
91 template <typename T>
92 struct AsComponents;
93
94 /// \private
95 template <>
96 struct AsComponents<archetypes::AnnotationContext> {
97 /// Serialize all set component batches.
98 static Result<std::vector<DataCell>> serialize(
99 const archetypes::AnnotationContext& archetype
100 );
101 };
102} // namespace rerun
All built-in archetypes. See Types in the Rerun manual.
Definition rerun.hpp:66
All Rerun C++ types and functions are in the rerun namespace or one of its nested namespaces.
Definition rerun.hpp:20
Archetype: The AnnotationContext provides additional information on how to display entities.
Definition annotation_context.hpp:63
size_t num_instances() const
Returns the number of primary instances of this archetype.
Definition annotation_context.hpp:82
rerun::components::AnnotationContext context
List of class descriptions, mapping class indices to class names, colors etc.
Definition annotation_context.hpp:65
Component: The AnnotationContext provides additional information on how to display entities.
Definition annotation_context.hpp:29
Indicator component used by archetypes when converting them to component lists.
Definition indicator_component.hpp:23