1#ifndef _CHRONOPTICS_TOF_DATA_HPP_
2#define _CHRONOPTICS_TOF_DATA_HPP_
4#include <chronoptics/tof/data.h>
6#include <chronoptics/tof/stream.hpp>
26using user_pointer_destructed_fn = std::function<void(uint8_t*,
size_t)>;
27constexpr auto user_pointer_destructed_cb_handler = &detail::callback_handler<void, uint8_t*, size_t>;
31class Data :
public detail::Base<tof_data, tof_data_delete> {
34 Data(tof_data_t ptr =
nullptr) {
42 return tof_data_data(this->ptr_, TOF_ERROR_HANDLER{});
49 return tof_data_size(this->ptr_, TOF_ERROR_HANDLER{});
56 return tof_data_get_user_data(this->ptr_, TOF_ERROR_HANDLER{});
63 return tof_data_set_user_data(this->ptr_, user_data, TOF_ERROR_HANDLER{});
70 return static_cast<MatType
>(tof_data_mat_type(this->ptr_, TOF_ERROR_HANDLER{}));
77 return tof_data_rows(this->ptr_, TOF_ERROR_HANDLER{});
84 return tof_data_cols(this->ptr_, TOF_ERROR_HANDLER{});
91 return tof_data_frame_count(this->ptr_, TOF_ERROR_HANDLER{});
98 return static_cast<FrameType
>(tof_data_frame_type(this->ptr_, TOF_ERROR_HANDLER{}));
105 return tof_data_frame_id(this->ptr_, TOF_ERROR_HANDLER{});
112 return tof_data_modulation_frequency(this->ptr_, TOF_ERROR_HANDLER{});
119 return tof_data_integration_time(this->ptr_, TOF_ERROR_HANDLER{});
126 return tof_data_process(this->ptr_, TOF_ERROR_HANDLER{});
134 return tof_data_scale(this->ptr_, TOF_ERROR_HANDLER{});
142 return tof_data_addition(this->ptr_, TOF_ERROR_HANDLER{});
149 size_t size = tof_data_temperatures(this->ptr_,
nullptr, 0, TOF_ERROR_HANDLER{});
150 std::vector<float> vec(
size);
151 size = tof_data_temperatures(this->ptr_, vec.data(), vec.size(), TOF_ERROR_HANDLER{});
159 return tof_data_sync_count(this->ptr_, TOF_ERROR_HANDLER{});
166 return tof_data_user_allocated(this->ptr_, TOF_ERROR_HANDLER{});
173 return tof_data_user_pointer(this->ptr_, TOF_ERROR_HANDLER{});
180 std::array<int16_t, 3> array;
181 auto data = tof_data_acceleration(this->ptr_, TOF_ERROR_HANDLER{});
182 std::copy(
data,
data + array.size(), array.data());
190 std::array<int16_t, 3> array;
191 auto data = tof_data_angular_velocity(this->ptr_, TOF_ERROR_HANDLER{});
192 std::copy(
data,
data + array.size(), array.data());
200 return tof_data_time_stamp(this->ptr_, TOF_ERROR_HANDLER{});
209 template <
typename T>
210 const T&
at(
size_t pos)
const {
211 auto non_const =
const_cast<tof::Data*
>(
this);
212 return reinterpret_cast<const T*
>(non_const->data())[pos];
219 template <
typename T>
221 return reinterpret_cast<T*
>(
data())[pos];
227 template <
typename T>
229 auto non_const =
const_cast<tof::Data*
>(
this);
230 return reinterpret_cast<const T*
>(non_const->data());
236 template <
typename T>
238 return reinterpret_cast<T*
>(
data());
244 template <
typename T>
246 auto non_const =
const_cast<tof::Data*
>(
this);
247 return reinterpret_cast<const T*
>(non_const->data()) +
rows() *
cols();
253 template <
typename T>
This is the class that contains depth or image data.
uint64_t get_user_data() const
Get user data that will get saved to csf file.
uint64_t time_stamp()
Unix time stamp since epoch.
float modulation_frequency() const
Get the modulation frequency of the frame.
bool user_allocated() const
Check whether the data uses a pointer supplied by the user.
T & at(size_t pos)
Get the data at location p, templated because the data type can differ.
const T * end() const
Return iterator to end, templated because the data type can differ.
float scale() const
Get the scale used for integer frames, to get the original value divide by scale.
size_t size() const
Get size of the data.
std::array< int16_t, 3 > acceleration() const
The acceleration measured by the imu.
FrameType frame_type() const
Get the frame type.
int32_t cols() const
Get the number of columns.
T * end()
Return iterator to end, templated because the data type can differ.
std::vector< float > temperatures() const
Get the temperature of various parts of the camera.
uint16_t frame_count() const
The frame counter.
const T * begin() const
Return iterator to beginning, templated because the data type can differ.
MatType mat_type() const
Get the matrix type.
void * data()
Get pointer to data.
void * user_pointer() const
The user data that was given in the add_user_pointer function.
Data(tof_data_t ptr=nullptr)
Construct from pointer.
uint32_t process() const
Get a bit array of the processing performed on the frame.
uint32_t integration_time() const
Get the integration time of the frame.
void set_user_data(uint64_t user_data)
Set user data that will get saved to csf file.
T * begin()
Return iterator to beginning, templated because the data type can differ.
float addition() const
Get the addition used for integer frames, to get the original value substract the addition.
uint32_t frame_id() const
Get the frame id.
int32_t rows() const
Get the number of rows.
const T & at(size_t pos) const
Get the data at location p, templated because the data type can differ.
uint8_t sync_count() const
Get the synchronization count.
std::array< int16_t, 3 > angular_velocity() const
The angular velocity measured by the imu.