Monado OpenXR Runtime
lm_interface.hpp
Go to the documentation of this file.
1// Copyright 2022, Collabora, Ltd.
2// SPDX-License-Identifier: BSL-1.0
3/*!
4 * @file
5 * @brief Interface for Levenberg-Marquardt kinematic optimizer
6 * @author Moses Turner <moses@collabora.com>
7 * @ingroup tracking
8 */
9#pragma once
10#include "xrt/xrt_defines.h"
11#include "util/u_logging.h"
12// #include "lm_defines.hpp"
13#include "../kine_common.hpp"
14
15namespace xrt::tracking::hand::mercury::lm {
16
17// Yes, this is a weird in-between-C-and-C++ API. Fight me, I like it this way.
18
19// Opaque struct.
20struct KinematicHandLM;
21
22// Constructor
23void
24optimizer_create(xrt_pose left_in_right,
25 bool is_right,
26 u_logging_level log_level,
27 KinematicHandLM **out_kinematic_hand);
28
29/*!
30 * The main tracking code calls this function with some 2D(ish) camera observations of the hand, and this function
31 * calculates a good 3D hand pose and writes it to out_viz_hand.
32 *
33 * @param observation The observation of the hand joints. Warning, this function will mutate the observation
34 * unpredictably. Keep a copy of it if you need it after.
35 * @param hand_was_untracked_last_frame: If the hand was untracked last frame (it was out of view, obscured, ML models
36 * failed, etc.) - if it was, we don't want to enforce temporal consistency because we have no good previous hand state
37 * with which to do that.
38 * @param optimize_hand_size: Whether or not it's allowed to tweak the hand size - when we're calibrating the user's
39 * hand size, we want to do that; afterwards we don't want to waste the compute.
40 * @param target_hand_size: The hand size we want it to get close to
41 * @param hand_size_err_mul: A multiplier to help determine how close it has to get to that hand size
42 * @param[out] out_hand: The xrt_hand_joint_set to output its result to
43 * @param[out] out_hand_size: The hand size it ended up at
44 * @param[out] out_reprojection_error: The reprojection error it ended up at
45 */
46
47void
48optimizer_run(KinematicHandLM *hand,
49 one_frame_input &observation,
50 bool hand_was_untracked_last_frame,
51 float smoothing_factor, //!<- Unused if this is the first frame
52 bool optimize_hand_size,
53 float target_hand_size,
54 float hand_size_err_mul,
55 float amt_use_depth,
56 xrt_hand_joint_set &out_hand,
57 float &out_hand_size,
58 float &out_reprojection_error);
59
60// Destructor
61void
62optimizer_destroy(KinematicHandLM **hand);
63
64} // namespace xrt::tracking::hand::mercury::lm
u_logging_level
Logging level enum.
Definition: u_logging.h:43
void optimizer_run(KinematicHandLM *hand, one_frame_input &observation, bool hand_was_untracked_last_frame, float smoothing_factor, bool optimize_hand_size, float target_hand_size, float hand_size_err_mul, float amt_use_depth, xrt_hand_joint_set &out_hand, float &out_hand_size, float &out_reprojection_error)
The main tracking code calls this function with some 2D(ish) camera observations of the hand,...
Definition: lm_main.cpp:954
Joint set type used for hand tracking.
Definition: xrt_defines.h:1400
A pose composed of a position and orientation.
Definition: xrt_defines.h:465
Basic logging functionality.
Common defines and enums for XRT.