Time-of-Flight Library(ToF)  3.2.4
calibration.hpp
1 #ifndef _CHRONOPTICS_TOF_CALIBRATION_HPP_
2 #define _CHRONOPTICS_TOF_CALIBRATION_HPP_
3 
4 #include <chronoptics/tof/calibration.h>
5 
6 #include <chronoptics/tof/base.hpp>
7 
8 namespace chronoptics {
9 namespace tof {
10 
11 /** This class contains all the calibration information
12 */
13 class Calibration : public detail::Base<tof_calibration, tof_calibration_delete> {
14  public:
15  /** Construct from pointer */
16  Calibration(tof_calibration_t ptr = nullptr) {
17  this->ptr_ = ptr;
18  }
19 
20  /** Read calibration from disk
21  * @param file_location Location of calibration file
22  */
23  Calibration(StringView file_location) {
24  this->ptr_ = tof_calibration_new_from_disk(file_location, TOF_ERROR_HANDLER{});
25  }
26 
27  /** Write calibration to disk
28  * @param file_location Location to save the calibration file to
29  */
30  void write(StringView file_location) const {
31  return tof_calibration_write(this->ptr_, file_location, TOF_ERROR_HANDLER{});
32  }
33 
34  /** The the calibrated frequencies in the calibration file
35  * @return The calibrated modulation frequencies
36  */
37  std::vector<float> get_calibrated_frequencies() const {
38  size_t size = tof_calibration_get_calibrated_frequencies(this->ptr_, nullptr, 0, TOF_ERROR_HANDLER{});
39  std::vector<float> vec(size);
40  size = tof_calibration_get_calibrated_frequencies(this->ptr_, vec.data(), vec.size(), TOF_ERROR_HANDLER{});
41  return vec;
42  }
43 
44  /** Get focal length x
45  * @return Focal length
46  */
47  double get_focal_length_x() const {
48  return tof_calibration_get_focal_length_x(this->ptr_, TOF_ERROR_HANDLER{});
49  }
50 
51  /** Get focal length y
52  * @return Focal length
53  */
54  double get_focal_length_y() const {
55  return tof_calibration_get_focal_length_y(this->ptr_, TOF_ERROR_HANDLER{});
56  }
57 
58  /** Get principal point x
59  * @return Principal point
60  */
61  double get_principal_point_x() const {
62  return tof_calibration_get_principal_point_x(this->ptr_, TOF_ERROR_HANDLER{});
63  }
64 
65  /** Get principal point y
66  * @return Principal point
67  */
68  double get_principal_point_y() const {
69  return tof_calibration_get_principal_point_y(this->ptr_, TOF_ERROR_HANDLER{});
70  }
71 
72  /** Get the camera matrix of the depth sensor and lens
73  * @return Camera matrix, 3x3 matrix
74  */
75  std::array<double, 9> get_depth_camera_matrix() {
76  std::array<double, 9> array;
77  auto data = tof_calibration_get_depth_camera_matrix(this->ptr_, TOF_ERROR_HANDLER{});
78  std::copy(data, data + array.size(), array.data());
79  return array;
80  }
81 
82  /** Get the distortion coefficients of the depth lens
83  * @return Distortion coefficients, 5x1 matrix
84  */
85  std::array<double, 5> get_depth_distortion_coefficients() {
86  std::array<double, 5> array;
87  auto data = tof_calibration_get_depth_distortion_coefficients(this->ptr_, TOF_ERROR_HANDLER{});
88  std::copy(data, data + array.size(), array.data());
89  return array;
90  }
91 
92  /** Get the camera matrix of the rgb sensor and lens
93  * @return Camera matrix, 3x3 matrix
94  */
95  std::array<double, 9> get_rgb_camera_matrix() {
96  std::array<double, 9> array;
97  auto data = tof_calibration_get_rgb_camera_matrix(this->ptr_, TOF_ERROR_HANDLER{});
98  std::copy(data, data + array.size(), array.data());
99  return array;
100  }
101 
102  /** Get the distortion coefficients of the rgb lens
103  * @return Distortion coefficients, 5x1 matrix
104  */
105  std::array<double, 5> get_rgb_distortion_coefficients() {
106  std::array<double, 5> array;
107  auto data = tof_calibration_get_rgb_distortion_coefficients(this->ptr_, TOF_ERROR_HANDLER{});
108  std::copy(data, data + array.size(), array.data());
109  return array;
110  }
111 
112 };
113 
114 } // tof
115 } // chronoptics
116 
117 #endif
This class contains all the calibration information.
Definition: calibration.hpp:13
std::array< double, 9 > get_depth_camera_matrix()
Get the camera matrix of the depth sensor and lens.
Definition: calibration.hpp:75
double get_principal_point_y() const
Get principal point y.
Definition: calibration.hpp:68
std::vector< float > get_calibrated_frequencies() const
The the calibrated frequencies in the calibration file.
Definition: calibration.hpp:37
Calibration(tof_calibration_t ptr=nullptr)
Construct from pointer.
Definition: calibration.hpp:16
double get_focal_length_y() const
Get focal length y.
Definition: calibration.hpp:54
double get_principal_point_x() const
Get principal point x.
Definition: calibration.hpp:61
double get_focal_length_x() const
Get focal length x.
Definition: calibration.hpp:47
std::array< double, 5 > get_rgb_distortion_coefficients()
Get the distortion coefficients of the rgb lens.
void write(StringView file_location) const
Write calibration to disk.
Definition: calibration.hpp:30
std::array< double, 5 > get_depth_distortion_coefficients()
Get the distortion coefficients of the depth lens.
Definition: calibration.hpp:85
Calibration(StringView file_location)
Read calibration from disk.
Definition: calibration.hpp:23
std::array< double, 9 > get_rgb_camera_matrix()
Get the camera matrix of the rgb sensor and lens.
Definition: calibration.hpp:95