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