1 #ifndef _CHRONOPTICS_TOF_CAMERA_CONFIG_HPP_
2 #define _CHRONOPTICS_TOF_CAMERA_CONFIG_HPP_
4 #include <chronoptics/tof/camera_config.h>
6 #include <chronoptics/tof/processing_config.hpp>
8 namespace chronoptics {
13 enum class CameraType {
21 enum class SensorMode {
33 class Roi :
public detail::Base<tof_roi, tof_roi_delete> {
36 Roi(tof_roi_t ptr =
nullptr) {
44 return tof_roi_sensor_rows(this->ptr_, TOF_ERROR_HANDLER{});
51 return tof_roi_sensor_cols(this->ptr_, TOF_ERROR_HANDLER{});
58 return tof_roi_get_row_offset(this->ptr_, TOF_ERROR_HANDLER{});
65 return tof_roi_set_row_offset(this->ptr_, row_offset, TOF_ERROR_HANDLER{});
72 return tof_roi_get_col_offset(this->ptr_, TOF_ERROR_HANDLER{});
79 return tof_roi_set_col_offset(this->ptr_, col_offset, TOF_ERROR_HANDLER{});
86 return tof_roi_get_img_rows(this->ptr_, TOF_ERROR_HANDLER{});
93 return tof_roi_set_img_rows(this->ptr_, img_rows, TOF_ERROR_HANDLER{});
100 return tof_roi_get_img_cols(this->ptr_, TOF_ERROR_HANDLER{});
107 return tof_roi_set_img_cols(this->ptr_, img_cols, TOF_ERROR_HANDLER{});
114 class CameraConfig :
public detail::Base<tof_camera_config, tof_camera_config_delete> {
125 this->ptr_ = tof_camera_config_new_from_disk(file_location, TOF_ERROR_HANDLER{});
131 void write(StringView file_location)
const {
132 return tof_camera_config_write(this->ptr_, file_location, TOF_ERROR_HANDLER{});
139 return static_cast<CameraType
>(tof_camera_config_get_type(this->ptr_, TOF_ERROR_HANDLER{}));
145 return tof_camera_config_reset(this->ptr_, TOF_ERROR_HANDLER{});
154 return tof_camera_config_frame_size(this->ptr_, TOF_ERROR_HANDLER{});
160 return tof_camera_config_add_frame(this->ptr_, TOF_ERROR_HANDLER{});
167 ProcessingConfig new_processing_config(
static_cast<tof_processing_config_t
>(
nullptr));
168 auto ptr =
reinterpret_cast<tof_processing_config_t*
>(&new_processing_config);
169 *ptr = tof_camera_config_default_processing(this->ptr_, TOF_ERROR_HANDLER{});
170 return new_processing_config;
177 return tof_camera_config_erase_frame(this->ptr_, frame, TOF_ERROR_HANDLER{});
186 size_t size = tof_camera_config_get_phase_shifts(this->ptr_, frame,
nullptr, 0, TOF_ERROR_HANDLER{});
187 std::vector<float> vec(size);
188 size = tof_camera_config_get_phase_shifts(this->ptr_, frame, vec.data(), vec.size(), TOF_ERROR_HANDLER{});
198 return tof_camera_config_set_phase_shifts(this->ptr_, frame, phase_shifts.data(), phase_shifts.size(), TOF_ERROR_HANDLER{});
206 size_t size = tof_camera_config_get_integration_time(this->ptr_, frame,
nullptr, 0, TOF_ERROR_HANDLER{});
207 std::vector<uint32_t> vec(size);
208 size = tof_camera_config_get_integration_time(this->ptr_, frame, vec.data(), vec.size(), TOF_ERROR_HANDLER{});
217 return tof_camera_config_set_integration_time(this->ptr_, frame, integration_time.data(), integration_time.size(), TOF_ERROR_HANDLER{});
225 return static_cast<SensorMode
>(tof_camera_config_get_sensor_mode(this->ptr_, frame, TOF_ERROR_HANDLER{}));
233 return tof_camera_config_set_sensor_mode(this->ptr_, frame,
static_cast<tof_sensor_mode
>(sensor_mode), TOF_ERROR_HANDLER{});
241 return tof_camera_config_get_modulation_frequency(this->ptr_, frame, TOF_ERROR_HANDLER{});
249 return tof_camera_config_set_modulation_frequency(this->ptr_, frame, modulation_frequency, TOF_ERROR_HANDLER{});
257 return tof_camera_config_get_duty_cycle(this->ptr_, frame, TOF_ERROR_HANDLER{});
265 return tof_camera_config_set_duty_cycle(this->ptr_, frame, duty_cycle, TOF_ERROR_HANDLER{});
273 Roi new_roi(
static_cast<tof_roi_t
>(
nullptr));
274 auto ptr =
reinterpret_cast<tof_roi_t*
>(&new_roi);
275 *ptr = tof_camera_config_get_roi(this->ptr_, frame, TOF_ERROR_HANDLER{});
284 return tof_camera_config_set_roi(this->ptr_, frame, *
reinterpret_cast<tof_roi_t*
>(&roi), TOF_ERROR_HANDLER{});
292 return tof_camera_config_get_binning(this->ptr_, frame, TOF_ERROR_HANDLER{});
300 return tof_camera_config_set_binning(this->ptr_, frame, binning, TOF_ERROR_HANDLER{});
308 return tof_camera_config_get_flip(this->ptr_, frame, TOF_ERROR_HANDLER{});
316 return tof_camera_config_set_flip(this->ptr_, frame, flip, TOF_ERROR_HANDLER{});
324 return tof_camera_config_get_mirror(this->ptr_, frame, TOF_ERROR_HANDLER{});
332 return tof_camera_config_set_mirror(this->ptr_, frame, mirror, TOF_ERROR_HANDLER{});
339 return tof_camera_config_get_gain(this->ptr_, TOF_ERROR_HANDLER{});
346 return tof_camera_config_set_gain(this->ptr_, gain, TOF_ERROR_HANDLER{});
354 return tof_camera_config_get_sync_mode(this->ptr_, TOF_ERROR_HANDLER{});
362 return tof_camera_config_set_sync_mode(this->ptr_, sync_mode, TOF_ERROR_HANDLER{});
370 size_t size = tof_camera_config_maximum_integration_time(this->ptr_, frame,
nullptr, 0, TOF_ERROR_HANDLER{});
371 std::vector<uint32_t> vec(size);
372 size = tof_camera_config_maximum_integration_time(this->ptr_, frame, vec.data(), vec.size(), TOF_ERROR_HANDLER{});
380 size_t size = tof_camera_config_get_dac(this->ptr_,
nullptr, 0, TOF_ERROR_HANDLER{});
381 std::vector<uint16_t> vec(size);
382 size = tof_camera_config_get_dac(this->ptr_, vec.data(), vec.size(), TOF_ERROR_HANDLER{});
389 void set_dac(
const std::vector<uint16_t> &dac) {
390 return tof_camera_config_set_dac(this->ptr_, dac.data(), dac.size(), TOF_ERROR_HANDLER{});
397 return tof_camera_config_get_mlx_mipi_speed(this->ptr_, TOF_ERROR_HANDLER{});
405 return tof_camera_config_set_mlx_mipi_speed(this->ptr_, mipi_speed, TOF_ERROR_HANDLER{});
413 return tof_camera_config_get_mlx_preheat(this->ptr_, frame, TOF_ERROR_HANDLER{});
421 return tof_camera_config_set_mlx_preheat(this->ptr_, frame, preheat, TOF_ERROR_HANDLER{});
429 return tof_camera_config_get_mlx_preheat_enable(this->ptr_, frame, TOF_ERROR_HANDLER{});
437 return tof_camera_config_set_mlx_preheat_enable(this->ptr_, frame, enable, TOF_ERROR_HANDLER{});
444 return tof_camera_config_set_opt_kea_nios_hex(this->ptr_, file_location, TOF_ERROR_HANDLER{});
451 std::array<int32_t, 2> array;
452 auto data = tof_camera_config_get_opt_kea_sub_quad(this->ptr_, TOF_ERROR_HANDLER{});
453 std::copy(data, data + array.size(), array.data());
461 return tof_camera_config_set_opt_kea_sub_quad(this->ptr_, subs_quads.data(), TOF_ERROR_HANDLER{});
469 ProcessingConfig new_processing_config(
static_cast<tof_processing_config_t
>(
nullptr));
470 auto ptr =
reinterpret_cast<tof_processing_config_t*
>(&new_processing_config);
471 *ptr = tof_camera_config_get_processing(this->ptr_, TOF_ERROR_HANDLER{});
472 return new_processing_config;
480 return tof_camera_config_set_processing(this->ptr_, *
reinterpret_cast<tof_processing_config_t*
>(&processing), TOF_ERROR_HANDLER{});
489 return tof_camera_config_get_frame_time(this->ptr_, frame, TOF_ERROR_HANDLER{});
498 return tof_camera_config_set_frame_time(this->ptr_, frame, frame_time, TOF_ERROR_HANDLER{});
509 std::array<float, 2> array;
510 auto data = tof_camera_config_get_global_phase_offset(this->ptr_, frame, TOF_ERROR_HANDLER{});
511 std::copy(data, data + array.size(), array.data());
523 return tof_camera_config_set_global_phase_offset(this->ptr_, frame, phase_offset.data(), TOF_ERROR_HANDLER{});
532 return tof_camera_config_get_illumination_mode(this->ptr_, frame, TOF_ERROR_HANDLER{});
541 return tof_camera_config_set_illumination_mode(this->ptr_, frame, illumination_mode, TOF_ERROR_HANDLER{});
550 size_t size = tof_camera_config_get_image_offsets(this->ptr_, frame,
nullptr, 0, TOF_ERROR_HANDLER{});
551 std::vector<float> vec(size);
552 size = tof_camera_config_get_image_offsets(this->ptr_, frame, vec.data(), vec.size(), TOF_ERROR_HANDLER{});
562 return tof_camera_config_set_image_offsets(this->ptr_, frame, image_offsets.data(), image_offsets.size(), TOF_ERROR_HANDLER{});
569 return tof_camera_config_get_rgb_width(this->ptr_, TOF_ERROR_HANDLER{});
576 return tof_camera_config_get_rgb_height(this->ptr_, TOF_ERROR_HANDLER{});
This class allows you to view/edit the camera settings.
void set_gain(float gain)
Set the image sensor gain.
void set_integration_time(size_t frame, const std::vector< uint32_t > &integration_time)
Set the integration time.
uint8_t get_illumination_mode(size_t frame) const
Get the illumination mode.
float get_duty_cycle(size_t frame) const
Get the duty cycle.
void set_modulation_frequency(size_t frame, float modulation_frequency)
Set the modulation frequency.
SensorMode get_sensor_mode(size_t frame) const
Get the mode to set the camera's depth sensor to.
size_t get_rgb_height()
Get the height of the rgb sensor.
size_t frame_size() const
Get the amount of frames in the config.
void set_global_phase_offset(size_t frame, const std::array< float, 2 > &phase_offset)
Set phase offset for illumination and sensor.
uint32_t get_mlx_preheat(size_t frame) const
Get the preheat time.
std::vector< float > get_phase_shifts(size_t frame) const
Get the phase shifts.
void set_image_offsets(size_t frame, const std::vector< float > &image_offsets)
Set the image offsets.
ProcessingConfig default_processing() const
Generate default processing config from camera configuration.
void erase_frame(size_t frame)
Erase specified frame.
bool get_mirror(size_t frame) const
Get is the image mirrored.
void set_mlx_mipi_speed(int32_t mipi_speed)
Set the mipi speed for the MLX75027.
void set_phase_shifts(size_t frame, const std::vector< float > &phase_shifts)
Set the phase shifts.
int32_t get_sync_mode() const
Get the kind of camera synchronization.
void set_sync_mode(int32_t sync_mode)
Set the kind of camera synchronization.
void set_mlx_preheat_enable(size_t frame, bool enable)
Set enable preheat.
std::vector< uint32_t > get_integration_time(size_t frame) const
Get the integration time.
void add_frame()
Add a default frame to the camera config.
std::array< int32_t, 2 > get_opt_kea_sub_quad() const
Get the opt8241 number of sub and quad frames.
std::vector< uint16_t > get_dac() const
Get the DAC gain.
void set_flip(size_t frame, bool flip)
Set is the image flipped.
uint8_t get_binning(size_t frame) const
Get the amount of binning.
std::vector< float > get_image_offsets(size_t frame) const
Get the image offsets.
void set_mlx_preheat(size_t frame, uint32_t preheat)
Set the preheat time.
uint32_t get_frame_time(size_t frame) const
Get the time this depth frame will take.
bool get_flip(size_t frame) const
Get is the image flipped.
void set_dac(const std::vector< uint16_t > &dac)
Set the DAC gain.
CameraConfig(tof_camera_config_t ptr=nullptr)
Construct from pointer.
Roi get_roi(size_t frame) const
Get the region of interest.
ProcessingConfig get_processing() const
Get the processing configuration for when the depth is calculated on camera.
int32_t get_mlx_mipi_speed() const
Get the mipi speed for the MLX75027.
float get_modulation_frequency(size_t frame) const
Get the modulation frequency.
CameraConfig(StringView file_location)
Read camera config from disk.
bool get_mlx_preheat_enable(size_t frame) const
Get enable preheat.
void reset()
Reset camera config to default.
size_t get_rgb_width()
Get the width of the rgb sensor.
void set_illumination_mode(size_t frame, uint8_t illumination_mode)
Set the illumination mode.
void set_roi(size_t frame, Roi &roi)
Set the region of interest.
void set_mirror(size_t frame, bool mirror)
Set is the image mirrored.
std::array< float, 2 > get_global_phase_offset(size_t frame) const
Get phase offset for illumination and sensor.
void set_duty_cycle(size_t frame, float duty_cycle)
Set the duty cycle.
void set_binning(size_t frame, uint8_t binning)
Set the amount of binning.
void write(StringView file_location) const
Write camera config to disk.
void set_frame_time(size_t frame, uint32_t frame_time)
Set the time this depth frame will take.
void set_processing(ProcessingConfig &processing)
Set the processing configuration for when the depth is calculated on camera.
std::vector< uint32_t > maximum_integration_time(size_t frame)
Get the maximum integration time possible.
void set_opt_kea_sub_quad(const std::array< int32_t, 2 > &subs_quads)
Set the opt8241 number of sub and quad frames.
void set_opt_kea_nios_hex(StringView file_location)
Set the Nios hex for the keaB cameras.
float get_gain() const
Get the image sensor gain.
void set_sensor_mode(size_t frame, SensorMode sensor_mode)
Set the mode to set the camera's depth sensor to.
CameraType get_type() const
Get the camera type.
Processing that can be done.
int32_t get_img_rows() const
Get the number of rows in the output image.
int32_t get_img_cols() const
Get the number of columns in the output image.
int32_t sensor_cols() const
Get the number of columns in the image sensor.
void set_img_rows(int32_t img_rows)
Set the number of rows in the output image.
int32_t get_row_offset() const
Get the row offset in pixels.
void set_img_cols(int32_t img_cols)
Set the number of columns in the output image.
void set_col_offset(int32_t col_offset)
Set the column offset in pixels.
void set_row_offset(int32_t row_offset)
Set the row offset in pixels.
int32_t sensor_rows() const
Get the number of rows in the image sensor.
int32_t get_col_offset() const
Get the column offset in pixels.
Roi(tof_roi_t ptr=nullptr)
Construct from pointer.