Monado OpenXR Runtime
Loading...
Searching...
No Matches
correspondence_search.h
Go to the documentation of this file.
1// Copyright 2020 Jan Schmidt
2// Copyright 2026 Beyley Cardellio
3// SPDX-License-Identifier: BSL-1.0
4/*!
5 * @file
6 * @brief Ab-initio blob<->LED correspondence search
7 * @author Jan Schmidt <jan@centricular.com>
8 * @author Beyley Cardellio <ep1cm1n10n123@gmail.com>
9 * @ingroup tracking
10 */
11
12#pragma once
13
15
16#include "pose_metrics.h"
17#include "camera_model.h"
18
19
20#ifdef __cplusplus
21extern "C" {
22#endif
23
24#define MAX_BLOB_SEARCH_DEPTH 5
25
26//! Lambdatwist can sometimes have spurious failures, the anchor LED must be within 2.5mm to be accepted
27#define ANCHOR_LED_MAX_DISTANCE_M_SQ (0.025 * 0.025)
28
30{
31 CS_FLAG_NONE = 0x0,
32 //! Do quick search @ depth 1-2 neighbour depth
34 //! do deeper searches @ up to MAX_LED_SEARCH_DEPTH/MAX_BLOB_SEARCH_DEPTH
36 //! Stop searching if a strong match is found, otherwise search all and return best match
38 //! Allow matching against all blobs, not just unlabelled ones or for the current device
40 //! If the input obj_cam_pose contains a valid prior
42 //! Use the provided gravity vector to check pose verticality. Depends on CS_FLAG_HAVE_POSE_PRIOR.
44};
45
47{
48 struct t_blob *blob;
49
50 double point_homog[3]; // Homogeneous version of the point
51 double size[2]; // w/h of the blob, in homogeneous coordinates
52 double max_dist; // norm of (W/H) for distance checks
53
54 /* List of the nearest blobs, filtered for the active model */
55 int num_neighbours;
56 struct cs_image_point *neighbours[MAX_BLOB_SEARCH_DEPTH];
57};
58
60{
61 t_constellation_device_id_t id;
62
63 const struct t_constellation_search_model *model;
64
65 double best_pose_found_time; /* Time (in secs) at which the best pose was found */
66 int best_pose_blob_depth; /* Blob neighbor depth the best pose is from */
67 int best_pose_led_depth; /* LED neighbour depth the best pose is from */
68 struct xrt_pose best_pose;
69 enum pose_match_flags match_flags;
70
71 struct pose_metrics best_score;
72
73 /* Search parameters */
74 double search_start_time;
75 int led_depth;
76 int led_index;
77 int blob_index;
78
79 enum correspondence_search_flags search_flags;
80 int min_led_depth, max_led_depth;
81 int max_blob_depth;
82
83 /* Valid when CS_FLAG_HAVE_POSE_PRIOR is set */
84 struct xrt_pose pose_prior;
85 const struct xrt_vec3 *pos_error_thresh;
86 const struct xrt_vec3 *rot_error_thresh;
87
88 /* Used when CS_FLAG_MATCH_GRAVITY is set */
89 struct xrt_vec3 gravity_vector;
90 struct xrt_quat gravity_swing;
91 float gravity_tolerance_rad;
92};
93
95{
96 const enum u_logging_level *ct_log_level;
97
98 int num_points;
99 struct cs_image_point *points;
100 struct t_blob *blobs; /* Original blobs structs [num_points] */
101
102 unsigned int num_trials;
103 unsigned int num_pose_checks;
104
105 struct camera_model *calib;
106
107 /* List of the nearest blobs for each blob */
108 struct cs_image_point
109 *blob_neighbours[XRT_CONSTELLATION_MAX_BLOBS_PER_FRAME][XRT_CONSTELLATION_MAX_BLOBS_PER_FRAME];
110};
111
113correspondence_search_new(const enum u_logging_level *ct_log_level, struct camera_model *camera_calib);
114
115void
116correspondence_search_free(struct correspondence_search *cs);
117
118void
119correspondence_search_set_blobs(struct correspondence_search *cs, struct t_blob *blobs, int num_blobs);
120
121/*!
122 * Does a brute-force search for a device's pose.
123 *
124 * @note The `pose` and `score` parameters are only written on success.
125 */
126bool
128 const struct t_constellation_search_model *model,
129 enum correspondence_search_flags search_flags,
130 struct xrt_pose *inout_pose,
131 const struct xrt_vec3 *pos_error_thresh,
132 const struct xrt_vec3 *rot_error_thresh,
133 const struct xrt_vec3 *gravity_vector,
134 float gravity_tolerance_rad,
135 struct pose_metrics *out_score);
136
137#ifdef __cplusplus
138}
139#endif
Constellation tracker's camera model storage.
bool correspondence_search_find_one_pose(struct correspondence_search *cs, const struct t_constellation_search_model *model, enum correspondence_search_flags search_flags, struct xrt_pose *inout_pose, const struct xrt_vec3 *pos_error_thresh, const struct xrt_vec3 *rot_error_thresh, const struct xrt_vec3 *gravity_vector, float gravity_tolerance_rad, struct pose_metrics *out_score)
Does a brute-force search for a device's pose.
Definition correspondence_search.c:949
correspondence_search_flags
Definition correspondence_search.h:30
@ CS_FLAG_HAVE_POSE_PRIOR
If the input obj_cam_pose contains a valid prior.
Definition correspondence_search.h:41
@ CS_FLAG_STOP_FOR_STRONG_MATCH
Stop searching if a strong match is found, otherwise search all and return best match.
Definition correspondence_search.h:37
@ CS_FLAG_SHALLOW_SEARCH
Do quick search @ depth 1-2 neighbour depth.
Definition correspondence_search.h:33
@ CS_FLAG_DEEP_SEARCH
do deeper searches @ up to MAX_LED_SEARCH_DEPTH/MAX_BLOB_SEARCH_DEPTH
Definition correspondence_search.h:35
@ CS_FLAG_MATCH_GRAVITY
Use the provided gravity vector to check pose verticality. Depends on CS_FLAG_HAVE_POSE_PRIOR.
Definition correspondence_search.h:43
@ CS_FLAG_MATCH_ALL_BLOBS
Allow matching against all blobs, not just unlabelled ones or for the current device.
Definition correspondence_search.h:39
u_logging_level
Logging level enum.
Definition u_logging.h:45
Metrics for constellation tracking poses.
pose_match_flags
Definition pose_metrics.h:48
Definition t_rift_blobwatch.c:51
Definition camera_model.h:19
Definition correspondence_search.h:95
Definition correspondence_search.h:47
Definition correspondence_search.h:60
Definition pose_metrics.h:79
A blob is a 2d position in a camera sensor's view that is being tracked.
Definition t_constellation.h:45
Definition led_search_model.h:40
A pose composed of a position and orientation.
Definition xrt_defines.h:513
A quaternion with single floats.
Definition xrt_defines.h:246
A 3 element vector with single floats.
Definition xrt_defines.h:310
Header defining the tracking system integration in Monado.