1#ifndef _CHRONOPTICS_TOF_CALIBRATION_HPP_
2#define _CHRONOPTICS_TOF_CALIBRATION_HPP_
4#include <chronoptics/tof/calibration.h>
6#include <chronoptics/tof/data.hpp>
13class Point2d :
public detail::Base<tof_point_2d, tof_point_2d_delete> {
24 return tof_point_2d_row(this->ptr_, TOF_ERROR_HANDLER{});
31 return tof_point_2d_col(this->ptr_, TOF_ERROR_HANDLER{});
38class Calibration :
public detail::Base<tof_calibration, tof_calibration_delete> {
49 this->ptr_ = tof_calibration_new_from_disk(file_location, TOF_ERROR_HANDLER{});
55 void write(StringView file_location)
const {
56 return tof_calibration_write(this->ptr_, file_location, TOF_ERROR_HANDLER{});
63 size_t size = tof_calibration_get_calibrated_frequencies(this->ptr_,
nullptr, 0, TOF_ERROR_HANDLER{});
64 std::vector<float> vec(size);
65 size = tof_calibration_get_calibrated_frequencies(this->ptr_, vec.data(), vec.size(), TOF_ERROR_HANDLER{});
73 return tof_calibration_get_focal_length_x(this->ptr_, TOF_ERROR_HANDLER{});
80 return tof_calibration_get_focal_length_y(this->ptr_, TOF_ERROR_HANDLER{});
87 return tof_calibration_get_principal_point_x(this->ptr_, TOF_ERROR_HANDLER{});
94 return tof_calibration_get_principal_point_y(this->ptr_, TOF_ERROR_HANDLER{});
101 std::array<double, 9> array;
102 auto data = tof_calibration_get_depth_camera_matrix(this->ptr_, TOF_ERROR_HANDLER{});
103 std::copy(data, data + array.size(), array.data());
111 std::array<double, 5> array;
112 auto data = tof_calibration_get_depth_distortion_coefficients(this->ptr_, TOF_ERROR_HANDLER{});
113 std::copy(data, data + array.size(), array.data());
121 std::array<double, 9> array;
122 auto data = tof_calibration_get_rgb_camera_matrix(this->ptr_, TOF_ERROR_HANDLER{});
123 std::copy(data, data + array.size(), array.data());
131 std::array<double, 5> array;
132 auto data = tof_calibration_get_rgb_distortion_coefficients(this->ptr_, TOF_ERROR_HANDLER{});
133 std::copy(data, data + array.size(), array.data());
141 std::array<double, 3> array;
142 auto data = tof_calibration_get_rotation_vector(this->ptr_, TOF_ERROR_HANDLER{});
143 std::copy(data, data + array.size(), array.data());
151 std::array<double, 3> array;
152 auto data = tof_calibration_get_translation_vector(this->ptr_, TOF_ERROR_HANDLER{});
153 std::copy(data, data + array.size(), array.data());
166inline Point2d transform_3d_to_depth_2d(
float x,
float y,
float z, Calibration &calibration) {
167 Point2d new_point_2d(
static_cast<tof_point_2d_t
>(
nullptr));
168 auto ptr =
reinterpret_cast<tof_point_2d_t*
>(&new_point_2d);
169 *ptr = tof_transform_3d_to_depth_2d(x, y, z, *
reinterpret_cast<tof_calibration_t*
>(&calibration), TOF_ERROR_HANDLER{});
180inline Point2d transform_3d_to_color_2d(
float x,
float y,
float z, Calibration &calibration) {
181 Point2d new_point_2d(
static_cast<tof_point_2d_t
>(
nullptr));
182 auto ptr =
reinterpret_cast<tof_point_2d_t*
>(&new_point_2d);
183 *ptr = tof_transform_3d_to_color_2d(x, y, z, *
reinterpret_cast<tof_calibration_t*
>(&calibration), TOF_ERROR_HANDLER{});
196inline Point2d transform_color_2d_to_depth_2d(int32_t row, int32_t col, Data &depth_data, Calibration &calibration) {
197 Point2d new_point_2d(
static_cast<tof_point_2d_t
>(
nullptr));
198 auto ptr =
reinterpret_cast<tof_point_2d_t*
>(&new_point_2d);
199 *ptr = tof_transform_color_2d_to_depth_2d(row, col, *
reinterpret_cast<tof_data_t*
>(&depth_data), *
reinterpret_cast<tof_calibration_t*
>(&calibration), TOF_ERROR_HANDLER{});
This class contains all the calibration information.
double get_principal_point_y() const
Get principal point y.
std::array< double, 9 > get_rgb_camera_matrix()
Get the camera matrix of the rgb sensor and lens.
std::array< double, 5 > get_depth_distortion_coefficients()
Get the distortion coefficients of the depth lens.
Calibration(tof_calibration_t ptr=nullptr)
Construct from pointer.
double get_focal_length_y() const
Get focal length y.
std::array< double, 5 > get_rgb_distortion_coefficients()
Get the distortion coefficients of the rgb lens.
double get_principal_point_x() const
Get principal point x.
double get_focal_length_x() const
Get focal length x.
std::array< double, 3 > get_rotation_vector()
Get the rotation vector between the depth and rgb sensor.
std::array< double, 3 > get_translation_vector()
Get the translation vector between the depth and rgb sensor.
void write(StringView file_location) const
Write calibration to disk.
std::array< double, 9 > get_depth_camera_matrix()
Get the camera matrix of the depth sensor and lens.
Calibration(StringView file_location)
Read calibration from disk.
std::vector< float > get_calibrated_frequencies() const
The the calibrated frequencies in the calibration file.
2D point for indexing into array
int32_t row()
Get the row value.
Point2d(tof_point_2d_t ptr=nullptr)
Construct from pointer.
int32_t col()
Get the column value.