60#ifndef WHITEBOARD_POSTER_STRING_CONVERSION
61#define WHITEBOARD_POSTER_STRING_CONVERSION
72#pragma clang diagnostic push
73#pragma clang diagnostic ignored "-Wunused-macros"
77#elif defined(__APPLE__)
78# include <machine/endian.h>
79# include <architecture/byte_order.h>
80# define bswap_16(x) NXSwapShort(x)
81# define bswap_32(x) NXSwapInt(x)
82# define bswap_64(x) NXSwapLongLong(x)
84# define bswap_16(x) __builtin_bswap16(x)
85# define bswap_32(x) __builtin_bswap32(x)
86# define bswap_64(x) __builtin_bswap64(x)
91#if (!defined(__BYTE_ORDER) && !defined(__LITTLE_ENDIAN)) || (defined(__BYTE_ORDER) && defined(__LITTLE_ENDIAN) && __BYTE_ORDER == __LITTLE_ENDIAN)
92# if !defined(htonll) && !defined(ntohll)
93# define htonll(x) bswap_64(x)
94# define ntohll(x) bswap_64(x)
96# if !defined(htonl) && !defined(ntohl)
97# define htonl(x) bswap_32(x)
98# define ntohl(x) bswap_32(x)
100# if !defined(htons) && !defined(ntohs)
101# define htons(x) bswap_16(x)
102# define ntohs(x) bswap_16(x)
105# if !defined(htonll) && !defined(ntohll)
106# define htonll(x) (x)
107# define ntohll(x) (x)
109# if !defined(htonl) && !defined(ntohl)
113# if !defined(htons) && !defined(ntohs)
118#pragma clang diagnostic pop
127#pragma clang diagnostic push
128#pragma clang diagnostic ignored "-Wunused-variable"
130 if (len >= bufferSize) {
134 len += snprintf(descString + len, bufferSize - len,
"frameNumber=%llu", self->frameNumber);
136 len += snprintf(descString + len, bufferSize - len,
"frameNumber=%lu", self->frameNumber);
138 if (len >= bufferSize) {
141 len = gu_strlcat(descString,
", ", bufferSize);
142 if (len >= bufferSize) {
145 len = gu_strlcat(descString,
"features={", bufferSize);
147 if (len >= bufferSize) {
150 if (features_index > 0) {
151 len = gu_strlcat(descString,
", ", bufferSize);
153 len = gu_strlcat(descString,
"{", bufferSize);
154 if (len >= bufferSize) {
158 char* features_1_p = features_1_buffer;
160 len = gu_strlcat(descString, features_1_p, bufferSize);
161 if (len >= bufferSize) {
164 len = gu_strlcat(descString,
"}", bufferSize);
166 if (len >= bufferSize) {
169 len = gu_strlcat(descString,
"}", bufferSize);
171#pragma clang diagnostic pop
179#pragma clang diagnostic push
180#pragma clang diagnostic ignored "-Wunused-variable"
182 if (len >= bufferSize) {
186 len += snprintf(toString + len, bufferSize - len,
"%llu", self->frameNumber);
188 len += snprintf(toString + len, bufferSize - len,
"%lu", self->frameNumber);
190 if (len >= bufferSize) {
193 len = gu_strlcat(toString,
", ", bufferSize);
194 if (len >= bufferSize) {
197 len = gu_strlcat(toString,
"{", bufferSize);
199 if (len >= bufferSize) {
202 if (features_index > 0) {
203 len = gu_strlcat(toString,
", ", bufferSize);
205 len = gu_strlcat(toString,
"{", bufferSize);
206 if (len >= bufferSize) {
210 char* features_1_p = features_1_buffer;
212 len = gu_strlcat(toString, features_1_p, bufferSize);
213 if (len >= bufferSize) {
216 len = gu_strlcat(toString,
"}", bufferSize);
218 if (len >= bufferSize) {
221 len = gu_strlcat(toString,
"}", bufferSize);
223#pragma clang diagnostic pop
231 size_t temp_length = strlen(str);
232 int length = (temp_length <= INT_MAX) ? ((
int)((ssize_t)temp_length)) : -1;
237 char* var_str = &var_str_buffer[0];
239 char* key = &key_buffer[0];
247 if (index == 0 && str[0] ==
'{') {
253 for (
int i = index; i < length; i++) {
255 if (bracecount == 0 && str[i] ==
'=') {
260 if (bracecount == 0 && isspace(str[i])) {
267 if (bracecount == 0 && str[i] ==
',') {
273 if (bracecount == 1) {
280 if (bracecount < 0) {
285 if (i == length - 1) {
289 if (endKey >= startKey && endKey - startKey < length) {
290 strncpy(key, str + startKey, ((
size_t)(endKey - startKey) + 1));
291 key[(endKey - startKey) + 1] = 0;
295 strncpy(var_str, str + startVar, ((
size_t)(index - startVar) + 1));
296 var_str[(index - startVar) + 1] = 0;
302 if (strlen(key) > 0) {
303 if (0 == strcmp(
"frameNumber", key)) {
305 }
else if (0 == strcmp(
"features", key)) {
316 self->frameNumber = ((uint64_t)atoll(var_str));
318 self->frameNumber = ((uint64_t)atol(var_str));
324 int restartIndex = index;
325 index = lastBrace + 1;
331 for (
int i = index; i < length; i++) {
333 if (bracecount == 0 && str[i] ==
'=') {
338 if (bracecount == 0 && isspace(str[i])) {
345 if (bracecount == 0 && str[i] ==
',') {
355 if (bracecount < 0) {
360 if (i == length - 1) {
364 if (endKey >= startKey && endKey - startKey < length) {
365 strncpy(key, str + startKey, ((
size_t)(endKey - startKey) + 1));
366 key[(endKey - startKey) + 1] = 0;
370 strncpy(var_str, str + startVar, ((
size_t)(index - startVar) + 1));
371 var_str[(index - startVar) + 1] = 0;
379 self->features[features_0_index] = features_0;
381 index = restartIndex;
388 }
while(index < length);
399 uint16_t bit_offset = 0;
400 uint64_t frameNumber_nbo =
htonll(self->frameNumber);
403 for (b = (64 - 1); b >= 0; b--) {
405 uint16_t
byte = bit_offset / 8;
406 uint16_t bit = 7 - (bit_offset % 8);
407 unsigned long newbit = !!((frameNumber_nbo >> b) & 1U);
408 dst[byte] ^= (-newbit ^ dst[byte]) & (1UL << bit);
409 bit_offset = bit_offset + 1;
419 const char *buf = (
const char *)&self->features[0];
422 for (c = 0; c < bytes; c++) {
423 for (b = 7; b >= 0; b--) {
425 uint16_t
byte = bit_offset / 8;
426 uint16_t bit = 7 - (bit_offset % 8);
427 unsigned long newbit = !!((buf[c] >> b) & 1U);
428 dst[byte] ^= (-newbit ^ dst[byte]) & (1UL << bit);
429 bit_offset = bit_offset + 1;
445 uint16_t bit_offset = 0;
448 for (b = (64 - 1); b >= 0; b--) {
450 uint16_t
byte = bit_offset / 8;
451 uint16_t bit = 7 - (bit_offset % 8);
452 char dataByte = src[byte];
453 unsigned char bitValue = (dataByte >> bit) & 1U;
455 bit_offset = bit_offset + 1;
466 char *buf = (
char *)malloc(bytes);
469 for (c = 0; c < bytes; c++) {
470 for (b = 7; b >= 0; b--) {
472 uint16_t
byte = bit_offset / 8;
473 uint16_t bit = 7 - (bit_offset % 8);
474 char dataByte = src[byte];
475 unsigned char bitValue = (dataByte >> bit) & 1U;
476 buf[c] ^= (-bitValue ^ buf[c]) & (1UL << b);
477 bit_offset = bit_offset + 1;
481 memcpy(&dst->
features[0], &buf[0], bytes);
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.
const char * wb_vision_detection_feature_array_description(const struct wb_vision_detection_feature_array *self, char *descString, size_t bufferSize)
Convert to a description string.
const char * wb_vision_detection_feature_array_to_string(const struct wb_vision_detection_feature_array *self, char *toString, size_t bufferSize)
Convert to a string.
struct wb_vision_detection_feature_array * wb_vision_detection_feature_array_from_string(struct wb_vision_detection_feature_array *self, const char *str)
Convert from a string.
#define VISION_DETECTION_FEATURE_ARRAY_TO_STRING_BUFFER_SIZE
#define VISION_DETECTION_FEATURE_ARRAY_DESC_BUFFER_SIZE
struct wb_vision_detection_features * wb_vision_detection_features_from_string(struct wb_vision_detection_features *self, const char *str)
Convert from a string.
size_t wb_vision_detection_features_from_network_serialised(const char *src, struct wb_vision_detection_features *dst)
Convert from a compressed, serialised, network byte order byte stream.
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.
size_t wb_vision_detection_features_to_network_serialised(const struct wb_vision_detection_features *self, char *dst)
Convert to a compressed, serialised, network byte order byte stream.
#define VISION_DETECTION_FEATURES_DESC_BUFFER_SIZE
#define VISION_DETECTION_FEATURES_FEATURES_ARRAY_SIZE
WHITEBOARD_POSTER_STRING_CONVERSION.