mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2024-12-29 11:06:18 +00:00
st/gui: Add small hand-tracking demo scene
This commit is contained in:
parent
d1b431bec6
commit
4643d4f089
|
@ -13,6 +13,7 @@ add_library(
|
|||
gui_scene.cpp
|
||||
gui_scene_calibrate.c
|
||||
gui_scene_debug.c
|
||||
gui_scene_hand_tracking_demo.c
|
||||
gui_scene_main_menu.c
|
||||
gui_scene_record.c
|
||||
gui_scene_remote.c
|
||||
|
@ -44,6 +45,10 @@ if(XRT_BUILD_DRIVER_DEPTHAI)
|
|||
target_link_libraries(st_gui PRIVATE drv_depthai)
|
||||
endif()
|
||||
|
||||
if(XRT_BUILD_DRIVER_HANDTRACKING)
|
||||
target_link_libraries(st_gui PRIVATE drv_ht)
|
||||
endif()
|
||||
|
||||
if(XRT_BUILD_DRIVER_REMOTE)
|
||||
target_link_libraries(st_gui PRIVATE drv_remote)
|
||||
endif()
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright 2019, Collabora, Ltd.
|
||||
// Copyright 2019-2023, Collabora, Ltd.
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
/*!
|
||||
* @file
|
||||
|
@ -213,6 +213,14 @@ gui_scene_tracking_overrides(struct gui_program *p);
|
|||
void
|
||||
gui_scene_debug(struct gui_program *p);
|
||||
|
||||
/*!
|
||||
* Small hand-tracking demo.
|
||||
*
|
||||
* @ingroup gui
|
||||
*/
|
||||
void
|
||||
gui_scene_hand_tracking_demo(struct gui_program *p);
|
||||
|
||||
/*!
|
||||
* Create a recording view scene.
|
||||
*
|
||||
|
|
121
src/xrt/state_trackers/gui/gui_scene_hand_tracking_demo.c
Normal file
121
src/xrt/state_trackers/gui/gui_scene_hand_tracking_demo.c
Normal file
|
@ -0,0 +1,121 @@
|
|||
// Copyright 2019-2023, Collabora, Ltd.
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
/*!
|
||||
* @file
|
||||
* @brief Small hand-tracking demo scene
|
||||
* @author Jakob Bornecrantz <jakob@collabora.com>
|
||||
* @ingroup gui
|
||||
*/
|
||||
|
||||
#include "xrt/xrt_prober.h"
|
||||
#include "xrt/xrt_device.h"
|
||||
#include "xrt/xrt_results.h"
|
||||
#include "xrt/xrt_config_have.h"
|
||||
#include "xrt/xrt_config_drivers.h"
|
||||
#include "xrt/xrt_config_drivers.h"
|
||||
|
||||
#include "math/m_api.h"
|
||||
#include "math/m_space.h"
|
||||
#include "multi_wrapper/multi.h"
|
||||
#include "realsense/rs_interface.h"
|
||||
#include "tracking/t_hand_tracking.h"
|
||||
#include "tracking/t_tracking.h"
|
||||
|
||||
#include "util/u_file.h"
|
||||
#include "util/u_sink.h"
|
||||
#include "util/u_debug.h"
|
||||
#include "util/u_device.h"
|
||||
#include "util/u_builders.h"
|
||||
#include "util/u_config_json.h"
|
||||
#include "util/u_pretty_print.h"
|
||||
#include "util/u_system_helpers.h"
|
||||
|
||||
#include "gui_common.h"
|
||||
|
||||
|
||||
#ifdef XRT_BUILD_DRIVER_DEPTHAI
|
||||
#include "depthai/depthai_interface.h"
|
||||
#endif
|
||||
|
||||
#ifdef XRT_BUILD_DRIVER_HANDTRACKING
|
||||
#include "ht/ht_interface.h"
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(XRT_BUILD_DRIVER_DEPTHAI) && defined(XRT_BUILD_DRIVER_HANDTRACKING)
|
||||
|
||||
|
||||
void
|
||||
gui_scene_hand_tracking_demo(struct gui_program *p)
|
||||
{
|
||||
struct u_system_devices *usysd = u_system_devices_allocate();
|
||||
struct xrt_system_devices *xsysd = &usysd->base;
|
||||
struct depthai_slam_startup_settings settings = {0};
|
||||
struct xrt_device *ht_dev;
|
||||
|
||||
settings.frames_per_second = 60;
|
||||
settings.half_size_ov9282 = false;
|
||||
settings.want_cameras = true;
|
||||
settings.want_imu = false;
|
||||
|
||||
struct xrt_fs *the_fs = depthai_fs_slam(&usysd->xfctx, &settings);
|
||||
|
||||
if (the_fs == NULL) {
|
||||
xrt_system_devices_destroy(&xsysd);
|
||||
return;
|
||||
}
|
||||
|
||||
struct t_stereo_camera_calibration *calib = NULL;
|
||||
depthai_fs_get_stereo_calibration(the_fs, &calib);
|
||||
|
||||
|
||||
struct xrt_slam_sinks *hand_sinks = NULL;
|
||||
|
||||
struct t_camera_extra_info extra_camera_info = XRT_STRUCT_INIT;
|
||||
extra_camera_info.views[0].boundary_type = HT_IMAGE_BOUNDARY_NONE;
|
||||
extra_camera_info.views[0].camera_orientation = CAMERA_ORIENTATION_0;
|
||||
extra_camera_info.views[1].boundary_type = HT_IMAGE_BOUNDARY_NONE;
|
||||
extra_camera_info.views[1].camera_orientation = CAMERA_ORIENTATION_0;
|
||||
|
||||
int create_status = ht_device_create( //
|
||||
&usysd->xfctx, //
|
||||
calib, //
|
||||
HT_ALGORITHM_MERCURY, //
|
||||
extra_camera_info, //
|
||||
&hand_sinks, //
|
||||
&ht_dev); //
|
||||
t_stereo_camera_calibration_reference(&calib, NULL);
|
||||
if (create_status != 0) {
|
||||
xrt_system_devices_destroy(&xsysd);
|
||||
return;
|
||||
}
|
||||
|
||||
xsysd->xdevs[xsysd->xdev_count++] = ht_dev;
|
||||
|
||||
struct xrt_slam_sinks gen_lock = {0};
|
||||
u_sink_force_genlock_create( //
|
||||
&usysd->xfctx, //
|
||||
hand_sinks->left, //
|
||||
hand_sinks->right, //
|
||||
&gen_lock.left, //
|
||||
&gen_lock.right); //
|
||||
|
||||
xrt_fs_slam_stream_start(the_fs, &gen_lock);
|
||||
|
||||
p->xsysd = xsysd;
|
||||
|
||||
gui_scene_debug(p);
|
||||
}
|
||||
|
||||
|
||||
#else /* XRT_BUILD_DRIVER_DEPTHAI */
|
||||
|
||||
|
||||
void
|
||||
gui_scene_hand_tracking_demo(struct gui_program *p)
|
||||
{
|
||||
// No-op
|
||||
}
|
||||
|
||||
|
||||
#endif /* XRT_BUILD_DRIVER_DEPTHAI */
|
|
@ -77,6 +77,11 @@ scene_render(struct gui_scene *scene, struct gui_program *p)
|
|||
gui_scene_remote(p, NULL);
|
||||
}
|
||||
|
||||
if (igButton("Hand-Tracking Demo", button_dims)) {
|
||||
gui_scene_delete_me(p, scene);
|
||||
gui_scene_hand_tracking_demo(p);
|
||||
}
|
||||
|
||||
igSeparator();
|
||||
|
||||
if (igButton("Exit", button_dims)) {
|
||||
|
|
Loading…
Reference in a new issue