Debian Codegraph @

src/xrt/state_trackers/gui/gui_scene_hand_tracking_demo.c

raw symbols SCIP
1 // Copyright 2019-2023, Collabora, Ltd.cxx . . $ `<file>/src/xrt/state_trackers/gui/gui_scene_hand_tracking_demo.c`/
2 // SPDX-License-Identifier: BSL-1.0
3 /*!
4 * @file
5 * @brief Small hand-tracking demo scene
6 * @author Jakob Bornecrantz <[email protected]>
7 * @ingroup gui
8 */
9
10 #include "xrt/xrt_prober.h"cxx . . $ `<file>/src/xrt/include/xrt/xrt_prober.h`/
11 #include "xrt/xrt_device.h"cxx . . $ `<file>/src/xrt/include/xrt/xrt_device.h`/
12 #include "xrt/xrt_results.h"cxx . . $ `<file>/src/xrt/include/xrt/xrt_results.h`/
13 #include "xrt/xrt_config_have.h"cxx . . $ `<file>/build/src/xrt/include/xrt/xrt_config_have.h`/
14 #include "xrt/xrt_config_drivers.h"cxx . . $ `<file>/build/src/xrt/include/xrt/xrt_config_drivers.h`/
15 #include "xrt/xrt_config_drivers.h"cxx . . $ `<file>/build/src/xrt/include/xrt/xrt_config_drivers.h`/
16
17 #include "math/m_api.h"cxx . . $ `<file>/src/xrt/auxiliary/math/m_api.h`/
18 #include "math/m_space.h"cxx . . $ `<file>/src/xrt/auxiliary/math/m_space.h`/
19 #include "multi_wrapper/multi.h"cxx . . $ `<file>/src/xrt/drivers/multi_wrapper/multi.h`/
20 #include "realsense/rs_interface.h"cxx . . $ `<file>/src/xrt/drivers/realsense/rs_interface.h`/
21 #include "tracking/t_hand_tracking.h"cxx . . $ `<file>/src/xrt/include/tracking/t_hand_tracking.h`/
22 #include "tracking/t_tracking.h"cxx . . $ `<file>/src/xrt/auxiliary/tracking/t_tracking.h`/
23
24 #include "util/u_file.h"cxx . . $ `<file>/src/xrt/auxiliary/util/u_file.h`/
25 #include "util/u_sink.h"cxx . . $ `<file>/src/xrt/auxiliary/util/u_sink.h`/
26 #include "util/u_debug.h"cxx . . $ `<file>/src/xrt/auxiliary/util/u_debug.h`/
27 #include "util/u_device.h"cxx . . $ `<file>/src/xrt/auxiliary/util/u_device.h`/
28 #include "util/u_builders.h"cxx . . $ `<file>/src/xrt/auxiliary/util/u_builders.h`/
29 #include "util/u_config_json.h"cxx . . $ `<file>/src/xrt/auxiliary/util/u_config_json.h`/
30 #include "util/u_pretty_print.h"cxx . . $ `<file>/src/xrt/auxiliary/util/u_pretty_print.h`/
31 #include "util/u_system_helpers.h"cxx . . $ `<file>/src/xrt/auxiliary/util/u_system_helpers.h`/
32
33 #include "gui_common.h"cxx . . $ `<file>/src/xrt/state_trackers/gui/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 struct t_hand_tracking_create_info create_info = {.cams_info = extra_camera_info, .masks_sink = NULL};
81
82 int create_status = ht_device_create( //
83 &usysd->xfctx, //
84 calib, //
85 create_info, //
86 &hand_sinks, //
87 &ht_dev); //
88 t_stereo_camera_calibration_reference(&calib, NULL);
89 if (create_status != 0) {
90 xrt_system_devices_destroy(&xsysd);
91 return;
92 }
93
94 xsysd->xdevs[xsysd->xdev_count++] = ht_dev;
95
96 struct xrt_slam_sinks gen_lock = {0};
97 u_sink_force_genlock_create( //
98 &usysd->xfctx, //
99 hand_sinks->cams[0], //
100 hand_sinks->cams[1], //
101 &gen_lock.cams[0], //
102 &gen_lock.cams[1]); //
103
104 xrt_fs_slam_stream_start(the_fs, &gen_lock);
105
106 p->xsysd = xsysd;
107
108 gui_scene_debug(p);
109 }
110
111
112 #else /* XRT_BUILD_DRIVER_DEPTHAI */
113
114
115 void
116 gui_scene_hand_tracking_democxx . . $ gui_scene_hand_tracking_demo(fc59ab155e161203).(struct gui_programcxx . . $ gui_program# *p)
117 {
118 // No-op
119 }
120
121
122 #endif /* XRT_BUILD_DRIVER_DEPTHAI */