d/{rift_s,vive,ns}: Share hand bounding box with head tracker

This commit is contained in:
Mateo de Mayo 2024-01-23 17:49:59 -03:00 committed by Simon Zeni
parent eadc592c04
commit 6afed4dc4a
3 changed files with 21 additions and 16 deletions

View file

@ -232,6 +232,7 @@ rift_s_create_slam_tracker(struct rift_s_tracker *t, struct xrt_frame_context *x
static int static int
rift_s_create_hand_tracker(struct rift_s_tracker *t, rift_s_create_hand_tracker(struct rift_s_tracker *t,
struct xrt_frame_context *xfctx, struct xrt_frame_context *xfctx,
struct xrt_hand_masks_sink *masks_sink,
struct xrt_slam_sinks **out_sinks, struct xrt_slam_sinks **out_sinks,
struct xrt_device **out_device) struct xrt_device **out_device)
{ {
@ -252,8 +253,7 @@ rift_s_create_hand_tracker(struct rift_s_tracker *t,
extra_camera_info.views[0].camera_orientation = CAMERA_ORIENTATION_90; extra_camera_info.views[0].camera_orientation = CAMERA_ORIENTATION_90;
extra_camera_info.views[1].camera_orientation = CAMERA_ORIENTATION_90; extra_camera_info.views[1].camera_orientation = CAMERA_ORIENTATION_90;
// TODO@mateosss: Use proper masks_sink in all drivers and not null struct t_hand_tracking_create_info create_info = {.cams_info = extra_camera_info, .masks_sink = masks_sink};
struct t_hand_tracking_create_info create_info = {.cams_info = extra_camera_info, .masks_sink = NULL};
int create_status = ht_device_create(xfctx, // int create_status = ht_device_create(xfctx, //
t->stereo_calib, // t->stereo_calib, //
@ -404,8 +404,9 @@ rift_s_tracker_create(struct xrt_tracking_origin *origin,
// Initialize hand tracker // Initialize hand tracker
struct xrt_slam_sinks *hand_sinks = NULL; struct xrt_slam_sinks *hand_sinks = NULL;
struct xrt_device *hand_device = NULL; struct xrt_device *hand_device = NULL;
struct xrt_hand_masks_sink *masks_sink = slam_sinks->hand_masks;
if (t->tracking.hand_enabled) { if (t->tracking.hand_enabled) {
int hand_status = rift_s_create_hand_tracker(t, xfctx, &hand_sinks, &hand_device); int hand_status = rift_s_create_hand_tracker(t, xfctx, masks_sink, &hand_sinks, &hand_device);
if (hand_status != 0 || hand_sinks == NULL || hand_device == NULL) { if (hand_status != 0 || hand_sinks == NULL || hand_device == NULL) {
RIFT_S_WARN("Unable to setup the hand tracker"); RIFT_S_WARN("Unable to setup the hand tracker");
rift_s_tracker_destroy(t); rift_s_tracker_destroy(t);

View file

@ -201,6 +201,7 @@ valve_index_hand_track(struct lighthouse_system *lhs,
struct xrt_frame_context *xfctx, struct xrt_frame_context *xfctx,
struct xrt_pose head_in_left_cam, struct xrt_pose head_in_left_cam,
struct t_stereo_camera_calibration *stereo_calib, struct t_stereo_camera_calibration *stereo_calib,
struct xrt_hand_masks_sink *masks_sink,
struct xrt_slam_sinks **out_sinks, struct xrt_slam_sinks **out_sinks,
struct xrt_device **out_devices) struct xrt_device **out_devices)
{ {
@ -233,7 +234,7 @@ valve_index_hand_track(struct lighthouse_system *lhs,
info.views[0].boundary.circle.normalized_radius = 0.55; info.views[0].boundary.circle.normalized_radius = 0.55;
info.views[1].boundary.circle.normalized_radius = 0.55; info.views[1].boundary.circle.normalized_radius = 0.55;
struct t_hand_tracking_create_info create_info = {.cams_info = info, .masks_sink = NULL}; struct t_hand_tracking_create_info create_info = {.cams_info = info, .masks_sink = masks_sink};
struct xrt_device *ht_device = NULL; struct xrt_device *ht_device = NULL;
int create_status = ht_device_create( // int create_status = ht_device_create( //
@ -384,6 +385,7 @@ valve_index_setup_visual_trackers(struct lighthouse_system *lhs,
// Initialize hand tracker // Initialize hand tracker
struct xrt_slam_sinks *hand_sinks = NULL; struct xrt_slam_sinks *hand_sinks = NULL;
struct xrt_device *hand_devices[2] = {NULL}; struct xrt_device *hand_devices[2] = {NULL};
struct xrt_hand_masks_sink *masks_sink = slam_sinks->hand_masks;
if (hand_enabled) { if (hand_enabled) {
bool success = valve_index_hand_track( // bool success = valve_index_hand_track( //
lhs, // lhs, //
@ -391,6 +393,7 @@ valve_index_setup_visual_trackers(struct lighthouse_system *lhs,
xfctx, // xfctx, //
head_in_left_cam, // head_in_left_cam, //
stereo_calib, // stereo_calib, //
masks_sink, //
&hand_sinks, // &hand_sinks, //
hand_devices); // hand_devices); //
if (!success) { if (!success) {

View file

@ -295,8 +295,20 @@ ns_setup_depthai_device(struct ns_builder *nsb,
depthai_fs_get_stereo_calibration(the_fs, &calib); depthai_fs_get_stereo_calibration(the_fs, &calib);
struct xrt_slam_sinks *slam_sinks = NULL;
xret = twrap_slam_create_device(xfctx, XRT_DEVICE_DEPTHAI, &slam_sinks, out_head_device);
if (xret != XRT_SUCCESS) {
U_LOG_E("twrap_slam_create_device: %u", xret);
return xret;
}
if (slam_sinks == NULL) {
U_LOG_E("twrap_slam_create_device: Returned NULL slam_sinks!");
return XRT_ERROR_DEVICE_CREATION_FAILED;
}
#ifdef XRT_BUILD_DRIVER_HANDTRACKING #ifdef XRT_BUILD_DRIVER_HANDTRACKING
struct xrt_slam_sinks *hand_sinks = NULL; struct xrt_slam_sinks *hand_sinks = NULL;
struct xrt_hand_masks_sink *masks_sink = slam_sinks->hand_masks;
struct t_camera_extra_info extra_camera_info = {0}; struct t_camera_extra_info extra_camera_info = {0};
@ -311,7 +323,7 @@ ns_setup_depthai_device(struct ns_builder *nsb,
extra_camera_info.views[0].boundary_type = HT_IMAGE_BOUNDARY_NONE; extra_camera_info.views[0].boundary_type = HT_IMAGE_BOUNDARY_NONE;
extra_camera_info.views[1].boundary_type = HT_IMAGE_BOUNDARY_NONE; extra_camera_info.views[1].boundary_type = HT_IMAGE_BOUNDARY_NONE;
struct t_hand_tracking_create_info create_info = {.cams_info = extra_camera_info, .masks_sink = NULL}; struct t_hand_tracking_create_info create_info = {.cams_info = extra_camera_info, .masks_sink = masks_sink};
int create_status = ht_device_create( // int create_status = ht_device_create( //
xfctx, // xfctx, //
@ -325,17 +337,6 @@ ns_setup_depthai_device(struct ns_builder *nsb,
} }
#endif #endif
struct xrt_slam_sinks *slam_sinks = NULL;
xret = twrap_slam_create_device(xfctx, XRT_DEVICE_DEPTHAI, &slam_sinks, out_head_device);
if (xret != XRT_SUCCESS) {
U_LOG_E("twrap_slam_create_device: %u", xret);
return xret;
}
if (slam_sinks == NULL) {
U_LOG_E("twrap_slam_create_device: Returned NULL slam_sinks!");
return XRT_ERROR_DEVICE_CREATION_FAILED;
}
struct xrt_slam_sinks entry_sinks = {0}; struct xrt_slam_sinks entry_sinks = {0};
struct xrt_frame_sink *entry_left_sink = NULL; struct xrt_frame_sink *entry_left_sink = NULL;
struct xrt_frame_sink *entry_right_sink = NULL; struct xrt_frame_sink *entry_right_sink = NULL;