#include <astra/capi/astra.h>
#include <stdio.h>
#include <stdint.h>
#include <stdbool.h>
#include <key_handler.h>
{
astra_status_t rc = astra_bodyframe_floor_info(bodyFrame, &floorInfo);
if (rc != ASTRA_STATUS_SUCCESS)
{
printf("Error %d in astra_bodyframe_floor_info()\n", rc);
return;
}
if (floorDetected != ASTRA_FALSE)
{
printf("Floor plane: [%f, %f, %f, %f]\n",
const int32_t bottomCenterIndex = floorMask->
width / 2 + floorMask->
width * (floorMask->
height - 1);
printf("Floor mask: width: %d height: %d bottom center value: %d\n",
floorMask->
data[bottomCenterIndex]);
}
}
{
const astra_status_t rc = astra_bodyframe_bodymask(bodyFrame, &bodyMask);
if (rc != ASTRA_STATUS_SUCCESS)
{
printf("Error %d in astra_bodyframe_bodymask()\n", rc);
return;
}
const int32_t centerIndex = bodyMask.
width / 2 + bodyMask.
width * bodyMask.
height / 2;
printf("Body mask: width: %d height: %d center value: %d\n",
bodyMask.
data[centerIndex]);
}
{
const astra_status_t rc = astra_bodyframe_info(bodyFrame, &info);
if (rc != ASTRA_STATUS_SUCCESS)
{
printf("Error %d in astra_bodyframe_info()\n", rc);
return;
}
const int32_t width = info.
width;
const int32_t height = info.
height;
printf("BodyFrame info: Width: %d Height: %d\n",
width,
height);
}
void output_joint(
const int32_t bodyId,
const astra_joint_t* joint)
{
const astra_joint_type_t jointType = joint->
type;
const astra_joint_status_t jointStatus = joint->
status;
printf("Body %u Joint %d status %d @ world (%.1f, %.1f, %.1f) depth (%.1f, %.1f)\n",
bodyId,
jointType,
jointStatus,
printf("Head orientation x: [%f %f %f]\n", xAxis->x, xAxis->y, xAxis->z);
printf("Head orientation y: [%f %f %f]\n", yAxis->x, yAxis->y, yAxis->z);
printf("Head orientation z: [%f %f %f]\n", zAxis->x, zAxis->y, zAxis->z);
}
{
const astra_handpose_t leftHandPose = handPoses->
leftHand;
const astra_handpose_t rightHandPose = handPoses->
rightHand;
printf("Body %d Left hand pose: %d Right hand pose: %d\n",
leftHandPose,
rightHandPose);
}
{
int i;
const astra_status_t rc = astra_bodyframe_body_list(bodyFrame, &bodyList);
if (rc != ASTRA_STATUS_SUCCESS)
{
printf("Error %d in astra_bodyframe_body_list()\n", rc);
return;
}
for(i = 0; i < bodyList.
count; ++i)
{
astra_body_id_t bodyId = body->
id;
astra_body_status_t bodyStatus = body->
status;
if (bodyStatus == ASTRA_BODY_STATUS_TRACKING_STARTED)
{
printf("Body Id: %d Status: Tracking started\n", bodyId);
}
if (bodyStatus == ASTRA_BODY_STATUS_TRACKING)
{
printf("Body Id: %d Status: Tracking\n", bodyId);
}
if (bodyStatus == ASTRA_BODY_STATUS_TRACKING_STARTED ||
bodyStatus == ASTRA_BODY_STATUS_TRACKING)
{
const astra_body_tracking_feature_flags_t features = body->
features;
const bool jointTrackingEnabled = (features & ASTRA_BODY_TRACKING_JOINTS) == ASTRA_BODY_TRACKING_JOINTS;
const bool handPoseRecognitionEnabled = (features & ASTRA_BODY_TRACKING_HAND_POSES) == ASTRA_BODY_TRACKING_HAND_POSES;
printf("Body %d CenterOfMass (%f, %f, %f) Joint Tracking Enabled: %s Hand Pose Recognition Enabled: %s\n",
bodyId,
centerOfMass->x, centerOfMass->y, centerOfMass->z,
jointTrackingEnabled ? "True" : "False",
handPoseRecognitionEnabled ? "True" : "False");
output_joint(bodyId, joint);
output_hand_poses(body);
}
else if (bodyStatus == ASTRA_BODY_STATUS_LOST)
{
printf("Body %u Status: Tracking lost.\n", bodyId);
}
else
{
printf("Body Id: %d Status: Not Tracking\n", bodyId);
}
}
}
{
output_floor(bodyFrame);
output_body_mask(bodyFrame);
output_bodyframe_info(bodyFrame);
output_bodies(bodyFrame);
}
int main(int argc, char* argv[])
{
set_key_handler();
astra_initialize();
const char* licenseString = "<INSERT LICENSE KEY HERE>";
astra_streamsetconnection_t sensor;
astra_streamset_open("device/default", &sensor);
astra_reader_t reader;
astra_reader_create(sensor, &reader);
astra_reader_get_bodystream(reader, &bodyStream);
astra_stream_start(bodyStream);
do
{
astra_update();
astra_reader_frame_t frame;
astra_status_t rc = astra_reader_open_frame(reader, 0, &frame);
if (rc == ASTRA_STATUS_SUCCESS)
{
astra_frame_get_bodyframe(frame, &bodyFrame);
astra_frame_index_t frameIndex;
astra_bodyframe_get_frameindex(bodyFrame, &frameIndex);
printf("Frame index: %d\n", frameIndex);
output_bodyframe(bodyFrame);
printf("----------------------------\n");
astra_reader_close_frame(&frame);
}
} while (shouldContinue);
astra_reader_destroy(&reader);
astra_streamset_close(&sensor);
astra_terminate();
}
ASTRA_API_EX astra_status_t orbbec_body_tracking_set_license(const char *licenseString)
Struct representing a 2-dimensional bitmask
Definition: body_types.h:344
uint8_t data[ASTRA_TEMP_IMAGE_LENGTH]
mask pixels
Definition: body_types.h:347
int32_t height
height in pixels
Definition: body_types.h:351
int32_t width
width in pixels
Definition: body_types.h:349
Struct containing a variable-sized array of astra_body_t structs
Definition: body_types.h:329
int32_t count
Number of astra_body_t in bodies
Definition: body_types.h:334
astra_body_t bodies[ASTRA_MAX_BODIES]
Pointer to an array of astra_body_t
Definition: body_types.h:332
Struct containing body tracking information
Definition: body_types.h:293
astra_body_status_t status
Tracking status
Definition: body_types.h:321
astra_body_tracking_feature_flags_t features
Bitmask of features that are enabled.
Definition: body_types.h:298
astra_joint_t joints[ASTRA_MAX_JOINTS]
Array of tracked joints
Definition: body_types.h:306
astra_vector3f_t centerOfMass
Single point describing the center of mass of a body.
Definition: body_types.h:304
astra_handpose_info_t handPoses
Hand poses
Definition: body_types.h:308
astra_body_id_t id
Persistent Id
Definition: body_types.h:315
Struct containing general body frame information
Definition: body_types.h:401
int32_t width
Frame width
Definition: body_types.h:403
int32_t height
Frame height
Definition: body_types.h:405
Definition: stream_types.h:62
Struct containing floor information about the scene
Definition: body_types.h:414
astra_floormask_t floorMask
Floor mask
Definition: body_types.h:416
astra_bool_t floorDetected
If the floor is detected, ASTRA_TRUE. Otherwise, ASTRA_FALSE.
Definition: body_types.h:424
astra_plane_t floorPlane
Floor plane
Definition: body_types.h:418
Definition: body_types.h:187
Joint information
Definition: body_types.h:123
astra_vector2f_t depthPosition
Depth ("projective") position of joint
Definition: body_types.h:135
astra_joint_status_t status
Joint status
Definition: body_types.h:133
astra_matrix3x3_t orientation
3x3 Rotation matrix representing the rotation of this joint.
Definition: body_types.h:140
astra_vector3f_t worldPosition
Real world position of joint
Definition: body_types.h:137
astra_joint_type_t type
Joint type
Definition: body_types.h:128
Represents a 3x3 rotation matrix
Definition: astra_ctypes.h:50
Struct representing a geometric 3-dimensional plane
Definition: body_types.h:386
float d
D coefficient
Definition: body_types.h:394
float c
C coefficient
Definition: body_types.h:392
float a
A coefficient
Definition: body_types.h:388
float b
B coefficient
Definition: body_types.h:390
Definition: astra_plugin.h:24
Definition: astra_ctypes.h:27
Definition: astra_ctypes.h:32