60#ifndef guWhiteboard_VisionLines_h
61#define guWhiteboard_VisionLines_h
63#ifdef WHITEBOARD_POSTER_STRING_CONVERSION
72#undef guWhiteboard_VisionLines_DEFINED
73#define guWhiteboard_VisionLines_DEFINED
75#undef VisionLines_DEFINED
76#define VisionLines_DEFINED
92 void init(
const struct wb_vision_line t_lines[7] = NULLPTR, uint8_t t_numLines = 0, uint64_t t_frameNumber = 0, uint16_t t_res_width = 0, uint16_t t_res_height = 0) {
93 if (t_lines != NULLPTR) {
110 VisionLines(
const struct wb_vision_line t_lines[7] = NULLPTR, uint8_t t_numLines = 0, uint64_t t_frameNumber = 0, uint16_t t_res_width = 0, uint16_t t_res_height = 0) {
111 this->init(t_lines, t_numLines, t_frameNumber, t_res_width, t_res_height);
153 for (
int lines_0_index = 0; lines_0_index < 7; lines_0_index++)
162 return !(*
this == t_other);
172 return !(*
this == t_other);
265#ifdef WHITEBOARD_POSTER_STRING_CONVERSION
275#ifdef USE_WB_VISION_LINES_C_CONVERSION
278 std::string descr = buffer;
281 std::ostringstream ss;
282 bool lines_first =
true;
290 ss <<
"numLines=" <<
static_cast<unsigned>(this->
numLines());
294 ss <<
"res_width=" <<
static_cast<unsigned>(this->
res_width());
296 ss <<
"res_height=" <<
static_cast<unsigned>(this->
res_height());
302#ifdef USE_WB_VISION_LINES_C_CONVERSION
305 std::string toString = buffer;
308 std::ostringstream ss;
309 bool lines_first =
true;
317 ss << static_cast<unsigned>(this->
numLines());
321 ss << static_cast<unsigned>(this->
res_width());
323 ss << static_cast<unsigned>(this->
res_height());
328#ifdef USE_WB_VISION_LINES_C_CONVERSION
333 char * str_cstr =
const_cast<char *
>(t_str.c_str());
334 size_t temp_length = strlen(str_cstr);
335 int length = (temp_length <= INT_MAX) ? static_cast<int>(
static_cast<ssize_t
>(temp_length)) : -1;
340 char* var_str = &var_str_buffer[0];
342 char* key = &key_buffer[0];
350 if (index == 0 && str_cstr[0] ==
'{') {
356 for (
int i = index; i < length; i++) {
358 if (bracecount == 0 && str_cstr[i] ==
'=') {
363 if (bracecount == 0 && isspace(str_cstr[i])) {
370 if (bracecount == 0 && str_cstr[i] ==
',') {
374 if (str_cstr[i] ==
'{') {
376 if (bracecount == 1) {
381 if (str_cstr[i] ==
'}') {
383 if (bracecount < 0) {
388 if (i == length - 1) {
392 if (endKey >= startKey && endKey - startKey < length) {
393 strncpy(key, str_cstr + startKey,
static_cast<size_t>((endKey - startKey) + 1));
394 key[(endKey - startKey) + 1] = 0;
398 strncpy(var_str, str_cstr + startVar,
static_cast<size_t>((index - startVar) + 1));
399 var_str[(index - startVar) + 1] = 0;
405 if (strlen(key) > 0) {
406 if (0 == strcmp(
"lines", key)) {
408 }
else if (0 == strcmp(
"numLines", key)) {
410 }
else if (0 == strcmp(
"frameNumber", key)) {
412 }
else if (0 == strcmp(
"res_width", key)) {
414 }
else if (0 == strcmp(
"res_height", key)) {
424 int restartIndex = index;
425 index = lastBrace + 1;
431 for (
int i = index; i < length; i++) {
433 if (bracecount == 0 && str_cstr[i] ==
'=') {
438 if (bracecount == 0 && isspace(str_cstr[i])) {
445 if (bracecount == 0 && str_cstr[i] ==
',') {
449 if (str_cstr[i] ==
'{') {
453 if (str_cstr[i] ==
'}') {
455 if (bracecount < 0) {
460 if (i == length - 1) {
464 if (endKey >= startKey && endKey - startKey < length) {
465 strncpy(key, str_cstr + startKey,
static_cast<size_t>((endKey - startKey) + 1));
466 key[(endKey - startKey) + 1] = 0;
470 strncpy(var_str, str_cstr + startVar,
static_cast<size_t>((index - startVar) + 1));
471 var_str[(index - startVar) + 1] = 0;
482 index = restartIndex;
487 this->
set_numLines(
static_cast<uint8_t
>(atoi(var_str)));
513 }
while(index < length);
Provides a C++ wrapper around wb_vision_line.
void from_string(const std::string &t_str)
Provides a C++ wrapper around wb_vision_lines.
void set_lines(const VisionLine *t_newValue)
const uint16_t & res_height() const
const uint16_t & res_width() const
void set_frameNumber(const uint64_t &t_newValue)
const VisionLine & lines(int t_i) const
const uint64_t & frameNumber() const
VisionLines(const struct wb_vision_lines &t_other)
Copy Constructor.
void set_res_height(const uint16_t &t_newValue)
bool operator!=(const VisionLines &t_other) const
VisionLine & lines(int t_i)
void set_numLines(const uint8_t &t_newValue)
const VisionLine * lines() const
void set_lines(const VisionLine &t_newValue, int t_i)
VisionLines(const VisionLines &t_other)
Copy Constructor.
VisionLines(const struct wb_vision_line t_lines[7]=NULLPTR, uint8_t t_numLines=0, uint64_t t_frameNumber=0, uint16_t t_res_width=0, uint16_t t_res_height=0)
Create a new VisionLines.
VisionLines & operator=(const VisionLines &t_other)
Copy Assignment Operator.
VisionLines(const std::string &t_str)
String Constructor.
size_t lines_size() const
bool operator==(const VisionLines &t_other) const
void from_string(const std::string &t_str)
std::string description()
void set_res_width(const uint16_t &t_newValue)
const uint8_t & numLines() const
WHITEBOARD_POSTER_STRING_CONVERSION.
Class use to represent lines detected by vision for a single camera and posted to the whiteboard.
uint8_t numLines
The number of lines reported on the camera.
uint16_t res_width
The resolution width.
uint64_t frameNumber
The frame number that these lines were seen in.
struct wb_vision_line lines[7]
Lines reported from the camera.
uint16_t res_height
The resolution height.
const char * wb_vision_lines_description(const struct wb_vision_lines *self, char *descString, size_t bufferSize)
Convert to a description string.
struct wb_vision_lines * wb_vision_lines_from_string(struct wb_vision_lines *self, const char *str)
Convert from a string.
const char * wb_vision_lines_to_string(const struct wb_vision_lines *self, char *toString, size_t bufferSize)
Convert to a string.
#define VISION_LINES_TO_STRING_BUFFER_SIZE
#define VISION_LINES_DESC_BUFFER_SIZE
#define VISION_LINES_LINES_ARRAY_SIZE
WHITEBOARD_POSTER_STRING_CONVERSION.