10 #include <k4a/k4a.hpp> 43 frame(
const frame &other) noexcept : m_handle(other.m_handle)
45 if (m_handle !=
nullptr)
47 k4abt_frame_reference(m_handle);
55 other.m_handle =
nullptr;
70 m_handle = other.m_handle;
71 if (m_handle !=
nullptr)
73 k4abt_frame_reference(m_handle);
86 m_handle = other.m_handle;
87 other.m_handle =
nullptr;
104 return m_handle == other.m_handle;
111 return m_handle ==
nullptr;
118 return m_handle != other.m_handle;
125 return m_handle !=
nullptr;
130 operator bool() const noexcept
132 return m_handle !=
nullptr;
151 if (m_handle !=
nullptr)
153 k4abt_frame_release(m_handle);
164 return k4abt_frame_get_num_bodies(m_handle);
184 k4a_result_t result = k4abt_frame_get_body_skeleton(m_handle, index, &skeleton);
187 throw k4a::error(
"Get body skeleton failed!");
197 return k4abt_frame_get_body_id(m_handle, index);
208 body.
id = k4abt_frame_get_body_id(m_handle, index);
219 return std::chrono::microseconds(k4abt_frame_get_device_timestamp_usec(m_handle));
228 return k4a::image(k4abt_frame_get_body_index_map(m_handle));
263 dev.m_handle =
nullptr;
282 m_handle = dev.m_handle;
283 dev.m_handle =
nullptr;
290 operator bool() const noexcept
292 return m_handle !=
nullptr;
301 if (m_handle !=
nullptr)
303 k4abt_tracker_destroy(m_handle);
315 int32_t timeout_ms = k4a::internal::clamp_cast<int32_t>(timeout.count());
316 k4a_wait_result_t result = k4abt_tracker_enqueue_capture(m_handle, cap.handle(), timeout_ms);
319 throw k4a::error(
"Failed to enqueue capture to tracker!");
337 int32_t timeout_ms = k4a::internal::clamp_cast<int32_t>(timeout.count());
338 k4a_wait_result_t result = k4abt_tracker_pop_result(m_handle, &frame_handle, timeout_ms);
341 throw k4a::error(
"Failed to pop result from tracker!");
348 *body_frame =
frame(frame_handle);
376 k4abt_tracker_set_temporal_smoothing(m_handle, smoothing_factor);
385 k4abt_tracker_shutdown(m_handle);
396 k4a_result_t result = k4abt_tracker_create(&sensor_calibration, config, &handle);
400 throw k4a::error(
"Failed to create k4abt tracker!");
bool pop_result(k4abt::frame *body_frame, std::chrono::milliseconds timeout=std::chrono::milliseconds(K4A_WAIT_INFINITE))
Gets the next available body frame.
Definition: k4abt.hpp:334
k4abt_skeleton_t get_body_skeleton(uint32_t index)
Get the joint information for a particular person index from the k4abt_frame_t.
Definition: k4abt.hpp:171
void shutdown() noexcept
Shut down the k4abt tracker.
Definition: k4abt.hpp:383
Wrapper for k4abt_tracker_t.
Definition: k4abt.hpp:249
void set_temporal_smoothing(float smoothing_factor) noexcept
Set temporal smoothing.
Definition: k4abt.hpp:374
uint32_t id
An id for the body that can be used for frame-to-frame correlation.
Definition: k4abttypes.h:215
Handle to k4a body tracking component.
Definition: k4abttypes.h:34
void destroy() noexcept
Destroys a k4abt tracker.
Definition: k4abt.hpp:299
frame(const frame &other) noexcept
Creates a shallow copy of another k4abt frame.
Definition: k4abt.hpp:43
Structure to define joints for skeleton.
Definition: k4abttypes.h:206
Structure to define body.
Definition: k4abttypes.h:213
Handle to a k4a body tracking frame.
Definition: k4abttypes.h:41
uint32_t get_body_id(uint32_t index) noexcept
Get the body id for a particular person index from the k4abt frame.
Definition: k4abt.hpp:195
tracker(tracker &&dev) noexcept
Moves another tracker into a new tracker.
Definition: k4abt.hpp:261
bool enqueue_capture(k4a::capture cap, std::chrono::milliseconds timeout=std::chrono::milliseconds(K4A_WAIT_INFINITE))
Add a k4a sensor capture to the tracker input queue to generate its body tracking result asynchronous...
Definition: k4abt.hpp:313
k4abt_frame_t handle() const noexcept
Returns the underlying k4abt_frame_t handle.
Definition: k4abt.hpp:142
bool operator!=(const frame &other) const noexcept
Returns true if two frames wrap different k4abt_frame_t instances, false otherwise.
Definition: k4abt.hpp:116
frame & operator=(frame &&other) noexcept
Moves another frame into this frame; other is set to invalid.
Definition: k4abt.hpp:81
static tracker create(const k4a_calibration_t &sensor_calibration, const k4abt_tracker_configuration_t &config=K4ABT_TRACKER_CONFIG_DEFAULT)
Create a k4abt tracker.
Definition: k4abt.hpp:393
k4a::capture get_capture() const noexcept
Get the original capture that is used to calculate the k4abt frame.
Definition: k4abt.hpp:235
frame(frame &&other) noexcept
Moves another k4abt frame into a new frame.
Definition: k4abt.hpp:53
void get_body_skeleton(uint32_t index, k4abt_skeleton_t &skeleton)
Get the joint information for a particular person index from the k4abt_frame_t.
Definition: k4abt.hpp:182
Configuration parameters for a k4abt body tracker.
Definition: k4abttypes.h:128
bool operator!=(std::nullptr_t) const noexcept
Returns true if the frame is valid, false otherwise.
Definition: k4abt.hpp:123
frame & operator=(std::nullptr_t) noexcept
Invalidates this frame.
Definition: k4abt.hpp:94
frame(k4abt_frame_t handle=nullptr) noexcept
Creates a k4abt frame from a k4abt_frame_t.
Definition: k4abt.hpp:39
static const k4abt_tracker_configuration_t K4ABT_TRACKER_CONFIG_DEFAULT
Default configuration setting for k4abt tracker.
Definition: k4abttypes.h:248
#define K4A_WAIT_INFINITE
k4a::image get_body_index_map() const noexcept
Get the body index map associated with the k4abt frame.
Definition: k4abt.hpp:226
bool operator==(const frame &other) const noexcept
Returns true if two frames refer to the same k4abt_frame_t, false otherwise.
Definition: k4abt.hpp:102
k4abt::frame pop_result(std::chrono::milliseconds timeout=std::chrono::milliseconds(K4A_WAIT_INFINITE))
Gets the next available body frame.
Definition: k4abt.hpp:357
std::chrono::microseconds get_device_timestamp() const noexcept
Get the k4abt frame's device timestamp in microseconds.
Definition: k4abt.hpp:217
tracker & operator=(tracker &&dev) noexcept
Moves another tracker into this tracker; other is set to invalid.
Definition: k4abt.hpp:277
frame & operator=(const frame &other) noexcept
Sets frame to a shallow copy of other.
Definition: k4abt.hpp:65
k4abt_skeleton_t skeleton
The skeleton information for the body.
Definition: k4abttypes.h:216
k4abt_body_t get_body(uint32_t index) noexcept
Get the full body struct for a particular person index from the k4abt frame.
Definition: k4abt.hpp:205
uint32_t get_num_bodies() noexcept
Get the number of people detected from the k4abt frame.
Definition: k4abt.hpp:162
void reset() noexcept
Releases the underlying k4abt_frame_t; the frame is set to invalid.
Definition: k4abt.hpp:149
Wrapper for k4abt_frame_t.
Definition: k4abt.hpp:31
bool operator==(std::nullptr_t) const noexcept
Returns false if the frame is valid, true otherwise.
Definition: k4abt.hpp:109
tracker(k4abt_tracker_t handle=nullptr) noexcept
Creates a tracker from a k4abt_tracker_t Takes ownership of the handle, i.e.
Definition: k4abt.hpp:257