60#ifndef guWhiteboard_VisionDetectionHorizons_h
61#define guWhiteboard_VisionDetectionHorizons_h
63#ifdef WHITEBOARD_POSTER_STRING_CONVERSION
72#undef guWhiteboard_VisionDetectionHorizons_DEFINED
73#define guWhiteboard_VisionDetectionHorizons_DEFINED
75#undef VisionDetectionHorizons_DEFINED
76#define VisionDetectionHorizons_DEFINED
92 void init(uint64_t t_frameNumber = 0,
const struct wb_vision_detection_horizon t_horizons[2] = NULLPTR, uint16_t t_res_width = 0, uint16_t t_res_height = 0) {
94 if (t_horizons != NULLPTR) {
110 this->init(t_frameNumber, t_horizons, t_res_width, t_res_height);
151 for (
int horizons_0_index = 0; horizons_0_index < 2; horizons_0_index++)
160 return !(*
this == t_other);
170 return !(*
this == t_other);
248#ifdef WHITEBOARD_POSTER_STRING_CONVERSION
258#ifdef USE_WB_VISION_DETECTION_HORIZONS_C_CONVERSION
261 std::string descr = buffer;
264 std::ostringstream ss;
267 bool horizons_first =
true;
271 horizons_first =
false;
275 ss <<
"res_width=" <<
static_cast<unsigned>(this->
res_width());
277 ss <<
"res_height=" <<
static_cast<unsigned>(this->
res_height());
283#ifdef USE_WB_VISION_DETECTION_HORIZONS_C_CONVERSION
286 std::string toString = buffer;
289 std::ostringstream ss;
292 bool horizons_first =
true;
296 horizons_first =
false;
300 ss << static_cast<unsigned>(this->
res_width());
302 ss << static_cast<unsigned>(this->
res_height());
307#ifdef USE_WB_VISION_DETECTION_HORIZONS_C_CONVERSION
312 char * str_cstr =
const_cast<char *
>(t_str.c_str());
313 size_t temp_length = strlen(str_cstr);
314 int length = (temp_length <= INT_MAX) ? static_cast<int>(
static_cast<ssize_t
>(temp_length)) : -1;
319 char* var_str = &var_str_buffer[0];
321 char* key = &key_buffer[0];
329 if (index == 0 && str_cstr[0] ==
'{') {
335 for (
int i = index; i < length; i++) {
337 if (bracecount == 0 && str_cstr[i] ==
'=') {
342 if (bracecount == 0 && isspace(str_cstr[i])) {
349 if (bracecount == 0 && str_cstr[i] ==
',') {
353 if (str_cstr[i] ==
'{') {
355 if (bracecount == 1) {
360 if (str_cstr[i] ==
'}') {
362 if (bracecount < 0) {
367 if (i == length - 1) {
371 if (endKey >= startKey && endKey - startKey < length) {
372 strncpy(key, str_cstr + startKey,
static_cast<size_t>((endKey - startKey) + 1));
373 key[(endKey - startKey) + 1] = 0;
377 strncpy(var_str, str_cstr + startVar,
static_cast<size_t>((index - startVar) + 1));
378 var_str[(index - startVar) + 1] = 0;
384 if (strlen(key) > 0) {
385 if (0 == strcmp(
"frameNumber", key)) {
387 }
else if (0 == strcmp(
"horizons", key)) {
389 }
else if (0 == strcmp(
"res_width", key)) {
391 }
else if (0 == strcmp(
"res_height", key)) {
410 int restartIndex = index;
411 index = lastBrace + 1;
417 for (
int i = index; i < length; i++) {
419 if (bracecount == 0 && str_cstr[i] ==
'=') {
424 if (bracecount == 0 && isspace(str_cstr[i])) {
431 if (bracecount == 0 && str_cstr[i] ==
',') {
435 if (str_cstr[i] ==
'{') {
439 if (str_cstr[i] ==
'}') {
441 if (bracecount < 0) {
446 if (i == length - 1) {
450 if (endKey >= startKey && endKey - startKey < length) {
451 strncpy(key, str_cstr + startKey,
static_cast<size_t>((endKey - startKey) + 1));
452 key[(endKey - startKey) + 1] = 0;
456 strncpy(var_str, str_cstr + startVar,
static_cast<size_t>((index - startVar) + 1));
457 var_str[(index - startVar) + 1] = 0;
468 index = restartIndex;
485 }
while(index < length);
Provides a C++ wrapper around wb_vision_detection_horizon.
void from_string(const std::string &t_str)
Provides a C++ wrapper around wb_vision_detection_horizons.
void set_horizons(const VisionDetectionHorizon &t_newValue, int t_i)
VisionDetectionHorizons(const VisionDetectionHorizons &t_other)
Copy Constructor.
bool operator!=(const VisionDetectionHorizons &t_other) const
const VisionDetectionHorizon & horizons(int t_i) const
bool operator==(const VisionDetectionHorizons &t_other) const
const uint16_t & res_height() const
void set_frameNumber(const uint64_t &t_newValue)
void from_string(const std::string &t_str)
VisionDetectionHorizon & horizons(int t_i)
VisionDetectionHorizons(uint64_t t_frameNumber=0, const struct wb_vision_detection_horizon t_horizons[2]=NULLPTR, uint16_t t_res_width=0, uint16_t t_res_height=0)
Create a new VisionDetectionHorizons.
VisionDetectionHorizons & operator=(const VisionDetectionHorizons &t_other)
Copy Assignment Operator.
const uint16_t & res_width() const
void set_res_height(const uint16_t &t_newValue)
std::string description()
VisionDetectionHorizons(const struct wb_vision_detection_horizons &t_other)
Copy Constructor.
const uint64_t & frameNumber() const
size_t horizons_size() const
VisionDetectionHorizons(const std::string &t_str)
String Constructor.
const VisionDetectionHorizon * horizons() const
void set_horizons(const VisionDetectionHorizon *t_newValue)
void set_res_width(const uint16_t &t_newValue)
WHITEBOARD_POSTER_STRING_CONVERSION.
Array of fieldHorizons, one instance reported by each camera.
uint16_t res_width
The resolution width.
uint64_t frameNumber
visionFrameNumber
uint16_t res_height
The resolution height.
struct wb_vision_detection_horizon horizons[2]
horizon objects
const char * wb_vision_detection_horizons_description(const struct wb_vision_detection_horizons *self, char *descString, size_t bufferSize)
Convert to a description string.
const char * wb_vision_detection_horizons_to_string(const struct wb_vision_detection_horizons *self, char *toString, size_t bufferSize)
Convert to a string.
struct wb_vision_detection_horizons * wb_vision_detection_horizons_from_string(struct wb_vision_detection_horizons *self, const char *str)
Convert from a string.
#define VISION_DETECTION_HORIZONS_HORIZONS_ARRAY_SIZE
WHITEBOARD_POSTER_STRING_CONVERSION.
#define VISION_DETECTION_HORIZONS_DESC_BUFFER_SIZE
#define VISION_DETECTION_HORIZONS_TO_STRING_BUFFER_SIZE