gusimplewhiteboard
VisionDetectionFeatures.hpp
Go to the documentation of this file.
1/*
2 * file VisionDetectionFeatures.hpp
3 *
4 * This file was generated by classgenerator from vision_detection_features.gen.
5 * DO NOT CHANGE MANUALLY!
6 *
7 * Copyright © 2021 Carl Lusty. All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 *
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 *
16 * 2. Redistributions in binary form must reproduce the above
17 * copyright notice, this list of conditions and the following
18 * disclaimer in the documentation and/or other materials
19 * provided with the distribution.
20 *
21 * 3. All advertising materials mentioning features or use of this
22 * software must display the following acknowledgement:
23 *
24 * This product includes software developed by Carl Lusty.
25 *
26 * 4. Neither the name of the author nor the names of contributors
27 * may be used to endorse or promote products derived from this
28 * software without specific prior written permission.
29 *
30 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
31 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
32 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
33 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
34 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
35 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
36 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
37 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
38 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
39 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
40 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
41 *
42 * -----------------------------------------------------------------------
43 * This program is free software; you can redistribute it and/or
44 * modify it under the above terms or under the terms of the GNU
45 * General Public License as published by the Free Software Foundation;
46 * either version 2 of the License, or (at your option) any later version.
47 *
48 * This program is distributed in the hope that it will be useful,
49 * but WITHOUT ANY WARRANTY; without even the implied warranty of
50 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
51 * GNU General Public License for more details.
52 *
53 * You should have received a copy of the GNU General Public License
54 * along with this program; if not, see http://www.gnu.org/licenses/
55 * or write to the Free Software Foundation, Inc., 51 Franklin Street,
56 * Fifth Floor, Boston, MA 02110-1301, USA.
57 *
58 */
59
60#ifndef guWhiteboard_VisionDetectionFeatures_h
61#define guWhiteboard_VisionDetectionFeatures_h
62
63#ifdef WHITEBOARD_POSTER_STRING_CONVERSION
64#include <cstdlib>
65#include <string.h>
66#include <sstream>
67#endif
68
69#include <gu_util.h>
71
72#undef guWhiteboard_VisionDetectionFeatures_DEFINED
73#define guWhiteboard_VisionDetectionFeatures_DEFINED
74
75#undef VisionDetectionFeatures_DEFINED
76#define VisionDetectionFeatures_DEFINED
77
79
80namespace guWhiteboard {
81
86
87 private:
88
92 void init(uint64_t t_frameNumber = 0, const struct wb_vision_detection_feature_array t_features[2] = NULLPTR) {
93 set_frameNumber(t_frameNumber);
94 if (t_features != NULLPTR) {
96 } else {
99 }
100 }
101
102 public:
103
107 VisionDetectionFeatures(uint64_t t_frameNumber = 0, const struct wb_vision_detection_feature_array t_features[2] = NULLPTR) {
108 this->init(t_frameNumber, t_features);
109 }
110
115 this->init(t_other.frameNumber(), t_other.features());
116 }
117
122 this->init(t_other.frameNumber, t_other.features);
123 }
124
129 this->init(t_other.frameNumber(), t_other.features());
130 return *this;
131 }
132
137 this->init(t_other.frameNumber, t_other.features);
138 return *this;
139 }
140
141 bool operator ==(const VisionDetectionFeatures &t_other) const
142 {
143 if (!(frameNumber() == t_other.frameNumber()))
144 {
145 return false;
146 }
147 for (int features_0_index = 0; features_0_index < 2; features_0_index++)
148 {
149 if (!(VisionDetectionFeatureArray(features(features_0_index)) == VisionDetectionFeatureArray(t_other.features(features_0_index)))) return false;
150 }
151 return true;
152 }
153
154 bool operator !=(const VisionDetectionFeatures &t_other) const
155 {
156 return !(*this == t_other);
157 }
158
159 bool operator ==(const wb_vision_detection_features &t_other) const
160 {
161 return *this == VisionDetectionFeatures(t_other);
162 }
163
164 bool operator !=(const wb_vision_detection_features &t_other) const
165 {
166 return !(*this == t_other);
167 }
168
169 uint64_t & frameNumber()
170 {
172 }
173
174 const uint64_t & frameNumber() const
175 {
177 }
178
179 void set_frameNumber(const uint64_t &t_newValue)
180 {
182 }
183
185 {
187 }
188
189 size_t features_size() const
190 {
192 }
193
195 {
197 }
198
200 {
202 }
203
205 {
207 }
208
209 void set_features(const VisionDetectionFeatureArray &t_newValue, int t_i)
210 {
212 }
213
214#ifdef WHITEBOARD_POSTER_STRING_CONVERSION
218 VisionDetectionFeatures(const std::string &t_str) {
219 this->init();
220 this->from_string(t_str);
221 }
222
223 std::string description() {
224#ifdef USE_WB_VISION_DETECTION_FEATURES_C_CONVERSION
226 wb_vision_detection_features_description(this, buffer, sizeof(buffer));
227 std::string descr = buffer;
228 return descr;
229#else
230 std::ostringstream ss;
231 ss << "frameNumber=" << this->frameNumber();
232 ss << ", ";
233 bool features_first = true;
234 ss << "features={";
235 for (int i = 0; i < VISION_DETECTION_FEATURES_FEATURES_ARRAY_SIZE; i++) {
236 ss << (features_first ? "" : ", ") << "{" << VisionDetectionFeatureArray(this->features(i)).description() << "}";
237 features_first = false;
238 }
239 ss << "}";
240 return ss.str();
241#endif
242 }
243
244 std::string to_string() {
245#ifdef USE_WB_VISION_DETECTION_FEATURES_C_CONVERSION
247 wb_vision_detection_features_to_string(this, buffer, sizeof(buffer));
248 std::string toString = buffer;
249 return toString;
250#else
251 std::ostringstream ss;
252 ss << this->frameNumber();
253 ss << ", ";
254 bool features_first = true;
255 ss << "{";
256 for (int i = 0; i < VISION_DETECTION_FEATURES_FEATURES_ARRAY_SIZE; i++) {
257 ss << (features_first ? "" : ", ") << "{" << VisionDetectionFeatureArray(this->features(i)).to_string() << "}";
258 features_first = false;
259 }
260 ss << "}";
261 return ss.str();
262#endif
263 }
264
265#ifdef USE_WB_VISION_DETECTION_FEATURES_C_CONVERSION
266 void from_string(const std::string &t_str) {
267 wb_vision_detection_features_from_string(this, t_str.c_str());
268#else
269 void from_string(const std::string &t_str) {
270 char * str_cstr = const_cast<char *>(t_str.c_str());
271 size_t temp_length = strlen(str_cstr);
272 int length = (temp_length <= INT_MAX) ? static_cast<int>(static_cast<ssize_t>(temp_length)) : -1;
273 if (length < 1 || length > VISION_DETECTION_FEATURES_DESC_BUFFER_SIZE) {
274 return;
275 }
276 char var_str_buffer[VISION_DETECTION_FEATURES_DESC_BUFFER_SIZE + 1];
277 char* var_str = &var_str_buffer[0];
278 char key_buffer[12];
279 char* key = &key_buffer[0];
280 int bracecount = 0;
281 int lastBrace = -1;
282 int startVar = 0;
283 int index = 0;
284 int startKey = 0;
285 int endKey = -1;
286 int varIndex = 0;
287 if (index == 0 && str_cstr[0] == '{') {
288 index = 1;
289 }
290 startVar = index;
291 startKey = startVar;
292 do {
293 for (int i = index; i < length; i++) {
294 index = i + 1;
295 if (bracecount == 0 && str_cstr[i] == '=') {
296 endKey = i - 1;
297 startVar = index;
298 continue;
299 }
300 if (bracecount == 0 && isspace(str_cstr[i])) {
301 startVar = index;
302 if (endKey == -1) {
303 startKey = index;
304 }
305 continue;
306 }
307 if (bracecount == 0 && str_cstr[i] == ',') {
308 index = i - 1;
309 break;
310 }
311 if (str_cstr[i] == '{') {
312 bracecount++;
313 if (bracecount == 1) {
314 lastBrace = i;
315 }
316 continue;
317 }
318 if (str_cstr[i] == '}') {
319 bracecount--;
320 if (bracecount < 0) {
321 index = i - 1;
322 break;
323 }
324 }
325 if (i == length - 1) {
326 index = i;
327 }
328 }
329 if (endKey >= startKey && endKey - startKey < length) {
330 strncpy(key, str_cstr + startKey, static_cast<size_t>((endKey - startKey) + 1));
331 key[(endKey - startKey) + 1] = 0;
332 } else {
333 key[0] = 0;
334 }
335 strncpy(var_str, str_cstr + startVar, static_cast<size_t>((index - startVar) + 1));
336 var_str[(index - startVar) + 1] = 0;
337 bracecount = 0;
338 index += 2;
339 startVar = index;
340 startKey = startVar;
341 endKey = -1;
342 if (strlen(key) > 0) {
343 if (0 == strcmp("frameNumber", key)) {
344 varIndex = 0;
345 } else if (0 == strcmp("features", key)) {
346 varIndex = 1;
347 } else {
348 varIndex = -1;
349 }
350 }
351 switch (varIndex) {
352 case -1: { break; }
353 case 0:
354 {
355#ifdef __APPLE__
356 this->set_frameNumber(static_cast<uint64_t>(atoll(var_str)));
357#else
358 this->set_frameNumber(static_cast<uint64_t>(atol(var_str)));
359#endif
360 break;
361 }
362 case 1:
363 {
364 int restartIndex = index;
365 index = lastBrace + 1;
366 startVar = index;
367 startKey = startVar;
368 endKey = -1;
369 bracecount = 0;
370 for (int features_0_index = 0; features_0_index < VISION_DETECTION_FEATURES_FEATURES_ARRAY_SIZE; features_0_index++) {
371 for (int i = index; i < length; i++) {
372 index = i + 1;
373 if (bracecount == 0 && str_cstr[i] == '=') {
374 endKey = i - 1;
375 startVar = index;
376 continue;
377 }
378 if (bracecount == 0 && isspace(str_cstr[i])) {
379 startVar = index;
380 if (endKey == -1) {
381 startKey = index;
382 }
383 continue;
384 }
385 if (bracecount == 0 && str_cstr[i] == ',') {
386 index = i - 1;
387 break;
388 }
389 if (str_cstr[i] == '{') {
390 bracecount++;
391 continue;
392 }
393 if (str_cstr[i] == '}') {
394 bracecount--;
395 if (bracecount < 0) {
396 index = i - 1;
397 break;
398 }
399 }
400 if (i == length - 1) {
401 index = i;
402 }
403 }
404 if (endKey >= startKey && endKey - startKey < length) {
405 strncpy(key, str_cstr + startKey, static_cast<size_t>((endKey - startKey) + 1));
406 key[(endKey - startKey) + 1] = 0;
407 } else {
408 key[0] = 0;
409 }
410 strncpy(var_str, str_cstr + startVar, static_cast<size_t>((index - startVar) + 1));
411 var_str[(index - startVar) + 1] = 0;
412 bracecount = 0;
413 index += 2;
414 startVar = index;
415 startKey = startVar;
416 endKey = -1;
418 features_0_temp.from_string(var_str);
419 struct wb_vision_detection_feature_array features_0 = features_0_temp;
420 this->set_features(features_0, features_0_index);
421 }
422 index = restartIndex;
423 break;
424 }
425 }
426 if (varIndex >= 0) {
427 varIndex++;
428 }
429 } while(index < length);
430#endif
431 }
432#endif
433 };
434
435}
436
437#endif
Provides a C++ wrapper around wb_vision_detection_feature_array.
Provides a C++ wrapper around wb_vision_detection_features.
void from_string(const std::string &t_str)
void set_features(const VisionDetectionFeatureArray &t_newValue, int t_i)
const VisionDetectionFeatureArray * features() const
bool operator!=(const VisionDetectionFeatures &t_other) const
bool operator==(const VisionDetectionFeatures &t_other) const
VisionDetectionFeatures(const VisionDetectionFeatures &t_other)
Copy Constructor.
void set_frameNumber(const uint64_t &t_newValue)
void set_features(const VisionDetectionFeatureArray *t_newValue)
VisionDetectionFeatureArray & features(int t_i)
VisionDetectionFeatures(const std::string &t_str)
String Constructor.
VisionDetectionFeatures(const struct wb_vision_detection_features &t_other)
Copy Constructor.
VisionDetectionFeatures(uint64_t t_frameNumber=0, const struct wb_vision_detection_feature_array t_features[2]=NULLPTR)
Create a new VisionDetectionFeatures.
const VisionDetectionFeatureArray & features(int t_i) const
VisionDetectionFeatures & operator=(const VisionDetectionFeatures &t_other)
Copy Assignment Operator.
/file APM_Interface.h
Results for the Feature Detector (guvision).
Results for the Feature Detector (guvision).
struct wb_vision_detection_feature_array features[2]
Features reported for each camera.
uint64_t frameNumber
The frame number that these lines were seen in.
struct wb_vision_detection_features * wb_vision_detection_features_from_string(struct wb_vision_detection_features *self, const char *str)
Convert from a string.
const char * wb_vision_detection_features_description(const struct wb_vision_detection_features *self, char *descString, size_t bufferSize)
Convert to a description string.
const char * wb_vision_detection_features_to_string(const struct wb_vision_detection_features *self, char *toString, size_t bufferSize)
Convert to a string.
#define VISION_DETECTION_FEATURES_DESC_BUFFER_SIZE
#define VISION_DETECTION_FEATURES_TO_STRING_BUFFER_SIZE
#define VISION_DETECTION_FEATURES_FEATURES_ARRAY_SIZE
WHITEBOARD_POSTER_STRING_CONVERSION.