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
27{
28 CS_FLAG_NONE = 0x0,
29 //! Do quick search @ depth 1-2 neighbour depth
31 //! do deeper searches @ up to MAX_LED_SEARCH_DEPTH/MAX_BLOB_SEARCH_DEPTH
33 //! Stop searching if a strong match is found, otherwise search all and return best match
35 //! Allow matching against all blobs, not just unlabelled ones or for the current device
37 //! If the input obj_cam_pose contains a valid prior
39 //! Use the provided gravity vector to check pose verticality. Depends on CS_FLAG_HAVE_POSE_PRIOR.
41};
42
44{
45 struct t_blob *blob;
46
47 double point_homog[3]; // Homogeneous version of the point
48 double size[2]; // w/h of the blob, in homogeneous coordinates
49 double max_dist; // norm of (W/H) for distance checks
50
51 /* List of the nearest blobs, filtered for the active model */
52 int num_neighbours;
53 struct cs_image_point *neighbours[MAX_BLOB_SEARCH_DEPTH];
54};
55
57{
58 t_constellation_device_id_t id;
59
60 struct t_constellation_search_model *model;
61
62 double best_pose_found_time; /* Time (in secs) at which the best pose was found */
63 int best_pose_blob_depth; /* Blob neighbor depth the best pose is from */
64 int best_pose_led_depth; /* LED neighbour depth the best pose is from */
65 struct xrt_pose best_pose;
66 enum pose_match_flags match_flags;
67
68 struct pose_metrics best_score;
69
70 /* Search parameters */
71 double search_start_time;
72 int led_depth;
73 int led_index;
74 int blob_index;
75
76 enum correspondence_search_flags search_flags;
77 int min_led_depth, max_led_depth;
78 int max_blob_depth;
79
80 /* Valid when CS_FLAG_HAVE_POSE_PRIOR is set */
81 struct xrt_pose pose_prior;
82 struct xrt_vec3 *pos_error_thresh;
83 struct xrt_vec3 *rot_error_thresh;
84
85 /* Used when CS_FLAG_MATCH_GRAVITY is set */
86 struct xrt_vec3 gravity_vector;
87 struct xrt_quat gravity_swing;
88 float gravity_tolerance_rad;
89};
90
92{
93 const enum u_logging_level *ct_log_level;
94
95 int num_points;
96 struct cs_image_point *points;
97 struct t_blob *blobs; /* Original blobs structs [num_points] */
98
99 unsigned int num_trials;
100 unsigned int num_pose_checks;
101
102 struct camera_model *calib;
103
104 /* List of the nearest blobs for each blob */
105 struct cs_image_point
106 *blob_neighbours[XRT_CONSTELLATION_MAX_BLOBS_PER_FRAME][XRT_CONSTELLATION_MAX_BLOBS_PER_FRAME];
107};
108
110correspondence_search_new(const enum u_logging_level *ct_log_level, struct camera_model *camera_calib);
111
112void
113correspondence_search_free(struct correspondence_search *cs);
114
115void
116correspondence_search_set_blobs(struct correspondence_search *cs, struct t_blob *blobs, int num_blobs);
117
118bool
119correspondence_search_find_one_pose(struct correspondence_search *cs,
120 struct t_constellation_search_model *model,
121 enum correspondence_search_flags search_flags,
122 struct xrt_pose *pose,
123 struct xrt_vec3 *pos_error_thresh,
124 struct xrt_vec3 *rot_error_thresh,
125 struct xrt_vec3 *gravity_vector,
126 float gravity_tolerance_rad,
127 struct pose_metrics *score);
128
129#ifdef __cplusplus
130}
131#endif
Constellation tracker's camera model storage.
correspondence_search_flags
Definition correspondence_search.h:27
@ CS_FLAG_HAVE_POSE_PRIOR
If the input obj_cam_pose contains a valid prior.
Definition correspondence_search.h:38
@ 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:34
@ CS_FLAG_SHALLOW_SEARCH
Do quick search @ depth 1-2 neighbour depth.
Definition correspondence_search.h:30
@ CS_FLAG_DEEP_SEARCH
do deeper searches @ up to MAX_LED_SEARCH_DEPTH/MAX_BLOB_SEARCH_DEPTH
Definition correspondence_search.h:32
@ CS_FLAG_MATCH_GRAVITY
Use the provided gravity vector to check pose verticality. Depends on CS_FLAG_HAVE_POSE_PRIOR.
Definition correspondence_search.h:40
@ CS_FLAG_MATCH_ALL_BLOBS
Allow matching against all blobs, not just unlabelled ones or for the current device.
Definition correspondence_search.h:36
u_logging_level
Logging level enum.
Definition u_logging.h:45
Metrics for constellation tracking poses.
pose_match_flags
Definition pose_metrics.h:41
Definition t_rift_blobwatch.c:45
Definition camera_model.h:19
Definition correspondence_search.h:92
Definition correspondence_search.h:44
Definition correspondence_search.h:57
Definition pose_metrics.h:61
A blob is a 2d position in a camera sensor's view that is being tracked.
Definition t_constellation.h:36
Definition led_search_model.h:40
A pose composed of a position and orientation.
Definition xrt_defines.h:492
A quaternion with single floats.
Definition xrt_defines.h:235
A 3 element vector with single floats.
Definition xrt_defines.h:289
Header defining the tracking system integration in Monado.