17 #ifndef ASTRA_HAND_HPP
18 #define ASTRA_HAND_HPP
22 #include <astra_core/astra_core.hpp>
23 #include <astra/capi/astra_ctypes.h>
24 #include <astra/capi/streams/hand_capi.h>
25 #include <astra/Vector.hpp>
58 astra_handpoint_t::trackingId = trackingId;
59 astra_handpoint_t::status =
status;
60 astra_handpoint_t::depthPosition = depthPosition;
61 astra_handpoint_t::worldPosition = worldPosition;
62 astra_handpoint_t::worldDeltaPosition = worldDeltaPosition;
82 astra_handpoint_t::trackingId = handPoint.trackingId;
83 astra_handpoint_t::status = handPoint.status;
84 astra_handpoint_t::depthPosition = handPoint.depthPosition;
85 astra_handpoint_t::worldPosition = handPoint.worldPosition;
86 astra_handpoint_t::worldDeltaPosition = handPoint.worldDeltaPosition;
96 inline operator ::astra_handpoint_t*() {
return this; }
103 inline operator const ::astra_handpoint_t*()
const {
return this; }
110 inline std::int32_t
tracking_id()
const {
return astra_handpoint_t::trackingId; }
117 inline astra_handstatus_t
status()
const {
return astra_handpoint_t::status; }
162 handStream_(connection)
165 static const astra_stream_type_t
id = ASTRA_STREAM_HAND;
174 bool includeCandidatePoints;
175 astra_handstream_get_include_candidate_points(handStream_, &includeCandidatePoints);
176 return includeCandidatePoints;
186 astra_handstream_set_include_candidate_points(handStream_, includeCandidatePoints);
200 using HandPointList = std::vector<HandPoint>;
207 template<
typename TFrameType>
208 static TFrameType
acquire(astra_reader_frame_t readerFrame,
209 astra_stream_subtype_t subtype)
211 if (readerFrame !=
nullptr)
214 astra_frame_get_handframe_with_subtype(readerFrame, subtype, &handFrame);
215 return TFrameType(handFrame);
218 return TFrameType(
nullptr);
228 handFrame_ = handFrame;
231 astra_handframe_get_frameindex(handFrame_, &frameIndex_);
233 std::uint32_t maxHandCount;
234 astra_handframe_get_hand_count(handFrame_, &maxHandCount);
236 handPoints_.reserve(maxHandCount);
245 bool is_valid()
const {
return handFrame_ !=
nullptr; }
261 throw_if_invalid_frame();
264 return handPoints_.size();
274 throw_if_invalid_frame();
286 throw_if_invalid_frame();
291 void throw_if_invalid_frame()
const
293 if (!handFrame_) {
throw std::logic_error(
"Cannot operate on an invalid frame"); }
296 void verify_handpoints()
const
298 if (handPointsInitialized_) {
return; }
299 handPointsInitialized_ =
true;
302 std::uint32_t maxHandCount;
304 astra_handframe_get_shared_hand_array(handFrame_, &handPtr, &maxHandCount);
306 for (
size_t i = 0; i < maxHandCount; ++i, ++handPtr)
309 if (p.status != astra_handstatus_t::HAND_STATUS_NOTTRACKING)
311 handPoints_.emplace_back(HandPoint(p));
317 mutable bool handPointsInitialized_{
false};
318 mutable HandPointList handPoints_;
321 astra_frame_index_t frameIndex_;
Data Stream
Definition: DataStream.hpp:33
A Hand Data Frame
Definition: Hand.hpp:198
const HandPointList & handpoints() const
get hand Points
Definition: Hand.hpp:272
astra_handframe_t handle() const
get handle
Definition: Hand.hpp:252
astra_frame_index_t frame_index() const
get frame index
Definition: Hand.hpp:284
size_t handpoint_count() const
get hand Points count
Definition: Hand.hpp:259
bool is_valid() const
get is valid
Definition: Hand.hpp:245
static TFrameType acquire(astra_reader_frame_t readerFrame, astra_stream_subtype_t subtype)
set is include candidate points
Definition: Hand.hpp:208
HandFrame(astra_handframe_t handFrame)
constructs
Definition: Hand.hpp:226
Hand Point struct
Definition: Hand.hpp:41
HandPoint(std::int32_t trackingId, astra_handstatus_t status, Vector2i depthPosition, Vector3f worldPosition, Vector3f worldDeltaPosition)
constructs
Definition: Hand.hpp:52
Vector3f world_position() const
get world position
Definition: Hand.hpp:131
std::int32_t tracking_id() const
get tracking id
Definition: Hand.hpp:110
astra_handstatus_t status() const
get status
Definition: Hand.hpp:117
HandPoint & operator=(const ::astra_handpoint_t &handPoint)
copy constructs
Definition: Hand.hpp:80
Vector2i depth_position() const
get depth position
Definition: Hand.hpp:124
Vector3f world_delta_position() const
get world delta position
Definition: Hand.hpp:138
HandPoint(const astra_handpoint_t &handPoint)
constructs
Definition: Hand.hpp:70
A Hand Stream
Definition: Hand.hpp:153
bool get_include_candidate_points() const
get is include candidate points
Definition: Hand.hpp:172
HandStream(astra_streamconnection_t connection)
constructs
Definition: Hand.hpp:160
void set_include_candidate_points(bool includeCandidatePoints)
set is include candidate points
Definition: Hand.hpp:184
Definition: stream_types.h:50
Definition: astra_plugin.h:24
Represents a float 2d vector
Definition: Vector2i.hpp:31
Represents a float 3d vector
Definition: Vector3f.hpp:30
Definition: hand_types.h:48