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 calibration data for a single calibrated camera.
42 * @note This is basically @ref t_camera_calibration, just without some compatibility stuff and using single floats
43 * instead of doubles.
44 * @ingroup aux_tracking
45 */
47{
48 float fx, fy, cx, cy;
49 union {
52 };
53 // This model gets reinterpreted from values in the main t_camera_calibration struct to either
54 // * T_DISTORTION_FISHEYE_KB4
55 // * T_DISTORTION_OPENCV_RADTAN_8
57};
58
59/*!
60 * Takes a @ref t_camera_calibration through \p cc, and returns a @ref t_camera_model_params that shadows \p cc
61 * 's parameters through \p out_params
62 */
63void
65 struct t_camera_model_params *out_params);
66
67/*!
68 * Takes a 2D image-space point through \p x and \p y, unprojects it to a normalized 3D direction, and returns
69 * the result through \p out_x, \p out_y and \p out_z
70 */
71bool
73 const struct t_camera_model_params *dist, const float x, const float y, float *out_x, float *out_y, float *out_z);
74
75/*!
76 * Takes a 2D image-space point through \p x and \p y, unprojects it to a normalized 3D direction, flips its Y
77 * and Z values (performing a coordinate space transform from +Z forward -Y up to -Z forward +Y up) and returns the
78 * result through \p out_x, \p out_y and \p out_z
79 */
80bool
82 const struct t_camera_model_params *dist, const float x, const float y, float *out_x, float *out_y, float *out_z);
83
84/*!
85 * Takes a distorted 2D point through \p x and \p y and computes the undistorted point into
86 * \p out_x and \p out_y
87 */
88void
90 const struct t_camera_model_params *dist, const float x, const float y, float *out_x, float *out_y);
91
92/*!
93 * Takes a 3D point through \p x, \p y, and \p z, projects it into image space, and returns the result
94 * through \p out_x and \p out_y
95 */
96bool
98 const float x, //
99 const float y, //
100 const float z, //
101 float *out_x, //
102 float *out_y);
103
104/*!
105 * Takes a 3D point through \p x, \p y, and \p z, flips its Y and Z values (performing a coordinate space
106 * transform from -Z forward +Y up to +Z forward -Y up), projects it into image space, and returns the result through
107 * \p out_x and \p out_y
108 */
109bool
111 const float x, //
112 const float y, //
113 const float z, //
114 float *out_x, //
115 float *out_y);
116
117#ifdef __cplusplus
118}
119#endif
t_camera_distortion_model
The distortion model this camera calibration falls under.
Definition t_tracking.h:63
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:236
Floating point calibration data for a single calibrated camera.
Definition t_camera_models.h:47
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.