Monado OpenXR Runtime
Loading...
Searching...
No Matches
t_camera_models.h
Go to the documentation of this file.
1// Copyright 2023, Collabora, Ltd.
2// Copyright 2026, Beyley Cardellio
3// SPDX-License-Identifier: BSL-1.0
4/*!
5 * @file
6 * @brief Camera (un)projection C API for various camera models.
7 * @author Moshi Turner <moshiturner@protonmail.com>
8 * @author Beyley Cardellio <ep1cm1n10n123@gmail.com>
9 * @ingroup aux_tracking
10 */
11
12#pragma once
13
14#include "tracking/t_tracking.h"
15
16
17#ifdef __cplusplus
18extern "C" {
19#endif
20
21/*!
22 * Floating point parameters for @ref T_DISTORTION_FISHEYE_KB4
23 * @ingroup aux_tracking
24 */
26{
27 float k1, k2, k3, k4;
28};
29
30/*!
31 * Floating point parameters for @ref T_DISTORTION_OPENCV_RADTAN_8, also including
32 * @p metric_radius.
33 * @ingroup aux_tracking
34 */
36{
37 float k1, k2, p1, p2, k3, k4, k5, k6, metric_radius;
38};
39
40/*!
41 * Floating point parameters for @ref T_DISTORTION_RIFT_CV1.
42 *
43 * @p k1 - @p k4 are the radial polynomial coefficients (Oculus @p d1 - @p d4), @p p1 / @p p2 the
44 * tangential decentering terms, and @p g3 / @p g4 the 4th-order affine gain applied to the
45 * decentering delta.
46 * @ingroup aux_tracking
47 */
49{
50 float k1, k2, k3, k4;
51 float p1, p2;
52 float g3, g4;
53};
54
55/*!
56 * Floating point calibration data for a single calibrated camera.
57 * @note This is basically @ref t_camera_calibration, just without some compatibility stuff and using single floats
58 * instead of doubles.
59 * @ingroup aux_tracking
60 */
62{
63 float fx, fy, cx, cy;
64 union {
68 };
69 // This model gets reinterpreted from values in the main t_camera_calibration struct to either
70 // * T_DISTORTION_FISHEYE_KB4
71 // * T_DISTORTION_OPENCV_RADTAN_8
72 // * T_DISTORTION_RIFT_CV1
74};
75
76/*!
77 * Takes a @ref t_camera_calibration through \p cc, and returns a @ref t_camera_model_params that shadows \p cc
78 * 's parameters through \p out_params
79 */
80void
82 struct t_camera_model_params *out_params);
83
84/*!
85 * Takes a 2D image-space point through \p x and \p y, unprojects it to a normalized 3D direction, and returns
86 * the result through \p out_x, \p out_y and \p out_z
87 */
88bool
90 const struct t_camera_model_params *dist, const float x, const float y, float *out_x, float *out_y, float *out_z);
91
92/*!
93 * Takes a 2D image-space point through \p x and \p y, unprojects it to a normalized 3D direction, flips its Y
94 * and Z values (performing a coordinate space transform from +Z forward -Y up to -Z forward +Y up) and returns the
95 * result through \p out_x, \p out_y and \p out_z
96 */
97bool
99 const struct t_camera_model_params *dist, const float x, const float y, float *out_x, float *out_y, float *out_z);
100
101/*!
102 * Takes a distorted 2D point through \p x and \p y and computes the undistorted point into
103 * \p out_x and \p out_y
104 */
105void
107 const struct t_camera_model_params *dist, const float x, const float y, float *out_x, float *out_y);
108
109/*!
110 * Takes a 3D point through \p x, \p y, and \p z, projects it into image space, and returns the result
111 * through \p out_x and \p out_y
112 */
113bool
115 const float x, //
116 const float y, //
117 const float z, //
118 float *out_x, //
119 float *out_y);
120
121/*!
122 * Takes a 3D point through \p x, \p y, and \p z, flips its Y and Z values (performing a coordinate space
123 * transform from -Z forward +Y up to +Z forward -Y up), projects it into image space, and returns the result through
124 * \p out_x and \p out_y
125 */
126bool
128 const float x, //
129 const float y, //
130 const float z, //
131 float *out_x, //
132 float *out_y);
133
134#ifdef __cplusplus
135}
136#endif
t_camera_distortion_model
The distortion model this camera calibration falls under.
Definition t_tracking.h:63
Floating point parameters for T_DISTORTION_RIFT_CV1.
Definition t_camera_models.h:49
Floating point parameters for T_DISTORTION_FISHEYE_KB4.
Definition t_camera_models.h:26
Floating point parameters for T_DISTORTION_OPENCV_RADTAN_8, also including metric_radius.
Definition t_camera_models.h:36
Essential calibration data for a single camera, or single lens/sensor of a stereo camera.
Definition t_tracking.h:269
Floating point calibration data for a single calibrated camera.
Definition t_camera_models.h:62
void t_camera_models_undistort(const struct t_camera_model_params *dist, const float x, const float y, float *out_x, float *out_y)
Takes a distorted 2D point through x and y and computes the undistorted point into out_x and out_y.
bool t_camera_models_project(const struct t_camera_model_params *dist, const float x, const float y, const float z, float *out_x, float *out_y)
Takes a 3D point through x, y, and z, projects it into image space, and returns the result through ou...
bool t_camera_models_unproject(const struct t_camera_model_params *dist, const float x, const float y, float *out_x, float *out_y, float *out_z)
Takes a 2D image-space point through x and y, unprojects it to a normalized 3D direction,...
bool t_camera_models_unproject_and_flip(const struct t_camera_model_params *dist, const float x, const float y, float *out_x, float *out_y, float *out_z)
Takes a 2D image-space point through x and y, unprojects it to a normalized 3D direction,...
bool t_camera_models_flip_and_project(const struct t_camera_model_params *dist, const float x, const float y, const float z, float *out_x, float *out_y)
Takes a 3D point through x, y, and z, flips its Y and Z values (performing a coordinate space transfo...
void t_camera_model_params_from_t_camera_calibration(const struct t_camera_calibration *cc, struct t_camera_model_params *out_params)
Takes a t_camera_calibration through cc, and returns a t_camera_model_params that shadows cc 's param...
Tracking API interface.