LibMultiSense
LibMultiSense Documentation
Loading...
Searching...
No Matches
ApriltagDetections.hh
Go to the documentation of this file.
1
39#ifndef LibMultiSense_ApriltagDetections
40#define LibMultiSense_ApriltagDetections
41
43
44namespace crl {
45namespace multisense {
46namespace details {
47namespace wire {
48
50public:
51 static CRL_CONSTEXPR IdType ID = ID_DATA_APRILTAG_DETECTIONS_MESSAGE;
52 static CRL_CONSTEXPR VersionType VERSION = 1;
53
54#ifdef SENSORPOD_FIRMWARE
55 IdType id;
56 VersionType version;
57#endif // SENSORPOD_FIRMWARE
58
59 // The frame ID of the image that the apriltags were detected on
60 int64_t frameId;
61
62 // The frame timestamp (nanoseconds) of the image that the apriltags were detected on
63 int64_t timestamp;
64
65 // The image source that the apriltags were detected on
66 char imageSource[32];
67
68 // Success flag to indicate whether for the apriltag algorithm ran successfully
69 uint8_t success;
70
71 // The number of apriltags that were detected
72 uint32_t numDetections;
73
74 //
75 // Constructors
76
78#ifdef SENSORPOD_FIRMWARE
79 id(ID),
80 version(VERSION),
81#endif // SENSORPOD_FIRMWARE
82 frameId(0),
83 timestamp(0),
84 success(0),
85 numDetections(0)
86 {
87 strncpy(imageSource, "", sizeof(imageSource));
88 };
89};
90
92public:
94
95 // The family of the tag
96 char family[32];
97
98 // The ID of the tag
99 uint32_t id;
100
101 // The hamming distance between the detection and the real code
102 uint8_t hamming;
103
104 // The quality/confidence of the binary decoding process
105 // average difference between intensity of data bit vs decision thresh.
106 // Higher is better. Only useful for small tags
108
109 // The 3x3 homography matrix describing the projection from an
110 // "ideal" tag (with corners at (-1,1), (1,1), (1,-1), and (-1,
111 // -1)) to pixels in the image
113
114 // The 2D position of the origin of the tag in the image
115 double center[2];
116
117 // The 4 tag corner pixel locations in the order:
118 // point 0: [-squareLength / 2, squareLength / 2]
119 // point 1: [ squareLength / 2, squareLength / 2]
120 // point 2: [ squareLength / 2, -squareLength / 2]
121 // point 3: [-squareLength / 2, -squareLength / 2]
122 double corners[4][2];
123
124#ifndef SENSORPOD_FIRMWARE
125 //
126 // Serialization routine
127
128 template<class Archive>
129 void serialize(Archive& message,
130 const VersionType version)
131 {
132 (void) version;
133
134 SER_ARRAY_1(family, 32);
135 message & id;
136 message & hamming;
137 message & decisionMargin;
140 SER_ARRAY_2(corners, 4, 2);
141 }
142#endif // !SENSORPOD_FIRMWARE
143};
144
146public:
147
148 //
149 // Apriltag detections
150
151 std::vector<ApriltagDetection> detections;
152
153#ifndef SENSORPOD_FIRMWARE
154
155 //
156 // Constructors
157
159
161
162 //
163 // Serialization routine
164
165 template<class Archive>
166 void serialize(Archive& message,
167 const VersionType version)
168 {
169 (void) version;
170
171 message & frameId;
172 message & timestamp;
174 message & success;
175 message & numDetections;
176
177 const uint32_t wireBytes = static_cast<uint32_t>(numDetections * sizeof(ApriltagDetection));
178
179 if (typeid(Archive) == typeid(utility::BufferStreamWriter)) {
180
181 message.write(reinterpret_cast<void*>(detections.data()), wireBytes);
182
183 } else {
184
185 void *rawDetectionsData = message.peek();
186 message.seek(message.tell() + wireBytes);
187
189 memcpy(detections.data(), rawDetectionsData, wireBytes);
190 }
191
192 }
193#endif // !SENSORPOD_FIRMWARE
194};
195
196}}}} // namespaces
197
198#endif
Macros and symbols to help portability between different compiler versions.
#define CRL_CONSTEXPR
#define WIRE_HEADER_ATTRIBS_
Definition Protocol.hh:65
#define SER_ARRAY_1(a_, n_)
Definition Protocol.hh:347
#define SER_ARRAY_2(a_, n_, m_)
Definition Protocol.hh:351
void serialize(Archive &message, const VersionType version)
ApriltagDetections(utility::BufferStreamReader &r, VersionType v)
void serialize(Archive &message, const VersionType version)