Monado OpenXR Runtime
Loading...
Searching...
No Matches
t_constellation_tracker_dataset.hpp
Go to the documentation of this file.
1// Copyright 2026, Beyley Cardellio
2// SPDX-License-Identifier: BSL-1.0
3/*!
4 * @file
5 * @brief Implementation of the data recorder logic for the constellation tracker.
6 * @author Beyley Cardellio <ep1cm1n10n123@gmail.com>
7 * @ingroup tracking
8 */
9
10#pragma once
11
13
14#include <mutex>
15
16
17namespace xrt::tracking::constellation {
18
20{
21private: // Fields
22 std::fstream file;
23
24public: // Methods
25 DataSerializer(std::string file, bool write);
26
28
29 void
30 write(uint8_t value);
31 void
32 read(uint8_t &value);
33
34 void
35 write(uint32_t value);
36 void
37 read(uint32_t &value);
38
39 void
40 write(float value);
41 void
42 read(float &value);
43
44 void
45 write(uint64_t value);
46 void
47 read(uint64_t &value);
48
49 void
50 write(double value);
51 void
52 read(double &value);
53
54 void
55 write(const xrt_pose &value);
56 void
57 read(xrt_pose &value);
58
59 void
60 write(const FoundDevicePose &value);
61 void
62 read(FoundDevicePose &value);
63
64 void
65 write(const DeviceState &value);
66 void
67 read(DeviceState &value);
68
69 void
70 write(const t_blob &value);
71 void
72 read(t_blob &value);
73
74 void
75 write(const CameraSample &value);
76 void
77 read(CameraSample &value);
78
79 void
80 write(const t_camera_calibration &value);
81 void
82 read(t_camera_calibration &value);
83
84 void
85 write(t_constellation_tracker_led &value);
86 void
87 read(t_constellation_tracker_led &value);
88
89 void
90 write(const t_constellation_tracker_led_model &value);
91 void
92 read(std::vector<t_constellation_tracker_led> &led_storage, t_constellation_tracker_led_model &value);
93
94 template <typename T>
95 void
96 write(const std::optional<T> &opt_value)
97 {
98 this->write(static_cast<uint8_t>(opt_value.has_value() ? 1 : 0));
99 if (opt_value.has_value()) {
100 this->write(opt_value.value());
101 }
102 }
103
104 template <typename T>
105 void
106 read(std::optional<T> &opt_value)
107 {
108 uint8_t has_value;
109 this->read(has_value);
110 if (has_value) {
111 T value;
112 this->read(value);
113 opt_value = value;
114 } else {
115 opt_value = std::nullopt;
116 }
117 }
118
119 void
120 flush();
121};
122
124{
125private: // Fields
126 DataSerializer serializer;
127
128 /*!
129 * Serializes writes to @ref serializer. Every camera has a fast processing thread of its own and
130 * records from it, so without this two cameras' packets interleave and the file is unreadable
131 * from the first race onwards.
132 */
133 std::mutex lock;
134
135public: // Methods
136 DataRecorder(ConstellationTracker *tracker, std::string out_file);
137
138 ~DataRecorder() = default;
139
140 void
141 recordSample(const CameraSample &sample);
142
143 void
144 recordDeviceInfo(const Device &device);
145};
146
148{
149 std::vector<t_camera_calibration> camera_calibrations;
150};
151
153{
154 t_constellation_device_id_t id;
155
156 std::vector<t_constellation_tracker_led> leds;
158};
159
161{
162private: // Fields
163 DataSerializer serializer;
164
165public: // Fields
166 std::vector<DatasetMosaic> mosaics;
167 std::vector<DatasetDevice> devices;
168
169 std::vector<CameraSample> samples;
170
171public: // Methods
172 DatasetReader(std::string filename);
173};
174
175}; // namespace xrt::tracking::constellation
A blob is a 2d position in a camera sensor's view that is being tracked.
Definition t_constellation.h:45
Essential calibration data for a single camera, or single lens/sensor of a stereo camera.
Definition t_tracking.h:236
The LED model is a series of points which define the real-world positions of all LEDs.
Definition t_constellation.h:274
Definition t_constellation.h:253
Definition t_constellation_tracker_internal.hpp:112
Definition t_constellation_tracker_internal.hpp:407
Definition t_constellation_tracker_dataset.hpp:124
Definition t_constellation_tracker_dataset.hpp:20
Definition t_constellation_tracker_dataset.hpp:153
Definition t_constellation_tracker_dataset.hpp:148
Definition t_constellation_tracker_dataset.hpp:161
Definition t_constellation_tracker_internal.hpp:344
Definition t_constellation_tracker_internal.hpp:97
Definition t_constellation_tracker_internal.hpp:91
A pose composed of a position and orientation.
Definition xrt_defines.h:502
Internal ures for the constellation tracker.