Monado OpenXR Runtime
Loading...
Searching...
No Matches
pose_metrics.h
Go to the documentation of this file.
1// Copyright 2020-2023 Jan Schmidt
2// Copyright 2025-2026 Beyley Cardellio
3// SPDX-License-Identifier: BSL-1.0
4/*!
5 * @file
6 * @brief Metrics for constellation tracking poses
7 * @author Jan Schmidt <jan@centricular.com>
8 * @author Beyley Cardellio <ep1cm1n10n123@gmail.com>
9 * @ingroup tracking
10 */
11
12#pragma once
13
14#include "xrt/xrt_defines.h"
16
17#include "camera_model.h"
18
19
20#ifdef __cplusplus
21extern "C" {
22#endif
23
24#define MAX_OBJECT_LEDS 64
25
26#define WORST_REPROJECTION_ERROR 10.0
27
29{
30 double left;
31 double top;
32 double right;
33 double bottom;
34};
35
36XRT_MAYBE_UNUSED static bool
37pose_rect_has_area(struct pose_rect *rect)
38{
39 return rect->left != rect->right && rect->top != rect->bottom;
40}
41
43{
44 //! A reasonable pose match - most LEDs matched to within a few pixels error
46 //! A strong pose match is a match with very low error
48 //! The position of the pose matched the prior well
50 //! The orientation of the pose matched the prior well
52 //! If a pose prior was supplied when calculating the score, then rot/trans_error are set
54 //! The LED IDs on the blobs all matched the LEDs we thought (or were unassigned)
56};
57
58#define POSE_SET_FLAG(score, f) ((score)->match_flags |= (f))
59#define POSE_CLEAR_FLAG(score, f) ((score)->match_flags &= ~(f))
60#define POSE_HAS_FLAGS(score, f) (((score)->match_flags & (f)) == (f))
61
63{
64 enum pose_match_flags match_flags;
65
66 uint32_t matched_blobs;
67 uint32_t unmatched_blobs;
68 uint32_t visible_leds;
69
70 double reprojection_error;
71
72 //! Rotation error (compared to a prior)
74 //! Translation error (compared to a prior)
76};
77
79{
81 double led_radius_px; //< Expected max size of the LED in pixels at that distance
82 struct xrt_vec2 pos_px; //< Projected position of the LED (pixels)
83 struct xrt_vec3 pos_m; //< Projected physical position of the LED (metres)
84 double facing_dot; //< Dot product between LED and camera
85 struct t_blob *matched_blob;
86};
87
89{
90 struct pose_metrics_visible_led_info visible_leds[MAX_OBJECT_LEDS];
91 int num_visible_leds;
92
93 bool all_led_ids_matched;
94 uint32_t matched_blobs;
95 uint32_t unmatched_blobs;
96
97 double reprojection_error;
98 struct pose_rect bounds;
99};
100
101void
102pose_metrics_match_pose_to_blobs(const struct xrt_pose *pose,
103 struct t_blob *blobs,
104 int num_blobs,
105 struct t_constellation_tracker_led_model *led_model,
106 t_constellation_device_id_t device_id,
107 struct camera_model *calib,
108 struct pose_metrics_blob_match_info *match_info);
109
110void
111pose_metrics_evaluate_pose(struct pose_metrics *score,
112 const struct xrt_pose *pose,
113 struct t_blob *blobs,
114 int num_blobs,
115 struct t_constellation_tracker_led_model *leds_model,
116 t_constellation_device_id_t device_id,
117 struct camera_model *calib,
118 struct pose_rect *out_bounds);
119
120void
121pose_metrics_evaluate_pose_with_prior(struct pose_metrics *score,
122 const struct xrt_pose *pose,
123 bool prior_must_match,
124 struct xrt_pose *pose_prior,
125 const struct xrt_vec3 *pos_error_thresh,
126 const struct xrt_vec3 *rot_error_thresh,
127 struct t_blob *blobs,
128 int num_blobs,
129 struct t_constellation_tracker_led_model *led_model,
130 t_constellation_device_id_t device_id,
131 struct camera_model *calib,
132 struct pose_rect *out_bounds);
133
134/*!
135 * Compares whether new_score is a better pose than old_score.
136 *
137 * @param old_score The old score to compare against.
138 * @param new_score The new score to compare against the old score.
139 * @return true if the new score is a better pose than the old score, false otherwise.
140 */
141bool
142pose_metrics_score_is_better_pose(struct pose_metrics *old_score, struct pose_metrics *new_score);
143
144#ifdef __cplusplus
145}
146#endif
Constellation tracker's camera model storage.
pose_match_flags
Definition pose_metrics.h:43
@ POSE_MATCH_LED_IDS
The LED IDs on the blobs all matched the LEDs we thought (or were unassigned)
Definition pose_metrics.h:55
@ POSE_MATCH_ORIENT
The orientation of the pose matched the prior well.
Definition pose_metrics.h:51
@ POSE_HAD_PRIOR
If a pose prior was supplied when calculating the score, then rot/trans_error are set.
Definition pose_metrics.h:53
@ POSE_MATCH_POSITION
The position of the pose matched the prior well.
Definition pose_metrics.h:49
@ POSE_MATCH_GOOD
A reasonable pose match - most LEDs matched to within a few pixels error.
Definition pose_metrics.h:45
@ POSE_MATCH_STRONG
A strong pose match is a match with very low error.
Definition pose_metrics.h:47
bool pose_metrics_score_is_better_pose(struct pose_metrics *old_score, struct pose_metrics *new_score)
Compares whether new_score is a better pose than old_score.
Definition pose_metrics.c:484
Definition camera_model.h:19
Definition pose_metrics.h:89
Definition pose_metrics.h:79
Definition pose_metrics.h:63
struct xrt_vec3 pos_error
Translation error (compared to a prior)
Definition pose_metrics.h:75
struct xrt_vec3 orient_error
Rotation error (compared to a prior)
Definition pose_metrics.h:73
Definition pose_metrics.h:29
A blob is a 2d position in a camera sensor's view that is being tracked.
Definition t_constellation.h:37
The LED model is a series of points which define the real-world positions of all LEDs.
Definition t_constellation.h:266
Definition t_constellation.h:245
A pose composed of a position and orientation.
Definition xrt_defines.h:492
A 2 element vector with single floats.
Definition xrt_defines.h:268
A 3 element vector with single floats.
Definition xrt_defines.h:289
Header defining the tracking system integration in Monado.
Common defines and enums for XRT.