Time-of-Flight Library(ToF) 3.13.4
 
calibration.h
1#ifndef _CHRONOPTICS_TOF_CALIBRATION_H_
2#define _CHRONOPTICS_TOF_CALIBRATION_H_
3
4#include <chronoptics/tof/data.h>
5
6#ifdef __cplusplus
7extern "C" {
8#endif
9
10/** 2D point for indexing into array
11 */
12typedef struct tof_point_2d* tof_point_2d_t;
13
14/** Destruct tof_point_2d */
15TOF_EXPORT void tof_point_2d_delete(tof_point_2d_t ptr);
16
17/** Get the row value
18 * @param ptr Pointer to class
19 * @param error Pointer to error
20 * @return Row value
21 */
22TOF_EXPORT int32_t tof_point_2d_row(tof_point_2d_t ptr, tof_error_t *error);
23
24/** Get the column value
25 * @param ptr Pointer to class
26 * @param error Pointer to error
27 * @return Column value
28 */
29TOF_EXPORT int32_t tof_point_2d_col(tof_point_2d_t ptr, tof_error_t *error);
30
31/** This class contains all the calibration information
32 */
33typedef struct tof_calibration* tof_calibration_t;
34
35/** Destruct tof_calibration */
36TOF_EXPORT void tof_calibration_delete(tof_calibration_t ptr);
37
38/** Read calibration from disk
39 * @param ptr Pointer to class
40 * @param file_location Location of calibration file
41 * @param error Pointer to error
42 * @return New object
43 */
44TOF_EXPORT tof_calibration_t tof_calibration_new_from_disk(const char* file_location, tof_error_t *error);
45
46/** Write calibration to disk
47 * @param ptr Pointer to class
48 * @param file_location Location to save the calibration file to
49 * @param error Pointer to error
50 */
51TOF_EXPORT void tof_calibration_write(const tof_calibration_t ptr, const char* file_location, tof_error_t *error);
52
53/** The the calibrated frequencies in the calibration file
54 * @param ptr Pointer to class
55 * @param calibrated_frequencies The calibrated modulation frequencies
56 * @param capacity The amount of data the above pointer can hold
57 * @param error Pointer to error
58 * @return Number of pointers filled or complete array size
59 */
60TOF_EXPORT size_t tof_calibration_get_calibrated_frequencies(const tof_calibration_t ptr, float* calibrated_frequencies, size_t capacity, tof_error_t *error);
61
62/** Get focal length x
63 * @param ptr Pointer to class
64 * @param error Pointer to error
65 * @return Focal length
66 */
67TOF_EXPORT double tof_calibration_get_focal_length_x(const tof_calibration_t ptr, tof_error_t *error);
68
69/** Get focal length y
70 * @param ptr Pointer to class
71 * @param error Pointer to error
72 * @return Focal length
73 */
74TOF_EXPORT double tof_calibration_get_focal_length_y(const tof_calibration_t ptr, tof_error_t *error);
75
76/** Get principal point x
77 * @param ptr Pointer to class
78 * @param error Pointer to error
79 * @return Principal point
80 */
81TOF_EXPORT double tof_calibration_get_principal_point_x(const tof_calibration_t ptr, tof_error_t *error);
82
83/** Get principal point y
84 * @param ptr Pointer to class
85 * @param error Pointer to error
86 * @return Principal point
87 */
88TOF_EXPORT double tof_calibration_get_principal_point_y(const tof_calibration_t ptr, tof_error_t *error);
89
90/** Get the camera matrix of the depth sensor and lens
91 * @param ptr Pointer to class
92 * @param error Pointer to error
93 * @return[9] Camera matrix, 3x3 matrix
94 */
95TOF_EXPORT double* tof_calibration_get_depth_camera_matrix(tof_calibration_t ptr, tof_error_t *error);
96
97/** Get the distortion coefficients of the depth lens
98 * @param ptr Pointer to class
99 * @param error Pointer to error
100 * @return[5] Distortion coefficients, 5x1 matrix
101 */
102TOF_EXPORT double* tof_calibration_get_depth_distortion_coefficients(tof_calibration_t ptr, tof_error_t *error);
103
104/** Get the camera matrix of the rgb sensor and lens
105 * @param ptr Pointer to class
106 * @param error Pointer to error
107 * @return[9] Camera matrix, 3x3 matrix
108 */
109TOF_EXPORT double* tof_calibration_get_rgb_camera_matrix(tof_calibration_t ptr, tof_error_t *error);
110
111/** Get the distortion coefficients of the rgb lens
112 * @param ptr Pointer to class
113 * @param error Pointer to error
114 * @return[5] Distortion coefficients, 5x1 matrix
115 */
116TOF_EXPORT double* tof_calibration_get_rgb_distortion_coefficients(tof_calibration_t ptr, tof_error_t *error);
117
118/** Get the rotation vector between the depth and rgb sensor
119 * @param ptr Pointer to class
120 * @param error Pointer to error
121 * @return[3] Rotation vector, 3x1 matrix
122 */
123TOF_EXPORT double* tof_calibration_get_rotation_vector(tof_calibration_t ptr, tof_error_t *error);
124
125/** Get the translation vector between the depth and rgb sensor
126 * @param ptr Pointer to class
127 * @param error Pointer to error
128 * @return[3] Translation vector, 3x1 matrix
129 */
130TOF_EXPORT double* tof_calibration_get_translation_vector(tof_calibration_t ptr, tof_error_t *error);
131
132/** Transform a 3D point into a 2D pixel coordinate of the depth camera
133 * @param x X value
134 * @param y Y value
135 * @param z Z value
136 * @param calibration The camera calibration
137 * @param error Pointer to error
138 * @return 2D pixel coordinate of the depth camera
139 */
140TOF_EXPORT tof_point_2d_t tof_transform_3d_to_depth_2d(float x, float y, float z, tof_calibration_t calibration, tof_error_t *error);
141
142/** Transform a 3D point into a 2D pixel coordinate of the color camera
143 * @param x X value
144 * @param y Y value
145 * @param z Z value
146 * @param calibration The camera calibration
147 * @param error Pointer to error
148 * @return 2D pixel coordinate of the color camera
149 */
150TOF_EXPORT tof_point_2d_t tof_transform_3d_to_color_2d(float x, float y, float z, tof_calibration_t calibration, tof_error_t *error);
151
152/** Transform a 2D pixel coordinate of the color camera to the 2D pixel
153 * coordinate of the depth camera.
154 * @param row Row coordinate
155 * @param col Column cooridnate
156 * @param depth_data Depth data containing xyz information, XYZ, XYZAmp, XYZBGR
157 * and XYZBGRI are all valid
158 * @param calibration The camera calibration
159 * @param error Pointer to error
160 * @return 2D pixel coordinate of the depth camera
161 */
162TOF_EXPORT tof_point_2d_t tof_transform_color_2d_to_depth_2d(int32_t row, int32_t col, tof_data_t depth_data, tof_calibration_t calibration, tof_error_t *error);
163
164#ifdef __cplusplus
165}
166#endif
167
168#endif