Skip to content

C API: Body tracking module (sona_body.h)

An optional library, sona_body, beside the core: webcam full-body pose to the avatar. Include sona_body.h and link sona_body. The guide: Body tracking (sona_body).

sona_body_defaults

void sona_body_defaults(sona_body_options *o);
Parameter and type Meaning
o
sona_body_options *
The sona_body_options to fill with the defaults (required)

Returns Nothing.

Example:

sona_body_options x_body_options;
memset(&x_body_options, 0, sizeof x_body_options);
x_body_options.size = sizeof x_body_options;
sona_body_defaults(&x_body_options);

size set; min_cutoff 1.5, beta 0.8, min_visibility 0.5, lost_seconds 0.5, return_seconds 0.4.

sona_body_create

sona_result sona_body_create(const sona_body_options *o,
                             sona_body_tracker **out);
Parameter and type Meaning
o
const sona_body_options *
The options, a sona_body_options (NULL: the defaults)
out
sona_body_tracker **
Receives the new body tracker (required)

Returns SONA_OK. Errors SONA_E_ARGUMENT, SONA_E_MEMORY (what each means).

NULL options: the defaults. SONA_E_ARGUMENT for a wrong size or a value out of range.

sona_body_destroy

void sona_body_destroy(sona_body_tracker *t);
Parameter and type Meaning
t
sona_body_tracker *
The body tracker (required)

Returns Nothing.

Frees the tracker.

sona_body_reset

void sona_body_reset(sona_body_tracker *t);
Parameter and type Meaning
t
sona_body_tracker *
The body tracker (required)

Returns Nothing.

Forgets the filters and the tracking state; keeps the options.

sona_body_input_defaults

void sona_body_input_defaults(sona_body_input *in);
Parameter and type Meaning
in
sona_body_input *
The sona_body_input to fill with the defaults (required)

Returns Nothing.

Example:

sona_body_input x_body_input;
sona_body_input_defaults(&x_body_input);
sona_body_input_defaults(&x_body_input);

size set, the MediaPipe layout and no points.

sona_body_feed

sona_result sona_body_feed(sona_body_tracker *t, const sona_body_input *in);
Parameter and type Meaning
t
sona_body_tracker *
The body tracker (required)
in
const sona_body_input *
A sona_body_input (required)

Returns SONA_OK. Errors SONA_E_ARGUMENT (what each means).

One frame of what the body tracker saw (sona_body_input). SONA_E_ARGUMENT for a wrong size, a time that is not finite, or a found body without 33 points in the MediaPipe layout.

sona_body_apply

sona_result sona_body_apply(sona_body_tracker *t, sona_avatar *a);
Parameter and type Meaning
t
sona_body_tracker *
The body tracker (required)
a
sona_avatar *
The avatar (required)

Returns SONA_OK. Errors SONA_E_ARGUMENT, SONA_E_DESTROYED, SONA_E_NOT_READY (what each means).

Puts the pose on an avatar through overrides below the neck, after the clip and before the IK. One tracker drives one avatar at a time. SONA_E_NOT_READY until the avatar is READY and posed.

sona_body_release

void sona_body_release(sona_body_tracker *t, sona_avatar *a);
Parameter and type Meaning
t
sona_body_tracker *
The body tracker (required)
a
sona_avatar *
The avatar (required)

Returns Nothing.

Hands the joints back to the clip; nothing when a is not the avatar it drives.

sona_body_struct_size

uint32_t sona_body_struct_size(const char *name);
Parameter and type Meaning
name
const char *
A public struct's name (required)

Returns uint32_t.

Example:

uint32_t x_got = sona_body_struct_size("sona_config");
printf("sona_body_struct_size: %lld\n", (long long)x_got);

sizeof a public struct of this header by name ("sona_body_options"), for the bindings' layout checks; 0 when unknown.

sona_body_struct_offset

uint32_t sona_body_struct_offset(const char *struct_dot_field);
Parameter and type Meaning
struct_dot_field
const char *
"struct.field" (required)

Returns uint32_t.

Example:

uint32_t x_got = sona_body_struct_offset("example");
printf("sona_body_struct_offset: %lld\n", (long long)x_got);

offsetof a field by "struct.field" ("sona_body_input.points"); UINT32_MAX when unknown.

This page as Markdown · All the docs as one file (llms-full.txt)