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> {
48 Calibration(StringView file_location) :
Calibration(tof_calibration_new_from_disk(file_location, TOF_ERROR_HANDLER{})) {}
53 void write(StringView file_location)
const {
54 return tof_calibration_write(this->ptr_, file_location, TOF_ERROR_HANDLER{});
61 size_t size = tof_calibration_get_calibrated_frequencies(this->ptr_,
nullptr, 0, TOF_ERROR_HANDLER{});
62 std::vector<float> vec(size);
63 size = tof_calibration_get_calibrated_frequencies(this->ptr_, vec.data(), vec.size(), TOF_ERROR_HANDLER{});
71 return tof_calibration_get_focal_length_x(this->ptr_, TOF_ERROR_HANDLER{});
78 return tof_calibration_get_focal_length_y(this->ptr_, TOF_ERROR_HANDLER{});
85 return tof_calibration_get_principal_point_x(this->ptr_, TOF_ERROR_HANDLER{});
92 return tof_calibration_get_principal_point_y(this->ptr_, TOF_ERROR_HANDLER{});
99 std::array<double, 9> array;
100 auto data = tof_calibration_get_depth_camera_matrix(this->ptr_, TOF_ERROR_HANDLER{});
101 std::copy(data, data + array.size(), array.data());
109 size_t size = tof_calibration_get_depth_distortion_coefficients(this->ptr_,
nullptr, 0, TOF_ERROR_HANDLER{});
110 std::vector<double> vec(size);
111 size = tof_calibration_get_depth_distortion_coefficients(this->ptr_, vec.data(), vec.size(), TOF_ERROR_HANDLER{});
119 std::array<double, 9> array;
120 auto data = tof_calibration_get_rgb_camera_matrix(this->ptr_, TOF_ERROR_HANDLER{});
121 std::copy(data, data + array.size(), array.data());
129 std::array<double, 5> array;
130 auto data = tof_calibration_get_rgb_distortion_coefficients(this->ptr_, TOF_ERROR_HANDLER{});
131 std::copy(data, data + array.size(), array.data());
139 std::array<double, 3> array;
140 auto data = tof_calibration_get_rotation_vector(this->ptr_, TOF_ERROR_HANDLER{});
141 std::copy(data, data + array.size(), array.data());
149 std::array<double, 3> array;
150 auto data = tof_calibration_get_translation_vector(this->ptr_, TOF_ERROR_HANDLER{});
151 std::copy(data, data + array.size(), array.data());
164inline Point2d transform_3d_to_depth_2d(
float x,
float y,
float z, Calibration &calibration) {
165 Point2d new_point_2d(
static_cast<tof_point_2d_t
>(
nullptr));
166 auto ptr =
reinterpret_cast<tof_point_2d_t*
>(&new_point_2d);
167 *ptr = tof_transform_3d_to_depth_2d(x, y, z, *
reinterpret_cast<tof_calibration_t*
>(&calibration), TOF_ERROR_HANDLER{});
178inline Point2d transform_3d_to_color_2d(
float x,
float y,
float z, Calibration &calibration) {
179 Point2d new_point_2d(
static_cast<tof_point_2d_t
>(
nullptr));
180 auto ptr =
reinterpret_cast<tof_point_2d_t*
>(&new_point_2d);
181 *ptr = tof_transform_3d_to_color_2d(x, y, z, *
reinterpret_cast<tof_calibration_t*
>(&calibration), TOF_ERROR_HANDLER{});
194inline Point2d transform_color_2d_to_depth_2d(int32_t row, int32_t col, Data &depth_data, Calibration &calibration) {
195 Point2d new_point_2d(
static_cast<tof_point_2d_t
>(
nullptr));
196 auto ptr =
reinterpret_cast<tof_point_2d_t*
>(&new_point_2d);
197 *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, 3 > get_rotation_vector() const
Get the rotation vector between the depth and rgb sensor.
Calibration(tof_calibration_t ptr=nullptr)
Construct from pointer.
double get_focal_length_y() const
Get focal length y.
std::array< double, 3 > get_translation_vector() const
Get the translation vector between the depth and rgb sensor.
double get_principal_point_x() const
Get principal point x.
double get_focal_length_x() const
Get focal length x.
void write(StringView file_location) const
Write calibration to disk.
std::array< double, 5 > get_rgb_distortion_coefficients() const
Get the distortion coefficients of the rgb lens.
std::array< double, 9 > get_depth_camera_matrix() const
Get the camera matrix of the depth sensor and lens.
std::vector< double > get_depth_distortion_coefficients() const
Get the distortion coefficients of the depth lens.
std::array< double, 9 > get_rgb_camera_matrix() const
Get the camera matrix of the rgb 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.