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 {
22enum class SensorMode {
35enum class TriggerMode {
43enum class LightPower {
51class Roi :
public detail::Base<tof_roi, tof_roi_delete> {
54 Roi(tof_roi_t ptr =
nullptr) {
62 return tof_roi_sensor_rows(this->ptr_, TOF_ERROR_HANDLER{});
69 return tof_roi_sensor_cols(this->ptr_, TOF_ERROR_HANDLER{});
76 return tof_roi_get_row_offset(this->ptr_, TOF_ERROR_HANDLER{});
83 return tof_roi_set_row_offset(this->ptr_, row_offset, TOF_ERROR_HANDLER{});
90 return tof_roi_get_col_offset(this->ptr_, TOF_ERROR_HANDLER{});
97 return tof_roi_set_col_offset(this->ptr_, col_offset, TOF_ERROR_HANDLER{});
104 return tof_roi_get_img_rows(this->ptr_, TOF_ERROR_HANDLER{});
111 return tof_roi_set_img_rows(this->ptr_, img_rows, TOF_ERROR_HANDLER{});
118 return tof_roi_get_img_cols(this->ptr_, TOF_ERROR_HANDLER{});
125 return tof_roi_set_img_cols(this->ptr_, img_cols, TOF_ERROR_HANDLER{});
132class CameraConfig :
public detail::Base<tof_camera_config, tof_camera_config_delete> {
143 this->ptr_ = tof_camera_config_new_from_disk(file_location, TOF_ERROR_HANDLER{});
149 void write(StringView file_location)
const {
150 return tof_camera_config_write(this->ptr_, file_location, TOF_ERROR_HANDLER{});
157 return static_cast<CameraType
>(tof_camera_config_get_type(this->ptr_, TOF_ERROR_HANDLER{}));
163 return tof_camera_config_reset(this->ptr_, TOF_ERROR_HANDLER{});
172 return tof_camera_config_frame_size(this->ptr_, TOF_ERROR_HANDLER{});
178 return tof_camera_config_add_frame(this->ptr_, TOF_ERROR_HANDLER{});
185 ProcessingConfig new_processing_config(
static_cast<tof_processing_config_t
>(
nullptr));
186 auto ptr =
reinterpret_cast<tof_processing_config_t*
>(&new_processing_config);
187 *ptr = tof_camera_config_default_processing(this->ptr_, TOF_ERROR_HANDLER{});
188 return new_processing_config;
195 return tof_camera_config_erase_frame(this->ptr_, frame, TOF_ERROR_HANDLER{});
204 size_t size = tof_camera_config_get_phase_shifts(this->ptr_, frame,
nullptr, 0, TOF_ERROR_HANDLER{});
205 std::vector<float> vec(size);
206 size = tof_camera_config_get_phase_shifts(this->ptr_, frame, vec.data(), vec.size(), TOF_ERROR_HANDLER{});
216 return tof_camera_config_set_phase_shifts(this->ptr_, frame, phase_shifts.data(), phase_shifts.size(), TOF_ERROR_HANDLER{});
224 size_t size = tof_camera_config_get_integration_time(this->ptr_, frame,
nullptr, 0, TOF_ERROR_HANDLER{});
225 std::vector<uint32_t> vec(size);
226 size = tof_camera_config_get_integration_time(this->ptr_, frame, vec.data(), vec.size(), TOF_ERROR_HANDLER{});
235 return tof_camera_config_set_integration_time(this->ptr_, frame, integration_time.data(), integration_time.size(), TOF_ERROR_HANDLER{});
243 return static_cast<SensorMode
>(tof_camera_config_get_sensor_mode(this->ptr_, frame, TOF_ERROR_HANDLER{}));
251 return tof_camera_config_set_sensor_mode(this->ptr_, frame,
static_cast<tof_sensor_mode
>(sensor_mode), TOF_ERROR_HANDLER{});
259 return tof_camera_config_get_modulation_frequency(this->ptr_, frame, TOF_ERROR_HANDLER{});
267 return tof_camera_config_set_modulation_frequency(this->ptr_, frame, modulation_frequency, TOF_ERROR_HANDLER{});
275 return tof_camera_config_get_duty_cycle(this->ptr_, frame, TOF_ERROR_HANDLER{});
283 return tof_camera_config_set_duty_cycle(this->ptr_, frame, duty_cycle, TOF_ERROR_HANDLER{});
291 Roi new_roi(
static_cast<tof_roi_t
>(
nullptr));
292 auto ptr =
reinterpret_cast<tof_roi_t*
>(&new_roi);
293 *ptr = tof_camera_config_get_roi(this->ptr_, frame, TOF_ERROR_HANDLER{});
302 return tof_camera_config_set_roi(this->ptr_, frame, *
reinterpret_cast<tof_roi_t*
>(&roi), TOF_ERROR_HANDLER{});
310 return tof_camera_config_get_binning(this->ptr_, frame, TOF_ERROR_HANDLER{});
318 return tof_camera_config_set_binning(this->ptr_, frame, binning, TOF_ERROR_HANDLER{});
326 return tof_camera_config_get_flip(this->ptr_, frame, TOF_ERROR_HANDLER{});
334 return tof_camera_config_set_flip(this->ptr_, frame, flip, TOF_ERROR_HANDLER{});
342 return tof_camera_config_get_mirror(this->ptr_, frame, TOF_ERROR_HANDLER{});
350 return tof_camera_config_set_mirror(this->ptr_, frame, mirror, TOF_ERROR_HANDLER{});
357 return tof_camera_config_get_gain(this->ptr_, TOF_ERROR_HANDLER{});
364 return tof_camera_config_set_gain(this->ptr_, gain, TOF_ERROR_HANDLER{});
372 return tof_camera_config_get_sync_mode(this->ptr_, TOF_ERROR_HANDLER{});
380 return tof_camera_config_set_sync_mode(this->ptr_, sync_mode, TOF_ERROR_HANDLER{});
388 size_t size = tof_camera_config_maximum_integration_time(this->ptr_, frame,
nullptr, 0, TOF_ERROR_HANDLER{});
389 std::vector<uint32_t> vec(size);
390 size = tof_camera_config_maximum_integration_time(this->ptr_, frame, vec.data(), vec.size(), TOF_ERROR_HANDLER{});
398 size_t size = tof_camera_config_get_dac(this->ptr_,
nullptr, 0, TOF_ERROR_HANDLER{});
399 std::vector<uint16_t> vec(size);
400 size = tof_camera_config_get_dac(this->ptr_, vec.data(), vec.size(), TOF_ERROR_HANDLER{});
407 void set_dac(
const std::vector<uint16_t> &dac) {
408 return tof_camera_config_set_dac(this->ptr_, dac.data(), dac.size(), TOF_ERROR_HANDLER{});
415 return tof_camera_config_get_mlx_mipi_speed(this->ptr_, TOF_ERROR_HANDLER{});
423 return tof_camera_config_set_mlx_mipi_speed(this->ptr_, mipi_speed, TOF_ERROR_HANDLER{});
430 return tof_camera_config_get_mipi_speed(this->ptr_, TOF_ERROR_HANDLER{});
437 return tof_camera_config_set_mipi_speed(this->ptr_, mipi_speed, TOF_ERROR_HANDLER{});
445 return tof_camera_config_get_mlx_preheat(this->ptr_, frame, TOF_ERROR_HANDLER{});
453 return tof_camera_config_set_mlx_preheat(this->ptr_, frame, preheat, TOF_ERROR_HANDLER{});
461 return tof_camera_config_get_mlx_preheat_enable(this->ptr_, frame, TOF_ERROR_HANDLER{});
469 return tof_camera_config_set_mlx_preheat_enable(this->ptr_, frame, enable, TOF_ERROR_HANDLER{});
476 return tof_camera_config_set_opt_kea_nios_hex(this->ptr_, file_location, TOF_ERROR_HANDLER{});
483 std::array<int32_t, 2> array;
484 auto data = tof_camera_config_get_opt_kea_sub_quad(this->ptr_, TOF_ERROR_HANDLER{});
485 std::copy(data, data + array.size(), array.data());
493 return tof_camera_config_set_opt_kea_sub_quad(this->ptr_, subs_quads.data(), TOF_ERROR_HANDLER{});
501 ProcessingConfig new_processing_config(
static_cast<tof_processing_config_t
>(
nullptr));
502 auto ptr =
reinterpret_cast<tof_processing_config_t*
>(&new_processing_config);
503 *ptr = tof_camera_config_get_processing(this->ptr_, TOF_ERROR_HANDLER{});
504 return new_processing_config;
512 return tof_camera_config_set_processing(this->ptr_, *
reinterpret_cast<tof_processing_config_t*
>(&processing), TOF_ERROR_HANDLER{});
521 return tof_camera_config_get_frame_time(this->ptr_, frame, TOF_ERROR_HANDLER{});
530 return tof_camera_config_set_frame_time(this->ptr_, frame, frame_time, TOF_ERROR_HANDLER{});
541 std::array<float, 2> array;
542 auto data = tof_camera_config_get_global_phase_offset(this->ptr_, frame, TOF_ERROR_HANDLER{});
543 std::copy(data, data + array.size(), array.data());
555 return tof_camera_config_set_global_phase_offset(this->ptr_, frame, phase_offset.data(), TOF_ERROR_HANDLER{});
564 return tof_camera_config_get_illumination_mode(this->ptr_, frame, TOF_ERROR_HANDLER{});
573 return tof_camera_config_set_illumination_mode(this->ptr_, frame, illumination_mode, TOF_ERROR_HANDLER{});
582 size_t size = tof_camera_config_get_image_offsets(this->ptr_, frame,
nullptr, 0, TOF_ERROR_HANDLER{});
583 std::vector<float> vec(size);
584 size = tof_camera_config_get_image_offsets(this->ptr_, frame, vec.data(), vec.size(), TOF_ERROR_HANDLER{});
594 return tof_camera_config_set_image_offsets(this->ptr_, frame, image_offsets.data(), image_offsets.size(), TOF_ERROR_HANDLER{});
601 return tof_camera_config_get_rgb_width(this->ptr_, TOF_ERROR_HANDLER{});
608 return tof_camera_config_get_rgb_height(this->ptr_, TOF_ERROR_HANDLER{});
615 return static_cast<TriggerMode
>(tof_camera_config_get_trigger_mode(this->ptr_, TOF_ERROR_HANDLER{}));
622 return tof_camera_config_set_trigger_mode(this->ptr_,
static_cast<tof_trigger_mode
>(trigger_mode), TOF_ERROR_HANDLER{});
629 return tof_camera_config_get_depth_fps(this->ptr_, TOF_ERROR_HANDLER{});
636 return tof_camera_config_get_name(this->ptr_, TOF_ERROR_HANDLER{});
643 return tof_camera_config_set_name(this->ptr_, name, TOF_ERROR_HANDLER{});
650 return tof_camera_config_get_description(this->ptr_, TOF_ERROR_HANDLER{});
657 return tof_camera_config_set_description(this->ptr_, description, TOF_ERROR_HANDLER{});
664 return static_cast<LightPower
>(tof_camera_config_get_light_power(this->ptr_, TOF_ERROR_HANDLER{}));
671 return tof_camera_config_set_light_power(this->ptr_,
static_cast<tof_light_power
>(light_power), TOF_ERROR_HANDLER{});
678 return tof_camera_config_has_light_power(this->ptr_, TOF_ERROR_HANDLER{});
688inline bool camera_config_equal(
const CameraConfig &lhs,
const CameraConfig &rhs) {
689 return tof_camera_config_equal(*
reinterpret_cast<const tof_camera_config_t*
>(&lhs), *
reinterpret_cast<const tof_camera_config_t*
>(&rhs), TOF_ERROR_HANDLER{});
696inline const char* light_power_name(LightPower light_power) {
697 return tof_light_power_name(
static_cast<tof_light_power
>(light_power), TOF_ERROR_HANDLER{});
This class allows you to view/edit the camera settings.
void set_description(StringView description)
Set the description.
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.
float get_depth_fps()
Get the maximum theoretical fps the camera can run.
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_light_power(LightPower light_power)
Set the light power.
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 set_mipi_speed(int32_t mipi_speed)
Set the mipi speed.
bool has_light_power()
Light power is set.
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.
const char * get_name() const
Get the configuration name.
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.
void set_name(StringView name)
Set the configuration name.
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.
int32_t get_mipi_speed() const
Get the mipi speed.
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.
LightPower get_light_power() const
Get the light power.
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.
const char * get_description() const
Get the description.
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.