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
27{
28 double left;
29 double top;
30 double right;
31 double bottom;
32};
33
34XRT_MAYBE_UNUSED static bool
35pose_rect_has_area(struct pose_rect *rect)
36{
37 return rect->left != rect->right && rect->top != rect->bottom;
38}
39
41{
42 //! A reasonable pose match - most LEDs matched to within a few pixels error
44 //! A strong pose match is a match with very low error
46 //! The position of the pose matched the prior well
48 //! The orientation of the pose matched the prior well
50 //! If a pose prior was supplied when calculating the score, then rot/trans_error are set
52 //! The LED IDs on the blobs all matched the LEDs we thought (or were unassigned)
54};
55
56#define POSE_SET_FLAG(score, f) ((score)->match_flags |= (f))
57#define POSE_CLEAR_FLAG(score, f) ((score)->match_flags &= ~(f))
58#define POSE_HAS_FLAGS(score, f) (((score)->match_flags & (f)) == (f))
59
61{
62 enum pose_match_flags match_flags;
63
64 int matched_blobs;
65 int unmatched_blobs;
66 int visible_leds;
67
68 double reprojection_error;
69
70 struct xrt_vec3 orient_error; /* Rotation error (compared to a prior) */
71 struct xrt_vec3 pos_error; /* Translation error (compared to a prior) */
72};
73
75{
77 double led_radius_px; /* Expected max size of the LED in pixels at that distance */
78 struct xrt_vec2 pos_px; /* Projected position of the LED (pixels) */
79 struct xrt_vec3 pos_m; /* Projected physical position of the LED (metres) */
80 double facing_dot; /* Dot product between LED and camera */
81 struct t_blob *matched_blob;
82};
83
85{
86 struct pose_metrics_visible_led_info visible_leds[MAX_OBJECT_LEDS];
87 int num_visible_leds;
88
89 bool all_led_ids_matched;
90 int matched_blobs;
91 int unmatched_blobs;
92
93 double reprojection_error;
94 struct pose_rect bounds;
95};
96
97void
98pose_metrics_match_pose_to_blobs(struct xrt_pose *pose,
99 struct t_blob *blobs,
100 int num_blobs,
101 struct t_constellation_tracker_led_model *led_model,
102 t_constellation_device_id_t device_id,
103 struct camera_model *calib,
104 struct pose_metrics_blob_match_info *match_info);
105
106void
107pose_metrics_evaluate_pose(struct pose_metrics *score,
108 struct xrt_pose *pose,
109 struct t_blob *blobs,
110 int num_blobs,
111 struct t_constellation_tracker_led_model *leds_model,
112 t_constellation_device_id_t device_id,
113 struct camera_model *calib,
114 struct pose_rect *out_bounds);
115
116void
117pose_metrics_evaluate_pose_with_prior(struct pose_metrics *score,
118 struct xrt_pose *pose,
119 bool prior_must_match,
120 struct xrt_pose *pose_prior,
121 const struct xrt_vec3 *pos_error_thresh,
122 const struct xrt_vec3 *rot_error_thresh,
123 struct t_blob *blobs,
124 int num_blobs,
125 struct t_constellation_tracker_led_model *led_model,
126 t_constellation_device_id_t device_id,
127 struct camera_model *calib,
128 struct pose_rect *out_bounds);
129
130/*!
131 * Compares whether new_score is a better pose than old_score.
132 *
133 * @param old_score The old score to compare against.
134 * @param new_score The new score to compare against the old score.
135 * @return true if the new score is a better pose than the old score, false otherwise.
136 */
137bool
138pose_metrics_score_is_better_pose(struct pose_metrics *old_score, struct pose_metrics *new_score);
139
140#ifdef __cplusplus
141}
142#endif
Constellation tracker's camera model storage.
pose_match_flags
Definition pose_metrics.h:41
@ POSE_MATCH_LED_IDS
The LED IDs on the blobs all matched the LEDs we thought (or were unassigned)
Definition pose_metrics.h:53
@ POSE_MATCH_ORIENT
The orientation of the pose matched the prior well.
Definition pose_metrics.h:49
@ POSE_HAD_PRIOR
If a pose prior was supplied when calculating the score, then rot/trans_error are set.
Definition pose_metrics.h:51
@ POSE_MATCH_POSITION
The position of the pose matched the prior well.
Definition pose_metrics.h:47
@ POSE_MATCH_GOOD
A reasonable pose match - most LEDs matched to within a few pixels error.
Definition pose_metrics.h:43
@ POSE_MATCH_STRONG
A strong pose match is a match with very low error.
Definition pose_metrics.h:45
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:462
Definition camera_model.h:19
Definition pose_metrics.h:85
Definition pose_metrics.h:75
Definition pose_metrics.h:61
Definition pose_metrics.h:27
A blob is a 2d position in a camera sensor's view that is being tracked.
Definition t_constellation.h:36
The LED model is a series of points which define the real-world positions of all LEDs.
Definition t_constellation.h:259
Definition t_constellation.h:238
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.