mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2025-02-13 17:20:09 +00:00
t/hand: Add option for allowing xfctx to be managed externally
Other trackers (e.g., psmv, slam, etc) work as sinks and the xfctx that manages them is handled by the device providing the data streams. This change helps the hand tracker have a more similar interface to other trackers.
This commit is contained in:
parent
44dac0eb5d
commit
7e1f9a7964
src/xrt
|
@ -54,6 +54,9 @@ struct ht_device
|
|||
{
|
||||
struct xrt_device base;
|
||||
|
||||
//! Whether to use our `xfctx` or an externally managed one.
|
||||
//! @note This variable exists because we still need to settle on the ht usage interface.
|
||||
bool own_xfctx;
|
||||
struct xrt_frame_context xfctx;
|
||||
|
||||
struct t_hand_tracking_sync *sync;
|
||||
|
@ -171,8 +174,10 @@ ht_device_destroy(struct xrt_device *xdev)
|
|||
struct ht_device *htd = ht_device(xdev);
|
||||
HT_DEBUG(htd, "called!");
|
||||
|
||||
if (htd->own_xfctx) {
|
||||
xrt_frame_context_destroy_nodes(&htd->xfctx);
|
||||
}
|
||||
|
||||
xrt_frame_context_destroy_nodes(&htd->xfctx);
|
||||
// Remove the variable tracking.
|
||||
u_var_remove_root(htd);
|
||||
|
||||
|
@ -181,6 +186,7 @@ ht_device_destroy(struct xrt_device *xdev)
|
|||
|
||||
static struct ht_device *
|
||||
ht_device_create_common(struct t_stereo_camera_calibration *calib,
|
||||
bool own_xfctx,
|
||||
struct xrt_frame_context *xfctx,
|
||||
struct t_hand_tracking_sync *sync)
|
||||
{
|
||||
|
@ -197,7 +203,10 @@ ht_device_create_common(struct t_stereo_camera_calibration *calib,
|
|||
// Setup logging first
|
||||
htd->log_level = debug_get_log_option_ht_log();
|
||||
|
||||
htd->xfctx.nodes = xfctx->nodes;
|
||||
htd->own_xfctx = own_xfctx;
|
||||
if (own_xfctx) { // Transfer ownership of xfctx to htd
|
||||
htd->xfctx.nodes = xfctx->nodes;
|
||||
}
|
||||
|
||||
htd->base.tracking_origin->type = XRT_TRACKING_TYPE_RGB;
|
||||
htd->base.tracking_origin->offset.position.x = 0.0f;
|
||||
|
@ -224,7 +233,7 @@ ht_device_create_common(struct t_stereo_camera_calibration *calib,
|
|||
|
||||
htd->sync = sync;
|
||||
|
||||
htd->async = t_hand_tracking_async_default_create(&htd->xfctx, sync);
|
||||
htd->async = t_hand_tracking_async_default_create(xfctx, sync);
|
||||
return htd;
|
||||
}
|
||||
|
||||
|
@ -280,7 +289,7 @@ ht_device_create_index(struct xrt_prober *xp, struct t_stereo_camera_calibration
|
|||
sync = t_hand_tracking_sync_mercury_create(calib, MERCURY_OUTPUT_SPACE_LEFT_CAMERA);
|
||||
}
|
||||
|
||||
struct ht_device *htd = ht_device_create_common(calib, &finder.xfctx, sync);
|
||||
struct ht_device *htd = ht_device_create_common(calib, true, &finder.xfctx, sync);
|
||||
|
||||
struct xrt_frame_sink *tmp = NULL;
|
||||
|
||||
|
@ -350,7 +359,7 @@ ht_device_create_depthai_ov9282()
|
|||
|
||||
sync = t_hand_tracking_sync_mercury_create(calib, MERCURY_OUTPUT_SPACE_LEFT_CAMERA);
|
||||
|
||||
struct ht_device *htd = ht_device_create_common(calib, &xfctx, sync);
|
||||
struct ht_device *htd = ht_device_create_common(calib, true, &xfctx, sync);
|
||||
|
||||
struct xrt_slam_sinks tmp;
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
|
||||
#include "xrt/xrt_defines.h"
|
||||
#include "xrt/xrt_frame.h"
|
||||
#include "xrt/xrt_tracking.h"
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -88,6 +89,7 @@ struct t_hand_tracking_async
|
|||
struct xrt_frame_node node;
|
||||
struct xrt_frame_sink left;
|
||||
struct xrt_frame_sink right;
|
||||
struct xrt_slam_sinks sinks; //!< Pointers to `left` and `right` sinks
|
||||
|
||||
void (*get_hand)(struct t_hand_tracking_async *ht_async,
|
||||
enum xrt_input_name name,
|
||||
|
|
|
@ -171,6 +171,8 @@ t_hand_tracking_async_default_create(struct xrt_frame_context *xfctx, struct t_h
|
|||
struct ht_async_impl *hta = U_TYPED_CALLOC(struct ht_async_impl);
|
||||
hta->base.left.push_frame = ht_async_receive_left;
|
||||
hta->base.right.push_frame = ht_async_receive_right;
|
||||
hta->base.sinks.left = &hta->base.left;
|
||||
hta->base.sinks.right = &hta->base.right;
|
||||
hta->base.node.break_apart = ht_async_break_apart;
|
||||
hta->base.node.destroy = ht_async_destroy;
|
||||
hta->base.get_hand = ht_async_get_hand;
|
||||
|
|
Loading…
Reference in a new issue