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 * Fills in a basic intrinsics matrix using the standard set of parameters.
292 */
293static inline void
295 struct t_camera_calibration *calibration, double fx, double fy, double cx, double cy)
296{
297 double intrinsics[3][3] = {
298 // clang-format off
299 {fx, 0.0, cx},
300 {0.0, fy, cy},
301 {0.0, 0.0, 1.0},
302 // clang-format on
303 };
304
305 memcpy(calibration->intrinsics, intrinsics, sizeof(intrinsics));
306}
307
308/*!
309 * Stereo camera calibration data to be given to trackers.
310 */
312{
313 //! Ref counting
315
316 //! Calibration of individual views/sensor
318
319 //! Translation from first to second in the stereo pair.
321 //! Rotation matrix from first to second in the stereo pair.
322 double camera_rotation[3][3];
323
324 //! Essential matrix.
325 double camera_essential[3][3];
326 //! Fundamental matrix.
327 double camera_fundamental[3][3];
328};
329
330/*!
331 * Allocates a new stereo calibration data, unreferences the old data pointed to by @p out_c.
332 *
333 * @public @memberof t_stereo_camera_calibration
334 */
335void
336t_stereo_camera_calibration_alloc(struct t_stereo_camera_calibration **out_c,
338
339/*!
340 * Only to be called by @p t_stereo_camera_calibration_reference.
341 *
342 * @private @memberof t_stereo_camera_calibration
343 */
344void
345t_stereo_camera_calibration_destroy(struct t_stereo_camera_calibration *c);
346
347/*!
348 * Update the reference counts on a stereo calibration data(s).
349 *
350 * @param[in,out] dst Pointer to a object reference: if the object reference is
351 * non-null will decrement its counter. The reference that
352 * @p dst points to will be set to @p src.
353 * @param[in] src New object for @p dst to refer to (may be null).
354 * If non-null, will have its refcount increased.
355 *
356 * @relates t_stereo_camera_calibration
357 */
358static inline void
360{
361 struct t_stereo_camera_calibration *old_dst = *dst;
362
363 if (old_dst == src) {
364 return;
365 }
366
367 if (src) {
368 xrt_reference_inc(&src->reference);
369 }
370
371 *dst = src;
372
373 if (old_dst) {
374 if (xrt_reference_dec_and_is_zero(&old_dst->reference)) {
375 t_stereo_camera_calibration_destroy(old_dst);
376 }
377 }
378}
379
380/*!
381 * Small helper function that dumps one camera calibration data to logging.
382 *
383 * @relates t_camera_calibration
384 */
385void
386t_camera_calibration_dump(struct t_camera_calibration *c);
387
388/*!
389 * Small helper function that dumps the stereo calibration data to logging.
390 *
391 * @relates t_stereo_camera_calibration
392 */
393void
395
396/*!
397 * Load stereo calibration data from a given file in v1 format (binary).
398 *
399 * @relates t_stereo_camera_calibration
400 */
401bool
402t_stereo_camera_calibration_load_v1(FILE *calib_file, struct t_stereo_camera_calibration **out_data);
403
404/*!
405 * Save the given stereo calibration data to the given file in v1 format (binary).
406 *
407 * @relates t_stereo_camera_calibration
408 */
409bool
411
412/*!
413 * Parse the json object in v2 format into stereo calibration data.
414 *
415 * @relates t_stereo_camera_calibration
416 */
417bool
419
420/*!
421 * Convert the given stereo calibration data into a json object in v2 format.
422 *
423 * @relates t_stereo_camera_calibration
424 */
425bool
427
428
429/*!
430 * Load stereo calibration data from a given file path.
431 *
432 * @relates t_stereo_camera_calibration
433 */
434bool
435t_stereo_camera_calibration_load(const char *calib_path, struct t_stereo_camera_calibration **out_data);
436
437/*!
438 * Save the given stereo calibration data to the given file path.
439 *
440 * @relates t_stereo_camera_calibration
441 */
442bool
443t_stereo_camera_calibration_save(const char *calib_path, struct t_stereo_camera_calibration *data);
444
445
446/*
447 *
448 * IMU calibration data.
449 *
450 */
451
452/*!
453 * @brief Parameters for accelerometer and gyroscope calibration.
454 * @see slam_tracker::imu_calibration for a more detailed description and references.
455 */
457{
458 //! Linear transformation for raw measurements alignment and scaling.
459 double transform[3][3];
460
461 //! Offset to apply to raw measurements.
462 double offset[3];
463
464 //! Modeled sensor bias. @see slam_tracker::imu_calibration.
465 double bias_std[3];
466
467 //! Modeled measurement noise. @see slam_tracker::imu_calibration.
468 double noise_std[3];
469};
470
471/*!
472 * @brief Combined IMU calibration data.
473 */
475{
476 //! Accelerometer calibration data.
478
479 //! Gyroscope calibration data.
481};
482/*!
483 * Prints a @ref t_inertial_calibration struct
484 *
485 * @relates t_camera_calibration
486 */
487void
488t_inertial_calibration_dump(struct t_inertial_calibration *c);
489
490/*!
491 * Small helper function that dumps the imu calibration data to logging.
492 *
493 * @relates t_camera_calibration
494 */
495void
496t_imu_calibration_dump(struct t_imu_calibration *c);
497
498
499/*
500 *
501 * Conversion functions.
502 *
503 */
504
506{
507 uint8_t v[256][256][256][3]; // nolint(readability-magic-numbers)
508};
509
510void
511t_convert_fill_table(struct t_convert_table *t);
512
513void
514t_convert_make_y8u8v8_to_r8g8b8(struct t_convert_table *t);
515
516void
517t_convert_make_y8u8v8_to_h8s8v8(struct t_convert_table *t);
518
519void
520t_convert_make_h8s8v8_to_r8g8b8(struct t_convert_table *t);
521
522void
523t_convert_in_place_y8u8v8_to_r8g8b8(uint32_t width, uint32_t height, size_t stride, void *data_ptr);
524
525void
526t_convert_in_place_y8u8v8_to_h8s8v8(uint32_t width, uint32_t height, size_t stride, void *data_ptr);
527
528void
529t_convert_in_place_h8s8v8_to_r8g8b8(uint32_t width, uint32_t height, size_t stride, void *data_ptr);
530
531
532/*
533 *
534 * Filter functions.
535 *
536 */
537
538#define T_HSV_SIZE 32
539#define T_HSV_STEP (256 / T_HSV_SIZE)
540
541// @todo Remove this when clang-format is updated in CI
542// clang-format off
543#define T_HSV_DEFAULT_PARAMS() \
544 { \
545 { \
546 {165, 30, 160, 100}, \
547 {135, 30, 160, 100}, \
548 {95, 30, 160, 100}, \
549 }, \
550 {128, 80}, \
551 }
552// clang-format on
553
555{
556 uint8_t hue_min;
557 uint8_t hue_range;
558
559 uint8_t s_min;
560
561 uint8_t v_min;
562};
563
564/*!
565 * Parameters for constructing an HSV filter.
566 * @relates t_hsv_filter
567 */
569{
570 struct t_hsv_filter_color color[3];
571
572 struct
573 {
574 uint8_t s_max;
575 uint8_t v_min;
576 } white;
577};
578
580{
581 uint8_t v[256][256][256];
582};
583
585{
586 uint8_t v[T_HSV_SIZE][T_HSV_SIZE][T_HSV_SIZE];
587};
588
589void
590t_hsv_build_convert_table(struct t_hsv_filter_params *params, struct t_convert_table *t);
591
592void
593t_hsv_build_large_table(struct t_hsv_filter_params *params, struct t_hsv_filter_large_table *t);
594
595void
596t_hsv_build_optimized_table(struct t_hsv_filter_params *params, struct t_hsv_filter_optimized_table *t);
597
598static inline uint8_t
599t_hsv_filter_sample(struct t_hsv_filter_optimized_table *t, uint32_t y, uint32_t u, uint32_t v)
600{
601 return t->v[y / T_HSV_STEP][u / T_HSV_STEP][v / T_HSV_STEP];
602}
603
604/*!
605 * Construct an HSV filter sink.
606 * @public @memberof t_hsv_filter
607 *
608 * @see xrt_frame_context
609 */
610int
611t_hsv_filter_create(struct xrt_frame_context *xfctx,
612 struct t_hsv_filter_params *params,
613 struct xrt_frame_sink *sinks[4],
614 struct xrt_frame_sink **out_sink);
615
616
617/*
618 *
619 * Tracker code.
620 *
621 */
622
623/*!
624 * @public @memberof xrt_tracked_psmv
625 */
626int
627t_psmv_start(struct xrt_tracked_psmv *xtmv);
628
629/*!
630 * @public @memberof xrt_tracked_psmv
631 */
632int
633t_psmv_create(struct xrt_frame_context *xfctx,
634 struct xrt_colour_rgb_f32 *rgb,
635 struct t_stereo_camera_calibration *data,
636 struct xrt_tracked_psmv **out_xtmv,
637 struct xrt_frame_sink **out_sink);
638
639/*!
640 * @public @memberof xrt_tracked_psvr
641 */
642int
643t_psvr_start(struct xrt_tracked_psvr *xtvr);
644
645/*!
646 * @public @memberof xrt_tracked_psvr
647 */
648int
649t_psvr_create(struct xrt_frame_context *xfctx,
650 struct t_stereo_camera_calibration *data,
651 struct xrt_tracked_psvr **out_xtvr,
652 struct xrt_frame_sink **out_sink);
653
654
655
656/*!
657 * SLAM prediction type. Naming scheme as follows:
658 * P: position, O: orientation, A: angular velocity, L: linear velocity
659 * S: From SLAM poses (slow, precise), I: From IMU data (fast, noisy)
660 *
661 * @see xrt_tracked_slam
662 */
664{
665 SLAM_PRED_NONE = 0, //!< No prediction, always return the last SLAM tracked pose
666 SLAM_PRED_POSE_ONLY, //!< Predicts from last two SLAM poses only
667 SLAM_PRED_GYRO, //!< Predicts from last SLAM pose with angular velocity computed from IMU
668 SLAM_PRED_ACCEL_GYRO, //!< Predicts from last SLAM pose with angular and linear velocity computed from IMU
669 SLAM_PRED_DEAD_RECKONING, //!< Predicts from a pose that is the last SLAM pose with the IMU samples that came
670 //!< after it integrated on top; velocities from latest IMU sample.
671 SLAM_PRED_COUNT,
672};
673
674/*!
675 * Extension to camera calibration for SLAM tracking
676 *
677 * @see xrt_tracked_slam
678 */
680{
681 struct t_camera_calibration base;
682 struct xrt_matrix_4x4 T_imu_cam; //!< Transform IMU to camera. Column major.
683 double frequency; //!< Camera FPS
684};
685
686/*!
687 * Extension to IMU calibration for SLAM tracking
688 *
689 * @see xrt_tracked_slam
690 */
692{
693 struct t_imu_calibration base;
694 double frequency;
695};
696
697/*!
698 * Calibration information necessary for SLAM tracking.
699 *
700 * @see xrt_tracked_slam
701 */
703{
704 struct t_slam_imu_calibration imu; //!< IMU calibration data
705 struct t_slam_camera_calibration cams[XRT_TRACKING_MAX_CAMS]; //!< Calib data of `cam_count` cams
706 int cam_count; //!< Number of cameras
707};
708
709/*!
710 * SLAM tracker configuration.
711 *
712 * @see xrt_tracked_slam
713 */
715{
716 enum u_logging_level log_level; //!< SLAM tracking logging level
717 const char *vit_system_library_path; //!< Path to the VIT system library
718 const char *slam_config; //!< Config file path, format is specific to the SLAM implementation in use
719 int cam_count; //!< Number of cameras in use
720 bool slam_ui; //!< Whether to open the external UI of the external SLAM system
721 bool submit_from_start; //!< Whether to submit data to the SLAM tracker without user action
722 int openvr_groundtruth_device; //!< If >0, use lighthouse as groundtruth, see @ref openvr_device
723 enum t_slam_prediction_type prediction; //!< Which level of prediction to use
724 bool write_csvs; //!< Whether to enable CSV writers from the start for later analysis
725 const char *csv_path; //!< Path to write CSVs to
726 bool timing_stat; //!< Enable timing metric in external system
727 bool features_stat; //!< Enable feature metric in external system
728
729 //!< Instead of a slam_config file you can set custom calibration data
730 const struct t_slam_calibration *slam_calib;
731};
732
733/*!
734 * Fills in a @ref t_slam_tracker_config with default values.
735 *
736 * @see xrt_tracked_Slam
737 */
738void
740
741/*!
742 * @public @memberof xrt_tracked_slam
743 */
744int
745t_slam_create(struct xrt_frame_context *xfctx,
746 struct t_slam_tracker_config *config,
747 struct xrt_tracked_slam **out_xts,
748 struct xrt_slam_sinks **out_sink);
749
750/*!
751 * @public @memberof xrt_tracked_slam
752 */
753int
754t_slam_start(struct xrt_tracked_slam *xts);
755
756/*
757 *
758 * Camera calibration
759 *
760 */
761
762/*!
763 * Board pattern type.
764 */
766{
767 T_BOARD_CHECKERS,
768 //! Sector based checker board, using `cv::findChessboardCornersSB`.
770 T_BOARD_CIRCLES,
771 T_BOARD_ASYMMETRIC_CIRCLES,
772};
773
775{
776 //! Is calibration finished?
778 //! Was the target found this frame?
779 bool found;
780 //! Number of frames collected
782 //! Number of moving frames before another capture
784 //! Number of non-moving frames before capture.
786 //! Stereo calibration data that was produced.
788};
789
791{
792 //! Should we use fisheye version of the calibration functions.
794 //! Is the camera a stereo sbs camera, mostly for image loading.
796 //! What type of pattern are we using for calibration.
798
799 struct
800 {
801 int cols;
802 int rows;
803 float size_meters;
804
805 bool subpixel_enable;
806 int subpixel_size;
807 } checkers;
808
809 struct
810 {
811 int cols;
812 int rows;
813 float size_meters;
814
815 bool marker;
816 bool normalize_image;
817 } sb_checkers;
818
819 struct
820 {
821 int cols;
822 int rows;
823 float distance_meters;
824 } circles;
825
826 struct
827 {
828 int cols;
829 int rows;
830 float diagonal_distance_meters;
831 } asymmetric_circles;
832
833 struct
834 {
835 bool enabled;
836 int num_images;
837 } load;
838
839 int num_cooldown_frames;
840 int num_wait_for;
841 int num_collect_total;
842 int num_collect_restart;
843
844 /*!
845 * Should we mirror the RGB image?
846 *
847 * Before text is written out, has no effect on actual image capture.
848 */
850
851 bool save_images;
852};
853
854/*!
855 * Sets the calibration parameters to the their default values.
856 * @public @memberof t_calibration_params
857 */
858void
859t_calibration_gui_params_default(struct t_calibration_params *p);
860
861void
862t_calibration_gui_params_load_or_default(struct t_calibration_params *p);
863
864void
865t_calibration_gui_params_to_json(cJSON **out_json, struct t_calibration_params *p);
866
867void
868t_calibration_gui_params_parse_from_json(const cJSON *params, struct t_calibration_params *p);
869
870/*!
871 * @brief Create the camera calibration frame sink.
872 *
873 * @param xfctx Context for frame transport.
874 * @param params Parameters to use during calibration. Values copied, pointer
875 * not retained.
876 * @param status Optional pointer to structure for status information. Pointer
877 * retained, and pointed-to struct modified.
878 * @param gui Frame sink
879 * @param out_sink Output: created frame sink.
880 *
881 * @see xrt_frame_context
882 */
883int
885 const struct t_calibration_params *params,
886 struct t_calibration_status *status,
887 struct xrt_frame_sink *gui,
888 struct xrt_frame_sink **out_sink);
889
890
891/*
892 *
893 * Sink creation functions.
894 *
895 */
896
897/*!
898 * @see xrt_frame_context
899 */
900int
902
903
904
905/*!
906 * @see xrt_frame_context
907 */
908int
910 struct xrt_frame_sink *passthrough,
911 struct xrt_frame_sink **out_sink);
912
913/*!
914 * @see xrt_frame_context
915 */
916int
918 struct xrt_frame_sink *passthrough,
919 struct xrt_frame_sink **out_sink);
920
921/*!
922 * @see xrt_frame_context
923 */
924int
926 struct xrt_frame_sink *passthrough,
927 struct xrt_frame_sink **out_sink);
928
929/*!
930 * @}
931 */
932
933
934#ifdef __cplusplus
935}
936#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:766
t_slam_prediction_type
SLAM prediction type.
Definition t_tracking.h:664
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:1436
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
static void t_camera_calibration_fill_intrinsics(struct t_camera_calibration *calibration, double fx, double fy, double cx, double cy)
Fills in a basic intrinsics matrix using the standard set of parameters.
Definition t_tracking.h:294
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:359
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:769
@ SLAM_PRED_POSE_ONLY
Predicts from last two SLAM poses only.
Definition t_tracking.h:666
@ SLAM_PRED_ACCEL_GYRO
Predicts from last SLAM pose with angular and linear velocity computed from IMU.
Definition t_tracking.h:668
@ 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:669
@ SLAM_PRED_NONE
No prediction, always return the last SLAM tracked pose.
Definition t_tracking.h:665
@ SLAM_PRED_GYRO
Predicts from last SLAM pose with angular velocity computed from IMU.
Definition t_tracking.h:667
@ 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:791
bool stereo_sbs
Is the camera a stereo sbs camera, mostly for image loading.
Definition t_tracking.h:795
bool use_fisheye
Should we use fisheye version of the calibration functions.
Definition t_tracking.h:793
enum t_board_pattern pattern
What type of pattern are we using for calibration.
Definition t_tracking.h:797
bool mirror_rgb_image
Should we mirror the RGB image?
Definition t_tracking.h:849
Definition t_tracking.h:775
bool finished
Is calibration finished?
Definition t_tracking.h:777
int num_collected
Number of frames collected.
Definition t_tracking.h:781
struct t_stereo_camera_calibration * stereo_data
Stereo calibration data that was produced.
Definition t_tracking.h:787
int waits_remaining
Number of non-moving frames before capture.
Definition t_tracking.h:785
int cooldown
Number of moving frames before another capture.
Definition t_tracking.h:783
bool found
Was the target found this frame?
Definition t_tracking.h:779
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:506
Definition t_tracking.h:555
Definition t_tracking.h:580
Definition t_tracking.h:585
Parameters for constructing an HSV filter.
Definition t_tracking.h:569
Combined IMU calibration data.
Definition t_tracking.h:475
struct t_inertial_calibration accel
Accelerometer calibration data.
Definition t_tracking.h:477
struct t_inertial_calibration gyro
Gyroscope calibration data.
Definition t_tracking.h:480
Parameters for accelerometer and gyroscope calibration.
Definition t_tracking.h:457
double bias_std[3]
Modeled sensor bias.
Definition t_tracking.h:465
double noise_std[3]
Modeled measurement noise.
Definition t_tracking.h:468
double offset[3]
Offset to apply to raw measurements.
Definition t_tracking.h:462
double transform[3][3]
Linear transformation for raw measurements alignment and scaling.
Definition t_tracking.h:459
Calibration information necessary for SLAM tracking.
Definition t_tracking.h:703
struct t_slam_camera_calibration cams[XRT_TRACKING_MAX_CAMS]
Calib data of cam_count cams.
Definition t_tracking.h:705
int cam_count
Number of cameras.
Definition t_tracking.h:706
struct t_slam_imu_calibration imu
IMU calibration data.
Definition t_tracking.h:704
Extension to camera calibration for SLAM tracking.
Definition t_tracking.h:680
struct xrt_matrix_4x4 T_imu_cam
Transform IMU to camera.
Definition t_tracking.h:682
double frequency
Camera FPS.
Definition t_tracking.h:683
Extension to IMU calibration for SLAM tracking.
Definition t_tracking.h:692
SLAM tracker configuration.
Definition t_tracking.h:715
bool features_stat
Enable feature metric in external system.
Definition t_tracking.h:727
bool submit_from_start
Whether to submit data to the SLAM tracker without user action.
Definition t_tracking.h:721
enum t_slam_prediction_type prediction
Which level of prediction to use.
Definition t_tracking.h:723
const char * vit_system_library_path
Path to the VIT system library.
Definition t_tracking.h:717
const char * csv_path
Path to write CSVs to.
Definition t_tracking.h:725
int cam_count
Number of cameras in use.
Definition t_tracking.h:719
int openvr_groundtruth_device
If >0, use lighthouse as groundtruth, see openvr_device.
Definition t_tracking.h:722
enum u_logging_level log_level
SLAM tracking logging level.
Definition t_tracking.h:716
const char * slam_config
Config file path, format is specific to the SLAM implementation in use.
Definition t_tracking.h:718
bool write_csvs
Whether to enable CSV writers from the start for later analysis.
Definition t_tracking.h:724
bool timing_stat
Enable timing metric in external system.
Definition t_tracking.h:726
bool slam_ui
Whether to open the external UI of the external SLAM system.
Definition t_tracking.h:720
Stereo camera calibration data to be given to trackers.
Definition t_tracking.h:312
double camera_essential[3][3]
Essential matrix.
Definition t_tracking.h:325
double camera_translation[3]
Translation from first to second in the stereo pair.
Definition t_tracking.h:320
struct t_camera_calibration view[2]
Calibration of individual views/sensor.
Definition t_tracking.h:317
double camera_rotation[3][3]
Rotation matrix from first to second in the stereo pair.
Definition t_tracking.h:322
double camera_fundamental[3][3]
Fundamental matrix.
Definition t_tracking.h:327
struct xrt_reference reference
Ref counting.
Definition t_tracking.h:314
A 3 element colour with floating point channels.
Definition xrt_defines.h:428
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:616
A base class for reference counted objects.
Definition xrt_defines.h:99
Image size.
Definition xrt_defines.h:466
Container of pointers to sinks that could be used for a SLAM system.
Definition xrt_tracking.h:217
A single tracked PS Move controller, camera and ball are not synced.
Definition xrt_tracking.h:236
A tracked PSVR headset.
Definition xrt_tracking.h:278
An adapter that wraps an external SLAM tracker to provide SLAM tracking.
Definition xrt_tracking.h:312
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.