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>
13enum class CameraType {
21enum class SensorMode {
33enum class TriggerMode {
41class Roi :
public detail::Base<tof_roi, tof_roi_delete> {
44 Roi(tof_roi_t ptr =
nullptr) {
52 return tof_roi_sensor_rows(this->ptr_, TOF_ERROR_HANDLER{});
59 return tof_roi_sensor_cols(this->ptr_, TOF_ERROR_HANDLER{});
66 return tof_roi_get_row_offset(this->ptr_, TOF_ERROR_HANDLER{});
73 return tof_roi_set_row_offset(this->ptr_, row_offset, TOF_ERROR_HANDLER{});
80 return tof_roi_get_col_offset(this->ptr_, TOF_ERROR_HANDLER{});
87 return tof_roi_set_col_offset(this->ptr_, col_offset, TOF_ERROR_HANDLER{});
94 return tof_roi_get_img_rows(this->ptr_, TOF_ERROR_HANDLER{});
101 return tof_roi_set_img_rows(this->ptr_, img_rows, TOF_ERROR_HANDLER{});
108 return tof_roi_get_img_cols(this->ptr_, TOF_ERROR_HANDLER{});
115 return tof_roi_set_img_cols(this->ptr_, img_cols, TOF_ERROR_HANDLER{});
122class CameraConfig :
public detail::Base<tof_camera_config, tof_camera_config_delete> {
133 this->ptr_ = tof_camera_config_new_from_disk(file_location, TOF_ERROR_HANDLER{});
139 void write(StringView file_location)
const {
140 return tof_camera_config_write(this->ptr_, file_location, TOF_ERROR_HANDLER{});
147 return static_cast<CameraType
>(tof_camera_config_get_type(this->ptr_, TOF_ERROR_HANDLER{}));
153 return tof_camera_config_reset(this->ptr_, TOF_ERROR_HANDLER{});
162 return tof_camera_config_frame_size(this->ptr_, TOF_ERROR_HANDLER{});
168 return tof_camera_config_add_frame(this->ptr_, TOF_ERROR_HANDLER{});
175 ProcessingConfig new_processing_config(
static_cast<tof_processing_config_t
>(
nullptr));
176 auto ptr =
reinterpret_cast<tof_processing_config_t*
>(&new_processing_config);
177 *ptr = tof_camera_config_default_processing(this->ptr_, TOF_ERROR_HANDLER{});
178 return new_processing_config;
185 return tof_camera_config_erase_frame(this->ptr_, frame, TOF_ERROR_HANDLER{});
194 size_t size = tof_camera_config_get_phase_shifts(this->ptr_, frame,
nullptr, 0, TOF_ERROR_HANDLER{});
195 std::vector<float> vec(size);
196 size = tof_camera_config_get_phase_shifts(this->ptr_, frame, vec.data(), vec.size(), TOF_ERROR_HANDLER{});
206 return tof_camera_config_set_phase_shifts(this->ptr_, frame, phase_shifts.data(), phase_shifts.size(), TOF_ERROR_HANDLER{});
214 size_t size = tof_camera_config_get_integration_time(this->ptr_, frame,
nullptr, 0, TOF_ERROR_HANDLER{});
215 std::vector<uint32_t> vec(size);
216 size = tof_camera_config_get_integration_time(this->ptr_, frame, vec.data(), vec.size(), TOF_ERROR_HANDLER{});
225 return tof_camera_config_set_integration_time(this->ptr_, frame, integration_time.data(), integration_time.size(), TOF_ERROR_HANDLER{});
233 return static_cast<SensorMode
>(tof_camera_config_get_sensor_mode(this->ptr_, frame, TOF_ERROR_HANDLER{}));
241 return tof_camera_config_set_sensor_mode(this->ptr_, frame,
static_cast<tof_sensor_mode
>(sensor_mode), TOF_ERROR_HANDLER{});
249 return tof_camera_config_get_modulation_frequency(this->ptr_, frame, TOF_ERROR_HANDLER{});
257 return tof_camera_config_set_modulation_frequency(this->ptr_, frame, modulation_frequency, TOF_ERROR_HANDLER{});
265 return tof_camera_config_get_duty_cycle(this->ptr_, frame, TOF_ERROR_HANDLER{});
273 return tof_camera_config_set_duty_cycle(this->ptr_, frame, duty_cycle, TOF_ERROR_HANDLER{});
281 Roi new_roi(
static_cast<tof_roi_t
>(
nullptr));
282 auto ptr =
reinterpret_cast<tof_roi_t*
>(&new_roi);
283 *ptr = tof_camera_config_get_roi(this->ptr_, frame, TOF_ERROR_HANDLER{});
292 return tof_camera_config_set_roi(this->ptr_, frame, *
reinterpret_cast<tof_roi_t*
>(&roi), TOF_ERROR_HANDLER{});
300 return tof_camera_config_get_binning(this->ptr_, frame, TOF_ERROR_HANDLER{});
308 return tof_camera_config_set_binning(this->ptr_, frame, binning, TOF_ERROR_HANDLER{});
316 return tof_camera_config_get_flip(this->ptr_, frame, TOF_ERROR_HANDLER{});
324 return tof_camera_config_set_flip(this->ptr_, frame, flip, TOF_ERROR_HANDLER{});
332 return tof_camera_config_get_mirror(this->ptr_, frame, TOF_ERROR_HANDLER{});
340 return tof_camera_config_set_mirror(this->ptr_, frame, mirror, TOF_ERROR_HANDLER{});
347 return tof_camera_config_get_gain(this->ptr_, TOF_ERROR_HANDLER{});
354 return tof_camera_config_set_gain(this->ptr_, gain, TOF_ERROR_HANDLER{});
362 return tof_camera_config_get_sync_mode(this->ptr_, TOF_ERROR_HANDLER{});
370 return tof_camera_config_set_sync_mode(this->ptr_, sync_mode, TOF_ERROR_HANDLER{});
378 size_t size = tof_camera_config_maximum_integration_time(this->ptr_, frame,
nullptr, 0, TOF_ERROR_HANDLER{});
379 std::vector<uint32_t> vec(size);
380 size = tof_camera_config_maximum_integration_time(this->ptr_, frame, vec.data(), vec.size(), TOF_ERROR_HANDLER{});
388 size_t size = tof_camera_config_get_dac(this->ptr_,
nullptr, 0, TOF_ERROR_HANDLER{});
389 std::vector<uint16_t> vec(size);
390 size = tof_camera_config_get_dac(this->ptr_, vec.data(), vec.size(), TOF_ERROR_HANDLER{});
397 void set_dac(
const std::vector<uint16_t> &dac) {
398 return tof_camera_config_set_dac(this->ptr_, dac.data(), dac.size(), TOF_ERROR_HANDLER{});
405 return tof_camera_config_get_mlx_mipi_speed(this->ptr_, TOF_ERROR_HANDLER{});
413 return tof_camera_config_set_mlx_mipi_speed(this->ptr_, mipi_speed, TOF_ERROR_HANDLER{});
421 return tof_camera_config_get_mlx_preheat(this->ptr_, frame, TOF_ERROR_HANDLER{});
429 return tof_camera_config_set_mlx_preheat(this->ptr_, frame, preheat, TOF_ERROR_HANDLER{});
437 return tof_camera_config_get_mlx_preheat_enable(this->ptr_, frame, TOF_ERROR_HANDLER{});
445 return tof_camera_config_set_mlx_preheat_enable(this->ptr_, frame, enable, TOF_ERROR_HANDLER{});
452 return tof_camera_config_set_opt_kea_nios_hex(this->ptr_, file_location, TOF_ERROR_HANDLER{});
459 std::array<int32_t, 2> array;
460 auto data = tof_camera_config_get_opt_kea_sub_quad(this->ptr_, TOF_ERROR_HANDLER{});
461 std::copy(data, data + array.size(), array.data());
469 return tof_camera_config_set_opt_kea_sub_quad(this->ptr_, subs_quads.data(), TOF_ERROR_HANDLER{});
477 ProcessingConfig new_processing_config(
static_cast<tof_processing_config_t
>(
nullptr));
478 auto ptr =
reinterpret_cast<tof_processing_config_t*
>(&new_processing_config);
479 *ptr = tof_camera_config_get_processing(this->ptr_, TOF_ERROR_HANDLER{});
480 return new_processing_config;
488 return tof_camera_config_set_processing(this->ptr_, *
reinterpret_cast<tof_processing_config_t*
>(&processing), TOF_ERROR_HANDLER{});
497 return tof_camera_config_get_frame_time(this->ptr_, frame, TOF_ERROR_HANDLER{});
506 return tof_camera_config_set_frame_time(this->ptr_, frame, frame_time, TOF_ERROR_HANDLER{});
517 std::array<float, 2> array;
518 auto data = tof_camera_config_get_global_phase_offset(this->ptr_, frame, TOF_ERROR_HANDLER{});
519 std::copy(data, data + array.size(), array.data());
531 return tof_camera_config_set_global_phase_offset(this->ptr_, frame, phase_offset.data(), TOF_ERROR_HANDLER{});
540 return tof_camera_config_get_illumination_mode(this->ptr_, frame, TOF_ERROR_HANDLER{});
549 return tof_camera_config_set_illumination_mode(this->ptr_, frame, illumination_mode, TOF_ERROR_HANDLER{});
558 size_t size = tof_camera_config_get_image_offsets(this->ptr_, frame,
nullptr, 0, TOF_ERROR_HANDLER{});
559 std::vector<float> vec(size);
560 size = tof_camera_config_get_image_offsets(this->ptr_, frame, vec.data(), vec.size(), TOF_ERROR_HANDLER{});
570 return tof_camera_config_set_image_offsets(this->ptr_, frame, image_offsets.data(), image_offsets.size(), TOF_ERROR_HANDLER{});
577 return tof_camera_config_get_rgb_width(this->ptr_, TOF_ERROR_HANDLER{});
584 return tof_camera_config_get_rgb_height(this->ptr_, TOF_ERROR_HANDLER{});
591 return static_cast<TriggerMode
>(tof_camera_config_get_trigger_mode(this->ptr_, TOF_ERROR_HANDLER{}));
598 return tof_camera_config_set_trigger_mode(this->ptr_,
static_cast<tof_trigger_mode
>(trigger_mode), 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.
std::vector< float > get_phase_shifts(size_t frame) const
Get the phase shifts.
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.
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.
void set_trigger_mode(TriggerMode trigger_mode)
Set the trigger mode.
std::array< int32_t, 2 > get_opt_kea_sub_quad() const
Get the opt8241 number of sub and quad frames.
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.
void add_frame()
Add a default frame to the camera config.
std::vector< uint32_t > maximum_integration_time(size_t frame)
Get the maximum integration time possible.
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::array< float, 2 > get_global_phase_offset(size_t frame) const
Get phase offset for illumination and sensor.
std::vector< uint32_t > get_integration_time(size_t frame) const
Get the integration time.
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.
std::vector< uint16_t > get_dac() const
Get 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.
std::vector< float > get_image_offsets(size_t frame) const
Get the image offsets.
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.
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.
TriggerMode get_trigger_mode() const
Get the trigger mode.
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.