Rerun C++ SDK
Loading...
Searching...
No Matches
video_frame_reference.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_types/definitions/rerun/archetypes/video_frame_reference.fbs".
3
4#pragma once
5
6#include "../collection.hpp"
7#include "../compiler_utils.hpp"
8#include "../component_batch.hpp"
9#include "../components/entity_path.hpp"
10#include "../components/video_timestamp.hpp"
11#include "../indicator_component.hpp"
12#include "../result.hpp"
13
14#include <cstdint>
15#include <optional>
16#include <utility>
17#include <vector>
18
19namespace rerun::archetypes {
20 /// **Archetype**: References a single video frame.
21 ///
22 /// Used to display individual video frames from a `archetypes::AssetVideo`.
23 /// To show an entire video, a video frame reference for each frame of the video should be logged.
24 ///
25 /// See <https://rerun.io/docs/reference/video> for details of what is and isn't supported.
26 ///
27 /// ## Examples
28 ///
29 /// ### Video with automatically determined frames
30 /// ![image](https://static.rerun.io/video_manual_frames/320a44e1e06b8b3a3161ecbbeae3e04d1ccb9589/full.png)
31 ///
32 /// ```cpp
33 /// #include <rerun.hpp>
34 ///
35 /// #include <iostream>
36 ///
37 /// using namespace std::chrono_literals;
38 ///
39 /// int main(int argc, char* argv[]) {
40 /// if (argc <2) {
41 /// // TODO(#7354): Only mp4 is supported for now.
42 /// std::cerr <<"Usage: " <<argv[0] <<" <path_to_video.[mp4]>" <<std::endl;
43 /// return 1;
44 /// }
45 ///
46 /// const auto path = argv[1];
47 ///
48 /// const auto rec = rerun::RecordingStream("rerun_example_asset_video_auto_frames");
49 /// rec.spawn().exit_on_failure();
50 ///
51 /// // Log video asset which is referred to by frame references.
52 /// auto video_asset = rerun::AssetVideo::from_file(path).value_or_throw();
53 /// rec.log_static("video", video_asset);
54 ///
55 /// // Send automatically determined video frame timestamps.
56 /// std::vector<std::chrono::nanoseconds> frame_timestamps_ns =
57 /// video_asset.read_frame_timestamps_ns().value_or_throw();
58 /// // Note timeline values don't have to be the same as the video timestamps.
59 /// auto time_column =
60 /// rerun::TimeColumn::from_times("video_time", rerun::borrow(frame_timestamps_ns));
61 ///
62 /// std::vector<rerun::components::VideoTimestamp> video_timestamps(frame_timestamps_ns.size());
63 /// for (size_t i = 0; i <frame_timestamps_ns.size(); i++) {
64 /// video_timestamps[i] = rerun::components::VideoTimestamp(frame_timestamps_ns[i]);
65 /// }
66 /// auto video_frame_reference_indicators =
67 /// rerun::ComponentColumn::from_indicators<rerun::VideoFrameReference>(
68 /// static_cast<uint32_t>(video_timestamps.size())
69 /// );
70 ///
71 /// rec.send_columns(
72 /// "video",
73 /// time_column,
74 /// {
75 /// video_frame_reference_indicators.value_or_throw(),
76 /// rerun::ComponentColumn::from_loggable(rerun::borrow(video_timestamps)).value_or_throw(),
77 /// }
78 /// );
79 /// }
80 /// ```
81 ///
82 /// ### Demonstrates manual use of video frame references
83 /// ![image](https://static.rerun.io/video_manual_frames/9f41c00f84a98cc3f26875fba7c1d2fa2bad7151/full.png)
84 ///
85 /// ```cpp
86 /// #include <rerun.hpp>
87 ///
88 /// #include <iostream>
89 ///
90 /// using namespace std::chrono_literals;
91 ///
92 /// int main(int argc, char* argv[]) {
93 /// if (argc <2) {
94 /// // TODO(#7354): Only mp4 is supported for now.
95 /// std::cerr <<"Usage: " <<argv[0] <<" <path_to_video.[mp4]>" <<std::endl;
96 /// return 1;
97 /// }
98 ///
99 /// const auto path = argv[1];
100 ///
101 /// const auto rec = rerun::RecordingStream("rerun_example_asset_video_manual_frames");
102 /// rec.spawn().exit_on_failure();
103 ///
104 /// // Log video asset which is referred to by frame references.
105 /// rec.log_static("video_asset", rerun::AssetVideo::from_file(path).value_or_throw());
106 ///
107 /// // Create two entities, showing the same video frozen at different times.
108 /// rec.log("frame_1s", rerun::VideoFrameReference(1.0s).with_video_reference("video_asset"));
109 /// rec.log("frame_2s", rerun::VideoFrameReference(2.0s).with_video_reference("video_asset"));
110 ///
111 /// // TODO(#5520): log blueprint once supported
112 /// }
113 /// ```
115 /// References the closest video frame to this timestamp.
116 ///
117 /// Note that this uses the closest video frame instead of the latest at this timestamp
118 /// in order to be more forgiving of rounding errors for inprecise timestamp types.
119 ///
120 /// Timestamps are relative to the start of the video, i.e. a timestamp of 0 always corresponds to the first frame.
121 /// This is oftentimes equivalent to presentation timestamps (known as PTS), but in the presence of B-frames
122 /// (bidirectionally predicted frames) there may be an offset on the first presentation timestamp in the video.
124
125 /// Optional reference to an entity with a `archetypes::AssetVideo`.
126 ///
127 /// If none is specified, the video is assumed to be at the same entity.
128 /// Note that blueprint overrides on the referenced video will be ignored regardless,
129 /// as this is always interpreted as a reference to the data store.
130 ///
131 /// For a series of video frame references, it is recommended to specify this path only once
132 /// at the beginning of the series and then rely on latest-at query semantics to
133 /// keep the video reference active.
134 std::optional<rerun::components::EntityPath> video_reference;
135
136 public:
137 static constexpr const char IndicatorComponentName[] =
138 "rerun.components.VideoFrameReferenceIndicator";
139
140 /// Indicator component, used to identify the archetype when converting to a list of components.
142
143 public:
144 VideoFrameReference() = default;
145 VideoFrameReference(VideoFrameReference&& other) = default;
146
148 : timestamp(std::move(_timestamp)) {}
149
150 /// Optional reference to an entity with a `archetypes::AssetVideo`.
151 ///
152 /// If none is specified, the video is assumed to be at the same entity.
153 /// Note that blueprint overrides on the referenced video will be ignored regardless,
154 /// as this is always interpreted as a reference to the data store.
155 ///
156 /// For a series of video frame references, it is recommended to specify this path only once
157 /// at the beginning of the series and then rely on latest-at query semantics to
158 /// keep the video reference active.
160 ) && {
161 video_reference = std::move(_video_reference);
162 // See: https://github.com/rerun-io/rerun/issues/4027
163 RR_WITH_MAYBE_UNINITIALIZED_DISABLED(return std::move(*this);)
164 }
165 };
166
167} // namespace rerun::archetypes
168
169namespace rerun {
170 /// \private
171 template <typename T>
172 struct AsComponents;
173
174 /// \private
175 template <>
176 struct AsComponents<archetypes::VideoFrameReference> {
177 /// Serialize all set component batches.
178 static Result<std::vector<ComponentBatch>> serialize(
179 const archetypes::VideoFrameReference& archetype
180 );
181 };
182} // namespace rerun
All built-in archetypes. See Types in the Rerun manual.
Definition rerun.hpp:77
All Rerun C++ types and functions are in the rerun namespace or one of its nested namespaces.
Definition rerun.hpp:23
Archetype: References a single video frame.
Definition video_frame_reference.hpp:114
VideoFrameReference with_video_reference(rerun::components::EntityPath _video_reference) &&
Optional reference to an entity with a archetypes::AssetVideo.
Definition video_frame_reference.hpp:159
rerun::components::VideoTimestamp timestamp
References the closest video frame to this timestamp.
Definition video_frame_reference.hpp:123
std::optional< rerun::components::EntityPath > video_reference
Optional reference to an entity with a archetypes::AssetVideo.
Definition video_frame_reference.hpp:134
Component: A path to an entity, usually to reference some data that is part of the target entity.
Definition entity_path.hpp:17
Indicator component used by archetypes when converting them to component lists.
Definition indicator_component.hpp:32
Component: Timestamp inside a archetypes::AssetVideo.
Definition video_timestamp.hpp:16