17 #ifndef ASTRA_BODY_HPP
18 #define ASTRA_BODY_HPP
22 #include <astra_core/astra_core.hpp>
23 #include <astra/capi/astra_ctypes.h>
24 #include <astra/capi/streams/body_capi.h>
25 #include <astra/capi/streams/stream_types.h>
26 #include <astra/Array.hpp>
27 #include <astra/Vector.hpp>
28 #include <astra/Matrix3x3.hpp>
62 int32_t
width()
const { return ::astra_bitmapmask_t::width; }
64 int32_t
height()
const { return ::astra_bitmapmask_t::height; }
66 int32_t
bpp()
const {
return sizeof(uint8_t); }
70 return ::astra_bitmapmask_t::width *
77 return ::astra_bitmapmask_t::width *
83 const uint8_t*
data()
const { return ::astra_bitmapmask_t::data; }
267 using ::astra_handpose_info_t::leftHand;
268 using ::astra_handpose_info_t::rightHand;
270 HandPose left_hand()
const {
return static_cast<HandPose>(this->leftHand); }
271 HandPose right_hand()
const {
return static_cast<HandPose>(this->rightHand); }
335 bool joints_enabled()
const
340 bool hand_poses_enabled()
const
357 friend class BodyFrame;
389 float a()
const { return ::astra_plane_t::a; }
391 float b()
const { return ::astra_plane_t::b; }
393 float c()
const { return ::astra_plane_t::c; }
395 float d()
const { return ::astra_plane_t::d; }
408 return ::astra_plane_t::a == 0.f &&
420 using ::astra_floor_info_t::floorMask;
421 using ::astra_floor_info_t::floorPlane;
422 using ::astra_floor_info_t::floorDetected;
428 const Plane& floor_plane()
const
432 bool floor_detected()
const {
return this->
floorDetected != ASTRA_FALSE; }
440 std::int32_t width()
const { return ::astra_bodyframe_info_t::width; }
441 std::int32_t height()
const { return ::astra_bodyframe_info_t::height; }
442 bool is_estimated()
const { return ::astra_bodyframe_info_t::isEstimated != 0; }
459 astra_frame_index_t frameIndex_;
469 : handle_(other.handle_),
470 frameIndex_(other.frameIndex_)
476 handle_ = other.handle_;
477 frameIndex_ = other.frameIndex_;
482 template<
typename TFrameType>
483 static TFrameType acquire(astra_reader_frame_t readerFrame,
484 astra_stream_subtype_t subtype)
486 if (readerFrame !=
nullptr)
489 astra_frame_get_bodyframe(readerFrame, &bodyFrame);
490 return TFrameType(bodyFrame);
493 return TFrameType(
nullptr);
501 bool is_valid()
const {
return handle_ !=
nullptr; }
510 throw_if_invalid_frame();
521 throw_if_invalid_frame();
528 throw_if_invalid_frame();
529 return *
static_cast<const BodyMask*
>(&handle_->bodyMask);
534 throw_if_invalid_frame();
535 return *
static_cast<const FloorInfo*
>(&handle_->floorInfo);
546 throw_if_invalid_frame();
547 const auto& bodyList = handle_->bodyList;
549 static_cast<const Body*
>(&bodyList.bodies[0]), bodyList.count);
558 throw_if_invalid_frame();
568 astra_bodyframe_get_frameindex(handle, &frameIndex_);
572 void throw_if_invalid_frame()
const
576 throw std::logic_error(
"Cannot operate on an invalid frame");
607 astra_body_tracking_feature_flags_t features = ASTRA_BODY_TRACKING_SEGMENTATION;
608 astra_bodystream_get_body_features(bodyStream_,
id, &features);
619 astra_bodystream_set_body_features(bodyStream_,
621 static_cast<astra_body_tracking_feature_flags_t
>(features));
631 astra_body_tracking_feature_flags_t features = ASTRA_BODY_TRACKING_SEGMENTATION;
632 astra_bodystream_get_default_body_features(bodyStream_, &features);
643 astra_bodystream_set_default_body_features(bodyStream_,
644 static_cast<astra_body_tracking_feature_flags_t
>(features));
654 astra_skeleton_profile_t skeletonProfileState = ASTRA_SKELETON_PROFILE_FULL;
655 astra_bodystream_get_skeleton_profile(bodyStream_, &skeletonProfileState);
666 astra_bodystream_set_skeleton_profile(bodyStream_,
667 static_cast<astra_skeleton_profile_t
>(skeletonProfile));
677 astra_skeleton_optimization_t skeletonOptimization = ASTRA_SKELETON_OPTIMIZATION_BEST_ACCURACY;
678 astra_bodystream_get_skeleton_optimization(bodyStream_, &skeletonOptimization);
689 astra_bodystream_set_skeleton_optimization(bodyStream_,
690 static_cast<astra_skeleton_optimization_t
>(skeletonOptimization));
700 astra_body_orientation_t bodyOrientation = ASTRA_BODY_ORIENTATION_TOP;
701 astra_bodystream_get_body_orientation(bodyStream_, &bodyOrientation);
712 astra_bodystream_set_body_orientation(bodyStream_,
713 static_cast<astra_body_orientation_t
>(bodyOrientation));
716 static const astra_stream_type_t
id = ASTRA_STREAM_BODY;
Simple wrapper around primitive arrays
Definition: Array.hpp:31
Bitmap representing a 2d mask
Definition: Body.hpp:51
int32_t height() const
Gets the height of the mask
Definition: Body.hpp:64
BitmapMask()
Default constructs an empty zero-sized BitmapMask
Definition: Body.hpp:54
int32_t width() const
Gets the width of the mask
Definition: Body.hpp:62
int32_t byte_length() const
Gets the length of the mask in bytes
Definition: Body.hpp:75
const uint8_t * data() const
Gets an immutable raw pointer to mask data
Definition: Body.hpp:83
int32_t bpp() const
Gets the bytes per pixel
Definition: Body.hpp:66
int32_t length() const
Gets the length of the mask in pixels
Definition: Body.hpp:68
Body tracking information produced by a BodyTracker instance
Definition: Body.hpp:456
void rotate(int angle)
Definition: Body.hpp:556
astra_frame_index_t frame_index() const
get body frame index
Definition: Body.hpp:508
BodyFrame(const BodyFrame &)=delete
BodyFrame is not copy constructible
BodyFrame(BodyFrame &&other)
BodyFrame is move constructible
Definition: Body.hpp:468
const BodyFrameInfo & info() const
get body frame info
Definition: Body.hpp:519
BodyFrame & operator=(BodyFrame &&other)
BodyFrame is move assignable
Definition: Body.hpp:474
BodyList bodies() const
Gets the current tracked bodies associated with the current BodyFrame
Definition: Body.hpp:544
BodyFrame & operator=(const BodyFrame &)=delete
BodyFrame is not copy assignable
const BodyMask & body_mask() const
Gets the BodyMask of the current tracked bodies
Definition: Body.hpp:526
bool is_valid() const
get body frame is vaild
Definition: Body.hpp:501
Human body
Definition: Body.hpp:312
BodyId id() const
Gets BodyId associated with the Body
Definition: Body.hpp:321
const Vector3f & center_of_mass() const
Gets the real world center of mass estimate
Definition: Body.hpp:330
BodyStatus status() const
Gets the tracking status of the body
Definition: Body.hpp:324
JointList joints() const
Gets the current list of joints (Joint) being currently tracked
Definition: Body.hpp:346
A Body Data Stream
Definition: Body.hpp:588
BodyTrackingFeatureFlags get_default_body_features()
get default body features
Definition: Body.hpp:629
void set_body_features(astra_body_id_t id, BodyTrackingFeatureFlags features)
set body features
Definition: Body.hpp:617
void set_body_orientation(BodyOrientation bodyOrientation)
set body orientation
Definition: Body.hpp:710
BodyOrientation get_body_orientation()
get body orientation, default value is BodyOrientation::TOP.
Definition: Body.hpp:698
void set_skeleton_optimization(SkeletonOptimization skeletonOptimization)
set skeleton optimization
Definition: Body.hpp:687
SkeletonProfile get_skeleton_profile()
get skeleton profile
Definition: Body.hpp:652
void set_skeleton_profile(SkeletonProfile skeletonProfile)
set skeleton profile
Definition: Body.hpp:664
BodyTrackingFeatureFlags get_body_features(astra_body_id_t id)
get body features
Definition: Body.hpp:605
BodyStream(astra_streamconnection_t connection)
default constructs
Definition: Body.hpp:595
SkeletonOptimization get_skeleton_optimization()
get skeleton optimization
Definition: Body.hpp:675
void set_default_body_features(BodyTrackingFeatureFlags features)
set default body features
Definition: Body.hpp:641
Data Stream
Definition: DataStream.hpp:33
Body joint
Definition: Body.hpp:211
const Matrix3x3 & orientation() const
Gets the 3x3 Rotation matrix representing the rotation of this joint.
Definition: Body.hpp:244
const Vector3f & world_position() const
Gets the real world position of the Joint
Definition: Body.hpp:238
JointType type() const
Gets the type of joint
Definition: Body.hpp:214
const Vector2f & depth_position() const
Gets the depth ("projective") position of the Joint
Definition: Body.hpp:232
JointStatus status() const
Gets the current status of the Joint
Definition: Body.hpp:220
3D geometric plane
Definition: Body.hpp:376
bool is_degenerate() const
Returns whether than plane is considered degenerate (invalid)
Definition: Body.hpp:406
float a() const
Gets the A coefficient
Definition: Body.hpp:389
float c() const
Gets the C coefficient
Definition: Body.hpp:393
float d() const
Gets the D coefficent (signed distance)
Definition: Body.hpp:395
const Vector3f & normal() const
Gets the plane normal
Definition: Body.hpp:398
Plane()
Default constructs a plane that passes though origin, has a zero-length normal, and is considered deg...
Definition: Body.hpp:380
float b() const
Gets the B coefficient
Definition: Body.hpp:391
ASTRA_API_EX astra_status_t astra_bodyframe_rotate(astra_bodyframe_t bodyFrame, int angle)
Array< T > make_array(T *ptr, std::size_t size)
Simplifies Array construction by leveraging function template type deduction
Definition: Array.hpp:132
HandPose
Hand pose enum. Enumeration of the hand poses that can be detected.
Definition: Body.hpp:257
JointStatus
Joint status enumeration
Definition: Body.hpp:162
astra_body_id_t BodyId
Identifier type for bodies
Definition: Body.hpp:299
BodyOrientation
the orientation of people's heads in depth image.
Definition: Body.hpp:152
SkeletonOptimization
Represents the body tracking configuration that trades-off tracking accuracy, memory,...
Definition: Body.hpp:131
SkeletonProfile
Skeleton profile representing the set of joints to be tracked.
Definition: Body.hpp:118
BodyStatus
Enumeration of possible tracking status of a orbbec::bodytracking::Body
Definition: Body.hpp:280
BodyTrackingFeatureFlags
Bitmask of body features Represents the possible features that body tracking can produce on a body....
Definition: Body.hpp:106
JointType
Joint type enumeration
Definition: Body.hpp:178
Struct representing a 2-dimensional bitmask
Definition: body_types.h:344
int32_t height
height in pixels
Definition: body_types.h:351
int32_t width
width in pixels
Definition: body_types.h:349
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
Struct containing general body frame information
Definition: body_types.h:401
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
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
Represents a 3x3 rotation matrix
Definition: Matrix3x3.hpp:31
Represents a float 2d vector
Definition: Vector2f.hpp:30
Represents a float 3d vector
Definition: Vector3f.hpp:30