The open source OpenXR runtime
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

st/gui: Add small hand-tracking demo scene

+140 -1
+5
src/xrt/state_trackers/gui/CMakeLists.txt
··· 13 13 gui_scene.cpp 14 14 gui_scene_calibrate.c 15 15 gui_scene_debug.c 16 + gui_scene_hand_tracking_demo.c 16 17 gui_scene_main_menu.c 17 18 gui_scene_record.c 18 19 gui_scene_remote.c ··· 42 43 43 44 if(XRT_BUILD_DRIVER_DEPTHAI) 44 45 target_link_libraries(st_gui PRIVATE drv_depthai) 46 + endif() 47 + 48 + if(XRT_BUILD_DRIVER_HANDTRACKING) 49 + target_link_libraries(st_gui PRIVATE drv_ht) 45 50 endif() 46 51 47 52 if(XRT_BUILD_DRIVER_REMOTE)
+9 -1
src/xrt/state_trackers/gui/gui_common.h
··· 1 - // Copyright 2019, Collabora, Ltd. 1 + // Copyright 2019-2023, Collabora, Ltd. 2 2 // SPDX-License-Identifier: BSL-1.0 3 3 /*! 4 4 * @file ··· 212 212 */ 213 213 void 214 214 gui_scene_debug(struct gui_program *p); 215 + 216 + /*! 217 + * Small hand-tracking demo. 218 + * 219 + * @ingroup gui 220 + */ 221 + void 222 + gui_scene_hand_tracking_demo(struct gui_program *p); 215 223 216 224 /*! 217 225 * Create a recording view scene.
+121
src/xrt/state_trackers/gui/gui_scene_hand_tracking_demo.c
··· 1 + // Copyright 2019-2023, Collabora, Ltd. 2 + // SPDX-License-Identifier: BSL-1.0 3 + /*! 4 + * @file 5 + * @brief Small hand-tracking demo scene 6 + * @author Jakob Bornecrantz <jakob@collabora.com> 7 + * @ingroup gui 8 + */ 9 + 10 + #include "xrt/xrt_prober.h" 11 + #include "xrt/xrt_device.h" 12 + #include "xrt/xrt_results.h" 13 + #include "xrt/xrt_config_have.h" 14 + #include "xrt/xrt_config_drivers.h" 15 + #include "xrt/xrt_config_drivers.h" 16 + 17 + #include "math/m_api.h" 18 + #include "math/m_space.h" 19 + #include "multi_wrapper/multi.h" 20 + #include "realsense/rs_interface.h" 21 + #include "tracking/t_hand_tracking.h" 22 + #include "tracking/t_tracking.h" 23 + 24 + #include "util/u_file.h" 25 + #include "util/u_sink.h" 26 + #include "util/u_debug.h" 27 + #include "util/u_device.h" 28 + #include "util/u_builders.h" 29 + #include "util/u_config_json.h" 30 + #include "util/u_pretty_print.h" 31 + #include "util/u_system_helpers.h" 32 + 33 + #include "gui_common.h" 34 + 35 + 36 + #ifdef XRT_BUILD_DRIVER_DEPTHAI 37 + #include "depthai/depthai_interface.h" 38 + #endif 39 + 40 + #ifdef XRT_BUILD_DRIVER_HANDTRACKING 41 + #include "ht/ht_interface.h" 42 + #endif 43 + 44 + 45 + #if defined(XRT_BUILD_DRIVER_DEPTHAI) && defined(XRT_BUILD_DRIVER_HANDTRACKING) 46 + 47 + 48 + void 49 + gui_scene_hand_tracking_demo(struct gui_program *p) 50 + { 51 + struct u_system_devices *usysd = u_system_devices_allocate(); 52 + struct xrt_system_devices *xsysd = &usysd->base; 53 + struct depthai_slam_startup_settings settings = {0}; 54 + struct xrt_device *ht_dev; 55 + 56 + settings.frames_per_second = 60; 57 + settings.half_size_ov9282 = false; 58 + settings.want_cameras = true; 59 + settings.want_imu = false; 60 + 61 + struct xrt_fs *the_fs = depthai_fs_slam(&usysd->xfctx, &settings); 62 + 63 + if (the_fs == NULL) { 64 + xrt_system_devices_destroy(&xsysd); 65 + return; 66 + } 67 + 68 + struct t_stereo_camera_calibration *calib = NULL; 69 + depthai_fs_get_stereo_calibration(the_fs, &calib); 70 + 71 + 72 + struct xrt_slam_sinks *hand_sinks = NULL; 73 + 74 + struct t_camera_extra_info extra_camera_info = XRT_STRUCT_INIT; 75 + extra_camera_info.views[0].boundary_type = HT_IMAGE_BOUNDARY_NONE; 76 + extra_camera_info.views[0].camera_orientation = CAMERA_ORIENTATION_0; 77 + extra_camera_info.views[1].boundary_type = HT_IMAGE_BOUNDARY_NONE; 78 + extra_camera_info.views[1].camera_orientation = CAMERA_ORIENTATION_0; 79 + 80 + int create_status = ht_device_create( // 81 + &usysd->xfctx, // 82 + calib, // 83 + HT_ALGORITHM_MERCURY, // 84 + extra_camera_info, // 85 + &hand_sinks, // 86 + &ht_dev); // 87 + t_stereo_camera_calibration_reference(&calib, NULL); 88 + if (create_status != 0) { 89 + xrt_system_devices_destroy(&xsysd); 90 + return; 91 + } 92 + 93 + xsysd->xdevs[xsysd->xdev_count++] = ht_dev; 94 + 95 + struct xrt_slam_sinks gen_lock = {0}; 96 + u_sink_force_genlock_create( // 97 + &usysd->xfctx, // 98 + hand_sinks->left, // 99 + hand_sinks->right, // 100 + &gen_lock.left, // 101 + &gen_lock.right); // 102 + 103 + xrt_fs_slam_stream_start(the_fs, &gen_lock); 104 + 105 + p->xsysd = xsysd; 106 + 107 + gui_scene_debug(p); 108 + } 109 + 110 + 111 + #else /* XRT_BUILD_DRIVER_DEPTHAI */ 112 + 113 + 114 + void 115 + gui_scene_hand_tracking_demo(struct gui_program *p) 116 + { 117 + // No-op 118 + } 119 + 120 + 121 + #endif /* XRT_BUILD_DRIVER_DEPTHAI */
+5
src/xrt/state_trackers/gui/gui_scene_main_menu.c
··· 77 77 gui_scene_remote(p, NULL); 78 78 } 79 79 80 + if (igButton("Hand-Tracking Demo", button_dims)) { 81 + gui_scene_delete_me(p, scene); 82 + gui_scene_hand_tracking_demo(p); 83 + } 84 + 80 85 igSeparator(); 81 86 82 87 if (igButton("Exit", button_dims)) {