Apriltag WASM Detector
Apriltag detector using the apriltag C library and compiled to WASM using emscripten.
Functions | Variables
str_json.c File Reference

Simple json strings creation. More...

#include <string.h>
#include <malloc.h>
#include <assert.h>
#include <stdio.h>
#include <stdarg.h>
#include "str_json.h"
Include dependency graph for str_json.c:

Functions

int str_json_create (t_str_json *str_json, size_t size_bytes)
 Init a string. More...
 
int str_json_destroy (t_str_json *str_json)
 Free a string. More...
 
void str_json_clear (t_str_json *str_json)
 Clear a string. More...
 
size_t str_json_concat (t_str_json *str_json_dest, const char *source_c_str)
 Copy the content of source_c_str to str_json_dest. More...
 
size_t str_json_printf (t_str_json *str_json_dest, const char *format,...)
 Composes a string with the same text that would be printed if format was used on printf,. More...
 

Variables

const char fmt_error [] = "{ \"result\": \"%s\" }"
 
const char fmt_det_point [] = "{\"id\":%d, \"size\":%.2f, \"corners\": [{\"x\":%.2f,\"y\":%.2f},{\"x\":%.2f,\"y\":%.2f},{\"x\":%.2f,\"y\":%.2f},{\"x\":%.2f,\"y\":%.2f}], \"center\": {\"x\":%.2f,\"y\":%.2f} }"
 
const char fmt_det_point_pose [] = "{\"id\":%d, \"size\":%.2f, \"corners\": [{\"x\":%.2f,\"y\":%.2f},{\"x\":%.2f,\"y\":%.2f},{\"x\":%.2f,\"y\":%.2f},{\"x\":%.2f,\"y\":%.2f}], \"center\": {\"x\":%.2f,\"y\":%.2f}, \"pose\": { \"R\": [[%f,%f,%f],[%f,%f,%f],[%f,%f,%f]], \"t\": [%f,%f,%f], \"e\": %f, %s } }"
 

Detailed Description

Simple json strings creation.

Author
Nuno Pereira; CMU (this file)
Date
Jul, 2020

Function Documentation

◆ str_json_clear()

void str_json_clear ( t_str_json str_json)

Clear a string.

Clear a string.

Parameters
str_jsont_str_json structure of the string to clear

Clear a string.

◆ str_json_concat()

size_t str_json_concat ( t_str_json str_json_dest,
const char *  source_c_str 
)

Copy the content of source_c_str to str_json_dest.

Copy the content of source_c_str to str_json_dest.

Copies up to the terminating null-character, or no more space in dest A terminating null character is always appended to dest.str. IMPORTANT: dest is assumed to be null-terminated

Parameters
str_json_destthe destination t_str_json structure with the destination string info
source_c_stra null-terminated c string (char *) to the source string
Returns
the length, in bytes, of the new string

Copy the content of source_c_str to str_json_dest.

◆ str_json_create()

int str_json_create ( t_str_json str_json,
size_t  size_bytes 
)

Init a string.

Init a string.

Parameters
str_jsont_str_json structure to hold the string info
size_bytessize of the string to allocate
Returns
0=success; -1 on error
Warning
Declare strings with: t_str_json a_str = STR_JSON_INITIALIZER;
Do not call str_json_create() on a string you already created without destroying it

Init a string.

◆ str_json_destroy()

int str_json_destroy ( t_str_json str_json)

Free a string.

Free a string.

Parameters
str_jsont_str_json structure with the string info
Returns
0=success; -1 on error

Free a string.

◆ str_json_printf()

size_t str_json_printf ( t_str_json str_json_dest,
const char *  format,
  ... 
)

Composes a string with the same text that would be printed if format was used on printf,.

Composes a string with the same text that would be printed if format was used on printf,.

Parameters
str_json_destthe destination t_str_json structure with the destination string info
formata format string
...additional arguments
Returns
The number of characters that would have been written if str_json_dest had been sufficiently large, not counting the terminating null character.

Composes a string with the same text that would be printed if format was used on printf,.