1 #ifndef _CHRONOPTICS_TOF_DATA_HPP_
2 #define _CHRONOPTICS_TOF_DATA_HPP_
4 #include <chronoptics/tof/data.h>
6 #include <chronoptics/tof/stream.hpp>
8 namespace chronoptics {
26 using user_pointer_destructed_fn = std::function<void(uint8_t*,
size_t)>;
27 constexpr
auto user_pointer_destructed_cb_handler = &detail::callback_handler<void, uint8_t*, size_t>;
31 class 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{});
182 template <
typename T>
183 const T&
at(
size_t pos)
const {
184 auto non_const =
const_cast<tof::Data*
>(
this);
185 return reinterpret_cast<const T*
>(non_const->data())[pos];
192 template <
typename T>
194 return reinterpret_cast<T*
>(
data())[pos];
200 template <
typename T>
202 auto non_const =
const_cast<tof::Data*
>(
this);
203 return reinterpret_cast<const T*
>(non_const->data());
209 template <
typename T>
211 return reinterpret_cast<T*
>(
data());
217 template <
typename T>
219 auto non_const =
const_cast<tof::Data*
>(
this);
220 return reinterpret_cast<const T*
>(non_const->data()) +
rows() *
cols();
226 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.
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.
float scale() const
Get the scale used for integer frames, to get the original value divide by scale.
const T * begin() const
Return iterator to beginning, templated because the data type can differ.
size_t size() const
Get size of the data.
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.
void * user_pointer() const
The user data that was given in the add_user_pointer function.
uint16_t frame_count() const
The frame counter.
MatType mat_type() const
Get the matrix type.
T & at(size_t pos)
Get the data at location p, templated because the data type can differ.
void * data()
Get pointer to data.
const T * end() const
Return iterator to end, templated because the data type can differ.
const T & at(size_t pos) const
Get the data at location p, templated because the data type can differ.
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.
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.
T * begin()
Return iterator to beginning, templated because the data type can differ.
int32_t rows() const
Get the number of rows.
uint8_t sync_count() const
Get the synchronization count.
std::vector< float > temperatures() const
Get the temperature of various parts of the camera.