Monado OpenXR Runtime
Loading...
Searching...
No Matches
t_tracking.h
Go to the documentation of this file.
1// Copyright 2019-2023, Collabora, Ltd.
2// SPDX-License-Identifier: BSL-1.0
3/*!
4 * @file
5 * @brief Tracking API interface.
6 * @author Pete Black <pblack@collabora.com>
7 * @author Jakob Bornecrantz <jakob@collabora.com>
8 * @author Rylie Pavlik <rylie.pavlik@collabora.com>
9 * @author Moshi Turner <moshiturner@protonmail.com>
10 * @ingroup aux_tracking
11 */
12
13#pragma once
14
15#include "util/u_logging.h"
16#include "xrt/xrt_defines.h"
17#include "xrt/xrt_frame.h"
18#include "xrt/xrt_tracking.h"
19#include "util/u_misc.h"
20
21#include <stdio.h>
22
23
24#ifdef __cplusplus
25extern "C" {
26#endif
27
28/*!
29 * @addtogroup aux_tracking
30 * @{
31 */
32
33
34/*
35 *
36 * Pre-declare
37 *
38 */
39
40typedef struct cJSON cJSON;
41struct xrt_slam_sinks;
42struct xrt_tracked_psmv;
43struct xrt_tracked_psvr;
44struct xrt_tracked_slam;
45
46
47/*
48 *
49 * Calibration data.
50 *
51 */
52
53//! Maximum size of rectilinear distortion coefficient array
54#define XRT_DISTORTION_MAX_DIM (14)
55
56/*!
57 * @brief The distortion model this camera calibration falls under.
58 * @todo Add RiftS's Fisheye62 to this enumerator once we have native support for it in our hand tracking and SLAM.
59 * @todo Feel free to add support for T_DISTORTION_OPENCV_RADTAN_4 or T_DISTORTION_OPENCV_RADTAN_12 whenever you have a
60 * camera that uses those.
61 */
63{
64 /*!
65 * A perfect pinhole camera with no distortion.
66 */
68
69 /*!
70 * OpenCV's radial-tangential distortion model. Exactly equivalent to the distortion model from OpenCV's calib3d
71 * module with just the first five parameters. This may be reinterpreted as RT8 with the last three parameters
72 * zeroed out, which is 100% valid and results in exactly equivalent (un)projections.
73 *
74 * Parameters:
75 *
76 * \f[(k_1, k_2, p_1, p_2, k_3)\f]
77 */
79
80 /*!
81 * OpenCV's radial-tangential distortion model. Exactly equivalent to the distortion model from OpenCV's calib3d
82 * module, with just the first 8 parameters.
83 * Parameters:
84 *
85 * \f[(k_1, k_2, p_1, p_2, k_3, k_4, k_5, k_6)\f]
86 */
88
89 /*!
90 * OpenCV's radial-tangential distortion model. Exactly equivalent to the distortion model from OpenCV's calib3d
91 * module, with all 14 parameters.
92 *
93 * In practice this is reinterpreted as RT8 because the last 6 parameters are almost always approximately 0.
94 *
95 * @todo Feel free to implement RT14 (un)projection functions if you have a camera that actually has a tilted
96 * sensor.
97 *
98 * Parameters:
99 *
100 * \f[(k_1, k_2, p_1, p_2, k_3, k_4, k_5, k_6, s_1, s_2, s_3, s_4, \tau_x, \tau_y)\f]
101 *
102 * All known factory-calibrated Luxonis cameras use this distortion model, and in all known cases their last 6
103 * parameters are approximately 0.
104 *
105 */
107
108 /*!
109 * Juho Kannalla and Sami Sebastian Brandt's fisheye distortion model. Exactly equivalent to the distortion
110 * model from OpenCV's calib3d/fisheye module.
111 *
112 * Parameters:
113 *
114 * \f[(k_1, k_2, k_3, k_4)\f]
115 *
116 * Many cameras use this model. Here's a non-exhaustive list of cameras Monado knows about that fall under this
117 * model:
118 * * Intel T265
119 * * Valve Index
120 */
122
123 /*!
124 * Windows Mixed Reality headsets' camera model.
125 *
126 * The model is listed as CALIBRATION_LensDistortionModelRational6KT in the WMR json files, which seems to be
127 * equivalent to Azure-Kinect-Sensor-SDK's K4A_CALIBRATION_LENS_DISTORTION_MODEL_RATIONAL_6KT.
128 *
129 * The only difference between this model and RT8 are codx, cody, and the way p1 and p2 are interpreted. In
130 * practice we reinterpret this as RT8 because those values are almost always approximately 0 for WMR headsets.
131 *
132 * Parameters:
133 *
134 * \f[(k_1, k_2, p_1, p_2, k_3, k_4, k_5, k_6, cod_x, cod_y, rpmax)\f]
135 */
137
138 /*!
139 * The Oculus Rift CV1 constellation sensor's lens model (LensModel "type 6" in Oculus'
140 * runtime). Despite superficially resembling Kannala-Brandt, it is a distinct model: the
141 * normalized image radius @p r is used *directly* as the field angle and passed through
142 * @p tan, rather than KB's \f$\theta = \operatorname{atan}(r)\f$. It also carries tangential
143 * decentering and a 4th-order affine gain on that decentering, which KB4 lacks.
144 *
145 * Parameters:
146 *
147 * \f[(k_1, k_2, k_3, k_4, p_1, p_2, g_3, g_4)\f]
148 */
150};
151
152
153/*!
154 * Stringifies a @ref t_camera_distortion_model
155 * @param model The distortion model to be stringified
156 * @return The distortion model as a string
157 */
158static inline const char *
160{
161 switch (model) {
162 case T_DISTORTION_PINHOLE: return "T_DISTORTION_PINHOLE"; break;
163 case T_DISTORTION_OPENCV_RADTAN_5: return "T_DISTORTION_OPENCV_RADTAN_5"; break;
164 case T_DISTORTION_OPENCV_RADTAN_8: return "T_DISTORTION_OPENCV_RADTAN_8"; break;
165 case T_DISTORTION_OPENCV_RADTAN_14: return "T_DISTORTION_OPENCV_RADTAN_14"; break;
166 case T_DISTORTION_WMR: return "T_DISTORTION_WMR"; break;
167 case T_DISTORTION_FISHEYE_KB4: return "T_DISTORTION_FISHEYE_KB4"; break;
168 case T_DISTORTION_RIFT_CV1: return "T_DISTORTION_RIFT_CV1"; break;
169 default: U_LOG_E("Invalid distortion_model! %d", model); return "INVALID";
170 }
171}
172
173/*!
174 * Returns the number of parameters needed for this @ref t_camera_distortion_model to be held by an OpenCV Mat and
175 * correctly interpreted by OpenCV's (un)projection functions.
176 *
177 * @param model The distortion model in question
178 * @return The number of distortion coefficients, or 0 if this model cannot be represented inside OpenCV.
179 */
180static inline size_t
182{
183 switch (model) {
184 case T_DISTORTION_PINHOLE: return 0; break;
185 case T_DISTORTION_OPENCV_RADTAN_5: return 5; break;
186 case T_DISTORTION_OPENCV_RADTAN_8: return 8; break;
187 case T_DISTORTION_OPENCV_RADTAN_14: return 14; break;
188 case T_DISTORTION_WMR: return 11; break;
189 case T_DISTORTION_FISHEYE_KB4: return 4; break;
190 case T_DISTORTION_RIFT_CV1: return 8; break; // k1..k4, p1, p2, g3, g4
191 default: U_LOG_E("Invalid distortion_model! %d", model); return 0;
192 }
193}
194
195static inline bool
196t_camera_distortion_model_is_fisheye(enum t_camera_distortion_model model)
197{
198 switch (model) {
200 case T_DISTORTION_RIFT_CV1: return true;
205 case T_DISTORTION_WMR: return false;
206 default: U_LOG_E("Invalid distortion_model! %d", model); return false;
207 }
208}
209
210/*!
211 * Parameters for @ref T_DISTORTION_OPENCV_RADTAN_5
212 * @ingroup aux_tracking
213 */
215{
216 double k1, k2, p1, p2, k3;
217};
218
219/*!
220 * Parameters for @ref T_DISTORTION_OPENCV_RADTAN_8
221 * @ingroup aux_tracking
222 */
224{
225 double k1, k2, p1, p2, k3, k4, k5, k6;
226};
227
228/*!
229 * Parameters for @ref T_DISTORTION_OPENCV_RADTAN_14
230 * @ingroup aux_tracking
231 */
233{
234 double k1, k2, p1, p2, k3, k4, k5, k6, s1, s2, s3, s4, tx, ty;
235};
236
237/*!
238 * Parameters for @ref T_DISTORTION_FISHEYE_KB4
239 * @ingroup aux_tracking
240 */
242{
243 double k1, k2, k3, k4;
244};
245
246/*!
247 * Parameters for @ref T_DISTORTION_WMR
248 * @ingroup aux_tracking
249 */
251{
252 double k1, k2, p1, p2, k3, k4, k5, k6, codx, cody, rpmax;
253};
254
255/*!
256 * Parameters for @ref T_DISTORTION_RIFT_CV1
257 * @ingroup aux_tracking
258 */
260{
261 double k1, k2, k3, k4, p1, p2, g3, g4;
262};
263
264/*!
265 * @brief Essential calibration data for a single camera, or single lens/sensor
266 * of a stereo camera.
267 */
269{
270 //! Source image size
272
273 //! Camera intrinsics matrix
274 double intrinsics[3][3];
275
276 union {
283 double distortion_parameters_as_array[XRT_DISTORTION_MAX_DIM];
284 };
285
286 //! Distortion model that this camera uses.
288};
289
290/*!
291 * Stereo camera calibration data to be given to trackers.
292 */
294{
295 //! Ref counting
297
298 //! Calibration of individual views/sensor
300
301 //! Translation from first to second in the stereo pair.
303 //! Rotation matrix from first to second in the stereo pair.
304 double camera_rotation[3][3];
305
306 //! Essential matrix.
307 double camera_essential[3][3];
308 //! Fundamental matrix.
309 double camera_fundamental[3][3];
310};
311
312/*!
313 * Allocates a new stereo calibration data, unreferences the old data pointed to by @p out_c.
314 *
315 * @public @memberof t_stereo_camera_calibration
316 */
317void
318t_stereo_camera_calibration_alloc(struct t_stereo_camera_calibration **out_c,
320
321/*!
322 * Only to be called by @p t_stereo_camera_calibration_reference.
323 *
324 * @private @memberof t_stereo_camera_calibration
325 */
326void
327t_stereo_camera_calibration_destroy(struct t_stereo_camera_calibration *c);
328
329/*!
330 * Update the reference counts on a stereo calibration data(s).
331 *
332 * @param[in,out] dst Pointer to a object reference: if the object reference is
333 * non-null will decrement its counter. The reference that
334 * @p dst points to will be set to @p src.
335 * @param[in] src New object for @p dst to refer to (may be null).
336 * If non-null, will have its refcount increased.
337 *
338 * @relates t_stereo_camera_calibration
339 */
340static inline void
342{
343 struct t_stereo_camera_calibration *old_dst = *dst;
344
345 if (old_dst == src) {
346 return;
347 }
348
349 if (src) {
350 xrt_reference_inc(&src->reference);
351 }
352
353 *dst = src;
354
355 if (old_dst) {
356 if (xrt_reference_dec_and_is_zero(&old_dst->reference)) {
357 t_stereo_camera_calibration_destroy(old_dst);
358 }
359 }
360}
361
362/*!
363 * Small helper function that dumps one camera calibration data to logging.
364 *
365 * @relates t_camera_calibration
366 */
367void
368t_camera_calibration_dump(struct t_camera_calibration *c);
369
370/*!
371 * Small helper function that dumps the stereo calibration data to logging.
372 *
373 * @relates t_stereo_camera_calibration
374 */
375void
377
378/*!
379 * Load stereo calibration data from a given file in v1 format (binary).
380 *
381 * @relates t_stereo_camera_calibration
382 */
383bool
384t_stereo_camera_calibration_load_v1(FILE *calib_file, struct t_stereo_camera_calibration **out_data);
385
386/*!
387 * Save the given stereo calibration data to the given file in v1 format (binary).
388 *
389 * @relates t_stereo_camera_calibration
390 */
391bool
393
394/*!
395 * Parse the json object in v2 format into stereo calibration data.
396 *
397 * @relates t_stereo_camera_calibration
398 */
399bool
401
402/*!
403 * Convert the given stereo calibration data into a json object in v2 format.
404 *
405 * @relates t_stereo_camera_calibration
406 */
407bool
409
410
411/*!
412 * Load stereo calibration data from a given file path.
413 *
414 * @relates t_stereo_camera_calibration
415 */
416bool
417t_stereo_camera_calibration_load(const char *calib_path, struct t_stereo_camera_calibration **out_data);
418
419/*!
420 * Save the given stereo calibration data to the given file path.
421 *
422 * @relates t_stereo_camera_calibration
423 */
424bool
425t_stereo_camera_calibration_save(const char *calib_path, struct t_stereo_camera_calibration *data);
426
427
428/*
429 *
430 * IMU calibration data.
431 *
432 */
433
434/*!
435 * @brief Parameters for accelerometer and gyroscope calibration.
436 * @see slam_tracker::imu_calibration for a more detailed description and references.
437 */
439{
440 //! Linear transformation for raw measurements alignment and scaling.
441 double transform[3][3];
442
443 //! Offset to apply to raw measurements.
444 double offset[3];
445
446 //! Modeled sensor bias. @see slam_tracker::imu_calibration.
447 double bias_std[3];
448
449 //! Modeled measurement noise. @see slam_tracker::imu_calibration.
450 double noise_std[3];
451};
452
453/*!
454 * @brief Combined IMU calibration data.
455 */
457{
458 //! Accelerometer calibration data.
460
461 //! Gyroscope calibration data.
463};
464/*!
465 * Prints a @ref t_inertial_calibration struct
466 *
467 * @relates t_camera_calibration
468 */
469void
470t_inertial_calibration_dump(struct t_inertial_calibration *c);
471
472/*!
473 * Small helper function that dumps the imu calibration data to logging.
474 *
475 * @relates t_camera_calibration
476 */
477void
478t_imu_calibration_dump(struct t_imu_calibration *c);
479
480
481/*
482 *
483 * Conversion functions.
484 *
485 */
486
488{
489 uint8_t v[256][256][256][3]; // nolint(readability-magic-numbers)
490};
491
492void
493t_convert_fill_table(struct t_convert_table *t);
494
495void
496t_convert_make_y8u8v8_to_r8g8b8(struct t_convert_table *t);
497
498void
499t_convert_make_y8u8v8_to_h8s8v8(struct t_convert_table *t);
500
501void
502t_convert_make_h8s8v8_to_r8g8b8(struct t_convert_table *t);
503
504void
505t_convert_in_place_y8u8v8_to_r8g8b8(uint32_t width, uint32_t height, size_t stride, void *data_ptr);
506
507void
508t_convert_in_place_y8u8v8_to_h8s8v8(uint32_t width, uint32_t height, size_t stride, void *data_ptr);
509
510void
511t_convert_in_place_h8s8v8_to_r8g8b8(uint32_t width, uint32_t height, size_t stride, void *data_ptr);
512
513
514/*
515 *
516 * Filter functions.
517 *
518 */
519
520#define T_HSV_SIZE 32
521#define T_HSV_STEP (256 / T_HSV_SIZE)
522
523#define T_HSV_DEFAULT_PARAMS() \
524 { \
525 { \
526 {165, 30, 160, 100}, \
527 {135, 30, 160, 100}, \
528 {95, 30, 160, 100}, \
529 }, \
530 {128, 80}, \
531 }
532
534{
535 uint8_t hue_min;
536 uint8_t hue_range;
537
538 uint8_t s_min;
539
540 uint8_t v_min;
541};
542
543/*!
544 * Parameters for constructing an HSV filter.
545 * @relates t_hsv_filter
546 */
548{
549 struct t_hsv_filter_color color[3];
550
551 struct
552 {
553 uint8_t s_max;
554 uint8_t v_min;
555 } white;
556};
557
559{
560 uint8_t v[256][256][256];
561};
562
564{
565 uint8_t v[T_HSV_SIZE][T_HSV_SIZE][T_HSV_SIZE];
566};
567
568void
569t_hsv_build_convert_table(struct t_hsv_filter_params *params, struct t_convert_table *t);
570
571void
572t_hsv_build_large_table(struct t_hsv_filter_params *params, struct t_hsv_filter_large_table *t);
573
574void
575t_hsv_build_optimized_table(struct t_hsv_filter_params *params, struct t_hsv_filter_optimized_table *t);
576
577static inline uint8_t
578t_hsv_filter_sample(struct t_hsv_filter_optimized_table *t, uint32_t y, uint32_t u, uint32_t v)
579{
580 return t->v[y / T_HSV_STEP][u / T_HSV_STEP][v / T_HSV_STEP];
581}
582
583/*!
584 * Construct an HSV filter sink.
585 * @public @memberof t_hsv_filter
586 *
587 * @see xrt_frame_context
588 */
589int
590t_hsv_filter_create(struct xrt_frame_context *xfctx,
591 struct t_hsv_filter_params *params,
592 struct xrt_frame_sink *sinks[4],
593 struct xrt_frame_sink **out_sink);
594
595
596/*
597 *
598 * Tracker code.
599 *
600 */
601
602/*!
603 * @public @memberof xrt_tracked_psmv
604 */
605int
606t_psmv_start(struct xrt_tracked_psmv *xtmv);
607
608/*!
609 * @public @memberof xrt_tracked_psmv
610 */
611int
612t_psmv_create(struct xrt_frame_context *xfctx,
613 struct xrt_colour_rgb_f32 *rgb,
614 struct t_stereo_camera_calibration *data,
615 struct xrt_tracked_psmv **out_xtmv,
616 struct xrt_frame_sink **out_sink);
617
618/*!
619 * @public @memberof xrt_tracked_psvr
620 */
621int
622t_psvr_start(struct xrt_tracked_psvr *xtvr);
623
624/*!
625 * @public @memberof xrt_tracked_psvr
626 */
627int
628t_psvr_create(struct xrt_frame_context *xfctx,
629 struct t_stereo_camera_calibration *data,
630 struct xrt_tracked_psvr **out_xtvr,
631 struct xrt_frame_sink **out_sink);
632
633
634
635/*!
636 * SLAM prediction type. Naming scheme as follows:
637 * P: position, O: orientation, A: angular velocity, L: linear velocity
638 * S: From SLAM poses (slow, precise), I: From IMU data (fast, noisy)
639 *
640 * @see xrt_tracked_slam
641 */
643{
644 SLAM_PRED_NONE = 0, //!< No prediction, always return the last SLAM tracked pose
645 SLAM_PRED_POSE_ONLY, //!< Predicts from last two SLAM poses only
646 SLAM_PRED_GYRO, //!< Predicts from last SLAM pose with angular velocity computed from IMU
647 SLAM_PRED_ACCEL_GYRO, //!< Predicts from last SLAM pose with angular and linear velocity computed from IMU
648 SLAM_PRED_DEAD_RECKONING, //!< Predicts from a pose that is the last SLAM pose with the IMU samples that came
649 //!< after it integrated on top; velocities from latest IMU sample.
650 SLAM_PRED_COUNT,
651};
652
653/*!
654 * Extension to camera calibration for SLAM tracking
655 *
656 * @see xrt_tracked_slam
657 */
659{
660 struct t_camera_calibration base;
661 struct xrt_matrix_4x4 T_imu_cam; //!< Transform IMU to camera. Column major.
662 double frequency; //!< Camera FPS
663};
664
665/*!
666 * Extension to IMU calibration for SLAM tracking
667 *
668 * @see xrt_tracked_slam
669 */
671{
672 struct t_imu_calibration base;
673 double frequency;
674};
675
676/*!
677 * Calibration information necessary for SLAM tracking.
678 *
679 * @see xrt_tracked_slam
680 */
682{
683 struct t_slam_imu_calibration imu; //!< IMU calibration data
684 struct t_slam_camera_calibration cams[XRT_TRACKING_MAX_CAMS]; //!< Calib data of `cam_count` cams
685 int cam_count; //!< Number of cameras
686};
687
688/*!
689 * SLAM tracker configuration.
690 *
691 * @see xrt_tracked_slam
692 */
694{
695 enum u_logging_level log_level; //!< SLAM tracking logging level
696 const char *vit_system_library_path; //!< Path to the VIT system library
697 const char *slam_config; //!< Config file path, format is specific to the SLAM implementation in use
698 int cam_count; //!< Number of cameras in use
699 bool slam_ui; //!< Whether to open the external UI of the external SLAM system
700 bool submit_from_start; //!< Whether to submit data to the SLAM tracker without user action
701 int openvr_groundtruth_device; //!< If >0, use lighthouse as groundtruth, see @ref openvr_device
702 enum t_slam_prediction_type prediction; //!< Which level of prediction to use
703 bool write_csvs; //!< Whether to enable CSV writers from the start for later analysis
704 const char *csv_path; //!< Path to write CSVs to
705 bool timing_stat; //!< Enable timing metric in external system
706 bool features_stat; //!< Enable feature metric in external system
707
708 //!< Instead of a slam_config file you can set custom calibration data
709 const struct t_slam_calibration *slam_calib;
710};
711
712/*!
713 * Fills in a @ref t_slam_tracker_config with default values.
714 *
715 * @see xrt_tracked_Slam
716 */
717void
719
720/*!
721 * @public @memberof xrt_tracked_slam
722 */
723int
724t_slam_create(struct xrt_frame_context *xfctx,
725 struct t_slam_tracker_config *config,
726 struct xrt_tracked_slam **out_xts,
727 struct xrt_slam_sinks **out_sink);
728
729/*!
730 * @public @memberof xrt_tracked_slam
731 */
732int
733t_slam_start(struct xrt_tracked_slam *xts);
734
735/*
736 *
737 * Camera calibration
738 *
739 */
740
741/*!
742 * Board pattern type.
743 */
745{
746 T_BOARD_CHECKERS,
747 //! Sector based checker board, using `cv::findChessboardCornersSB`.
749 T_BOARD_CIRCLES,
750 T_BOARD_ASYMMETRIC_CIRCLES,
751};
752
754{
755 //! Is calibration finished?
757 //! Was the target found this frame?
758 bool found;
759 //! Number of frames collected
761 //! Number of moving frames before another capture
763 //! Number of non-moving frames before capture.
765 //! Stereo calibration data that was produced.
767};
768
770{
771 //! Should we use fisheye version of the calibration functions.
773 //! Is the camera a stereo sbs camera, mostly for image loading.
775 //! What type of pattern are we using for calibration.
777
778 struct
779 {
780 int cols;
781 int rows;
782 float size_meters;
783
784 bool subpixel_enable;
785 int subpixel_size;
786 } checkers;
787
788 struct
789 {
790 int cols;
791 int rows;
792 float size_meters;
793
794 bool marker;
795 bool normalize_image;
796 } sb_checkers;
797
798 struct
799 {
800 int cols;
801 int rows;
802 float distance_meters;
803 } circles;
804
805 struct
806 {
807 int cols;
808 int rows;
809 float diagonal_distance_meters;
810 } asymmetric_circles;
811
812 struct
813 {
814 bool enabled;
815 int num_images;
816 } load;
817
818 int num_cooldown_frames;
819 int num_wait_for;
820 int num_collect_total;
821 int num_collect_restart;
822
823 /*!
824 * Should we mirror the RGB image?
825 *
826 * Before text is written out, has no effect on actual image capture.
827 */
829
830 bool save_images;
831};
832
833/*!
834 * Sets the calibration parameters to the their default values.
835 * @public @memberof t_calibration_params
836 */
837void
838t_calibration_gui_params_default(struct t_calibration_params *p);
839
840void
841t_calibration_gui_params_load_or_default(struct t_calibration_params *p);
842
843void
844t_calibration_gui_params_to_json(cJSON **out_json, struct t_calibration_params *p);
845
846void
847t_calibration_gui_params_parse_from_json(const cJSON *params, struct t_calibration_params *p);
848
849/*!
850 * @brief Create the camera calibration frame sink.
851 *
852 * @param xfctx Context for frame transport.
853 * @param params Parameters to use during calibration. Values copied, pointer
854 * not retained.
855 * @param status Optional pointer to structure for status information. Pointer
856 * retained, and pointed-to struct modified.
857 * @param gui Frame sink
858 * @param out_sink Output: created frame sink.
859 *
860 * @see xrt_frame_context
861 */
862int
864 const struct t_calibration_params *params,
865 struct t_calibration_status *status,
866 struct xrt_frame_sink *gui,
867 struct xrt_frame_sink **out_sink);
868
869
870/*
871 *
872 * Sink creation functions.
873 *
874 */
875
876/*!
877 * @see xrt_frame_context
878 */
879int
881
882
883
884/*!
885 * @see xrt_frame_context
886 */
887int
889 struct xrt_frame_sink *passthrough,
890 struct xrt_frame_sink **out_sink);
891
892/*!
893 * @see xrt_frame_context
894 */
895int
897 struct xrt_frame_sink *passthrough,
898 struct xrt_frame_sink **out_sink);
899
900/*!
901 * @see xrt_frame_context
902 */
903int
905 struct xrt_frame_sink *passthrough,
906 struct xrt_frame_sink **out_sink);
907
908/*!
909 * @}
910 */
911
912
913#ifdef __cplusplus
914}
915#endif
u_logging_level
Logging level enum.
Definition u_logging.h:45
#define U_LOG_E(...)
Log a message at U_LOGGING_ERROR level, conditional on the global log level.
Definition u_logging.h:442
t_board_pattern
Board pattern type.
Definition t_tracking.h:745
t_slam_prediction_type
SLAM prediction type.
Definition t_tracking.h:643
void t_slam_fill_default_config(struct t_slam_tracker_config *config)
Fills in a t_slam_tracker_config with default values.
Definition t_tracker_slam.cpp:1419
int t_convert_yuv_or_yuyv_create(struct xrt_frame_sink *next, struct xrt_frame_sink **out_sink)
bool t_stereo_camera_calibration_save_v1(FILE *calib_file, struct t_stereo_camera_calibration *data)
Save the given stereo calibration data to the given file in v1 format (binary).
Definition t_file.cpp:507
bool t_stereo_camera_calibration_load_v1(FILE *calib_file, struct t_stereo_camera_calibration **out_data)
Load stereo calibration data from a given file in v1 format (binary).
Definition t_file.cpp:227
int t_debug_hsv_filter_create(struct xrt_frame_context *xfctx, struct xrt_frame_sink *passthrough, struct xrt_frame_sink **out_sink)
Definition t_debug_hsv_filter.cpp:107
static const char * t_stringify_camera_distortion_model(const enum t_camera_distortion_model model)
Stringifies a t_camera_distortion_model.
Definition t_tracking.h:159
#define XRT_DISTORTION_MAX_DIM
Maximum size of rectilinear distortion coefficient array.
Definition t_tracking.h:54
bool t_stereo_camera_calibration_to_json_v2(cJSON **out_cjson, struct t_stereo_camera_calibration *data)
Convert the given stereo calibration data into a json object in v2 format.
Definition t_file.cpp:606
static size_t t_num_params_from_distortion_model(const enum t_camera_distortion_model model)
Returns the number of parameters needed for this t_camera_distortion_model to be held by an OpenCV Ma...
Definition t_tracking.h:181
bool t_stereo_camera_calibration_load(const char *calib_path, struct t_stereo_camera_calibration **out_data)
Load stereo calibration data from a given file path.
Definition t_file.cpp:811
int t_debug_hsv_viewer_create(struct xrt_frame_context *xfctx, struct xrt_frame_sink *passthrough, struct xrt_frame_sink **out_sink)
Definition t_debug_hsv_viewer.cpp:168
void t_stereo_camera_calibration_dump(struct t_stereo_camera_calibration *c)
Small helper function that dumps the stereo calibration data to logging.
Definition t_data_utils.c:138
bool t_stereo_camera_calibration_save(const char *calib_path, struct t_stereo_camera_calibration *data)
Save the given stereo calibration data to the given file path.
Definition t_file.cpp:818
int t_debug_hsv_picker_create(struct xrt_frame_context *xfctx, struct xrt_frame_sink *passthrough, struct xrt_frame_sink **out_sink)
Definition t_debug_hsv_picker.cpp:219
static void t_stereo_camera_calibration_reference(struct t_stereo_camera_calibration **dst, struct t_stereo_camera_calibration *src)
Update the reference counts on a stereo calibration data(s).
Definition t_tracking.h:341
int t_calibration_stereo_create(struct xrt_frame_context *xfctx, const struct t_calibration_params *params, struct t_calibration_status *status, struct xrt_frame_sink *gui, struct xrt_frame_sink **out_sink)
Create the camera calibration frame sink.
t_camera_distortion_model
The distortion model this camera calibration falls under.
Definition t_tracking.h:63
@ T_BOARD_SB_CHECKERS
Sector based checker board, using cv::findChessboardCornersSB.
Definition t_tracking.h:748
@ SLAM_PRED_POSE_ONLY
Predicts from last two SLAM poses only.
Definition t_tracking.h:645
@ SLAM_PRED_ACCEL_GYRO
Predicts from last SLAM pose with angular and linear velocity computed from IMU.
Definition t_tracking.h:647
@ SLAM_PRED_DEAD_RECKONING
Predicts from a pose that is the last SLAM pose with the IMU samples that came after it integrated on...
Definition t_tracking.h:648
@ SLAM_PRED_NONE
No prediction, always return the last SLAM tracked pose.
Definition t_tracking.h:644
@ SLAM_PRED_GYRO
Predicts from last SLAM pose with angular velocity computed from IMU.
Definition t_tracking.h:646
@ T_DISTORTION_OPENCV_RADTAN_8
OpenCV's radial-tangential distortion model.
Definition t_tracking.h:87
@ T_DISTORTION_OPENCV_RADTAN_5
OpenCV's radial-tangential distortion model.
Definition t_tracking.h:78
@ T_DISTORTION_FISHEYE_KB4
Juho Kannalla and Sami Sebastian Brandt's fisheye distortion model.
Definition t_tracking.h:121
@ T_DISTORTION_WMR
Windows Mixed Reality headsets' camera model.
Definition t_tracking.h:136
@ T_DISTORTION_OPENCV_RADTAN_14
OpenCV's radial-tangential distortion model.
Definition t_tracking.h:106
@ T_DISTORTION_RIFT_CV1
The Oculus Rift CV1 constellation sensor's lens model (LensModel "type 6" in Oculus' runtime).
Definition t_tracking.h:149
@ T_DISTORTION_PINHOLE
A perfect pinhole camera with no distortion.
Definition t_tracking.h:67
Definition t_tracking.h:770
bool stereo_sbs
Is the camera a stereo sbs camera, mostly for image loading.
Definition t_tracking.h:774
bool use_fisheye
Should we use fisheye version of the calibration functions.
Definition t_tracking.h:772
enum t_board_pattern pattern
What type of pattern are we using for calibration.
Definition t_tracking.h:776
bool mirror_rgb_image
Should we mirror the RGB image?
Definition t_tracking.h:828
Definition t_tracking.h:754
bool finished
Is calibration finished?
Definition t_tracking.h:756
int num_collected
Number of frames collected.
Definition t_tracking.h:760
struct t_stereo_camera_calibration * stereo_data
Stereo calibration data that was produced.
Definition t_tracking.h:766
int waits_remaining
Number of non-moving frames before capture.
Definition t_tracking.h:764
int cooldown
Number of moving frames before another capture.
Definition t_tracking.h:762
bool found
Was the target found this frame?
Definition t_tracking.h:758
Parameters for T_DISTORTION_RIFT_CV1.
Definition t_tracking.h:260
Parameters for T_DISTORTION_FISHEYE_KB4.
Definition t_tracking.h:242
Parameters for T_DISTORTION_OPENCV_RADTAN_14.
Definition t_tracking.h:233
Parameters for T_DISTORTION_OPENCV_RADTAN_5.
Definition t_tracking.h:215
Parameters for T_DISTORTION_OPENCV_RADTAN_8.
Definition t_tracking.h:224
Parameters for T_DISTORTION_WMR.
Definition t_tracking.h:251
Essential calibration data for a single camera, or single lens/sensor of a stereo camera.
Definition t_tracking.h:269
double intrinsics[3][3]
Camera intrinsics matrix.
Definition t_tracking.h:274
struct xrt_size image_size_pixels
Source image size.
Definition t_tracking.h:271
enum t_camera_distortion_model distortion_model
Distortion model that this camera uses.
Definition t_tracking.h:287
Definition t_tracking.h:488
Definition t_tracking.h:534
Definition t_tracking.h:559
Definition t_tracking.h:564
Parameters for constructing an HSV filter.
Definition t_tracking.h:548
Combined IMU calibration data.
Definition t_tracking.h:457
struct t_inertial_calibration accel
Accelerometer calibration data.
Definition t_tracking.h:459
struct t_inertial_calibration gyro
Gyroscope calibration data.
Definition t_tracking.h:462
Parameters for accelerometer and gyroscope calibration.
Definition t_tracking.h:439
double bias_std[3]
Modeled sensor bias.
Definition t_tracking.h:447
double noise_std[3]
Modeled measurement noise.
Definition t_tracking.h:450
double offset[3]
Offset to apply to raw measurements.
Definition t_tracking.h:444
double transform[3][3]
Linear transformation for raw measurements alignment and scaling.
Definition t_tracking.h:441
Calibration information necessary for SLAM tracking.
Definition t_tracking.h:682
struct t_slam_camera_calibration cams[XRT_TRACKING_MAX_CAMS]
Calib data of cam_count cams.
Definition t_tracking.h:684
int cam_count
Number of cameras.
Definition t_tracking.h:685
struct t_slam_imu_calibration imu
IMU calibration data.
Definition t_tracking.h:683
Extension to camera calibration for SLAM tracking.
Definition t_tracking.h:659
struct xrt_matrix_4x4 T_imu_cam
Transform IMU to camera.
Definition t_tracking.h:661
double frequency
Camera FPS.
Definition t_tracking.h:662
Extension to IMU calibration for SLAM tracking.
Definition t_tracking.h:671
SLAM tracker configuration.
Definition t_tracking.h:694
bool features_stat
Enable feature metric in external system.
Definition t_tracking.h:706
bool submit_from_start
Whether to submit data to the SLAM tracker without user action.
Definition t_tracking.h:700
enum t_slam_prediction_type prediction
Which level of prediction to use.
Definition t_tracking.h:702
const char * vit_system_library_path
Path to the VIT system library.
Definition t_tracking.h:696
const char * csv_path
Path to write CSVs to.
Definition t_tracking.h:704
int cam_count
Number of cameras in use.
Definition t_tracking.h:698
int openvr_groundtruth_device
If >0, use lighthouse as groundtruth, see openvr_device.
Definition t_tracking.h:701
enum u_logging_level log_level
SLAM tracking logging level.
Definition t_tracking.h:695
const char * slam_config
Config file path, format is specific to the SLAM implementation in use.
Definition t_tracking.h:697
bool write_csvs
Whether to enable CSV writers from the start for later analysis.
Definition t_tracking.h:703
bool timing_stat
Enable timing metric in external system.
Definition t_tracking.h:705
bool slam_ui
Whether to open the external UI of the external SLAM system.
Definition t_tracking.h:699
Stereo camera calibration data to be given to trackers.
Definition t_tracking.h:294
double camera_essential[3][3]
Essential matrix.
Definition t_tracking.h:307
double camera_translation[3]
Translation from first to second in the stereo pair.
Definition t_tracking.h:302
struct t_camera_calibration view[2]
Calibration of individual views/sensor.
Definition t_tracking.h:299
double camera_rotation[3][3]
Rotation matrix from first to second in the stereo pair.
Definition t_tracking.h:304
double camera_fundamental[3][3]
Fundamental matrix.
Definition t_tracking.h:309
struct xrt_reference reference
Ref counting.
Definition t_tracking.h:296
A 3 element colour with floating point channels.
Definition xrt_defines.h:419
Object used to track all sinks and frame producers in a graph.
Definition xrt_frame.h:108
A object that is sent frames.
Definition xrt_frame.h:58
A tightly packed 4x4 matrix of floats.
Definition xrt_defines.h:607
A base class for reference counted objects.
Definition xrt_defines.h:99
Image size.
Definition xrt_defines.h:457
Container of pointers to sinks that could be used for a SLAM system.
Definition xrt_tracking.h:214
A single tracked PS Move controller, camera and ball are not synced.
Definition xrt_tracking.h:231
A tracked PSVR headset.
Definition xrt_tracking.h:273
An adapter that wraps an external SLAM tracker to provide SLAM tracking.
Definition xrt_tracking.h:307
bool t_stereo_camera_calibration_from_json_v2(cJSON *cjson, struct t_stereo_camera_calibration **out_stereo)
Definition t_file.cpp:435
Basic logging functionality.
Very small misc utils.
Common defines and enums for XRT.
Data frame header.
Header defining the tracking system integration in Monado.