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 {
61class Roi :
public detail::Base<tof_roi, tof_roi_delete> {
64 Roi(tof_roi_t ptr =
nullptr) {
72 return tof_roi_sensor_rows(this->ptr_, TOF_ERROR_HANDLER{});
79 return tof_roi_sensor_cols(this->ptr_, TOF_ERROR_HANDLER{});
86 return tof_roi_get_row_offset(this->ptr_, TOF_ERROR_HANDLER{});
93 return tof_roi_set_row_offset(this->ptr_, row_offset, TOF_ERROR_HANDLER{});
100 return tof_roi_get_col_offset(this->ptr_, TOF_ERROR_HANDLER{});
107 return tof_roi_set_col_offset(this->ptr_, col_offset, TOF_ERROR_HANDLER{});
114 return tof_roi_get_img_rows(this->ptr_, TOF_ERROR_HANDLER{});
121 return tof_roi_set_img_rows(this->ptr_, img_rows, TOF_ERROR_HANDLER{});
128 return tof_roi_get_img_cols(this->ptr_, TOF_ERROR_HANDLER{});
135 return tof_roi_set_img_cols(this->ptr_, img_cols, TOF_ERROR_HANDLER{});
142class CameraConfig :
public detail::Base<tof_camera_config, tof_camera_config_delete> {
157 void write(StringView file_location)
const {
158 return tof_camera_config_write(this->ptr_, file_location, TOF_ERROR_HANDLER{});
165 return static_cast<CameraType
>(tof_camera_config_get_type(this->ptr_, TOF_ERROR_HANDLER{}));
171 return tof_camera_config_reset(this->ptr_, TOF_ERROR_HANDLER{});
180 return tof_camera_config_frame_size(this->ptr_, TOF_ERROR_HANDLER{});
186 return tof_camera_config_add_frame(this->ptr_, TOF_ERROR_HANDLER{});
193 ProcessingConfig new_processing_config(
static_cast<tof_processing_config_t
>(
nullptr));
194 auto ptr =
reinterpret_cast<tof_processing_config_t*
>(&new_processing_config);
195 *ptr = tof_camera_config_default_processing(this->ptr_, TOF_ERROR_HANDLER{});
196 return new_processing_config;
203 return tof_camera_config_erase_frame(this->ptr_, frame, TOF_ERROR_HANDLER{});
212 size_t size = tof_camera_config_get_phase_shifts(this->ptr_, frame,
nullptr, 0, TOF_ERROR_HANDLER{});
213 std::vector<float> vec(size);
214 size = tof_camera_config_get_phase_shifts(this->ptr_, frame, vec.data(), vec.size(), TOF_ERROR_HANDLER{});
224 return tof_camera_config_set_phase_shifts(this->ptr_, frame, phase_shifts.data(), phase_shifts.size(), TOF_ERROR_HANDLER{});
232 size_t size = tof_camera_config_get_integration_time(this->ptr_, frame,
nullptr, 0, TOF_ERROR_HANDLER{});
233 std::vector<uint32_t> vec(size);
234 size = tof_camera_config_get_integration_time(this->ptr_, frame, vec.data(), vec.size(), TOF_ERROR_HANDLER{});
243 return tof_camera_config_set_integration_time(this->ptr_, frame, integration_time.data(), integration_time.size(), TOF_ERROR_HANDLER{});
251 return static_cast<SensorMode
>(tof_camera_config_get_sensor_mode(this->ptr_, frame, TOF_ERROR_HANDLER{}));
259 return tof_camera_config_set_sensor_mode(this->ptr_, frame,
static_cast<tof_sensor_mode
>(sensor_mode), TOF_ERROR_HANDLER{});
267 return tof_camera_config_get_modulation_frequency(this->ptr_, frame, TOF_ERROR_HANDLER{});
275 return tof_camera_config_set_modulation_frequency(this->ptr_, frame, modulation_frequency, TOF_ERROR_HANDLER{});
283 return tof_camera_config_get_duty_cycle(this->ptr_, frame, TOF_ERROR_HANDLER{});
291 return tof_camera_config_set_duty_cycle(this->ptr_, frame, duty_cycle, TOF_ERROR_HANDLER{});
299 Roi new_roi(
static_cast<tof_roi_t
>(
nullptr));
300 auto ptr =
reinterpret_cast<tof_roi_t*
>(&new_roi);
301 *ptr = tof_camera_config_get_roi(this->ptr_, frame, TOF_ERROR_HANDLER{});
310 return tof_camera_config_set_roi(this->ptr_, frame, *
reinterpret_cast<tof_roi_t*
>(&roi), TOF_ERROR_HANDLER{});
318 return tof_camera_config_get_binning(this->ptr_, frame, TOF_ERROR_HANDLER{});
326 return tof_camera_config_set_binning(this->ptr_, frame, binning, TOF_ERROR_HANDLER{});
334 return tof_camera_config_get_flip(this->ptr_, frame, TOF_ERROR_HANDLER{});
342 return tof_camera_config_set_flip(this->ptr_, frame, flip, TOF_ERROR_HANDLER{});
350 return tof_camera_config_get_mirror(this->ptr_, frame, TOF_ERROR_HANDLER{});
358 return tof_camera_config_set_mirror(this->ptr_, frame, mirror, TOF_ERROR_HANDLER{});
365 return tof_camera_config_get_gain(this->ptr_, TOF_ERROR_HANDLER{});
372 return tof_camera_config_set_gain(this->ptr_, gain, TOF_ERROR_HANDLER{});
380 return tof_camera_config_get_sync_mode(this->ptr_, TOF_ERROR_HANDLER{});
388 return tof_camera_config_set_sync_mode(this->ptr_, sync_mode, TOF_ERROR_HANDLER{});
396 size_t size = tof_camera_config_maximum_integration_time(this->ptr_, frame,
nullptr, 0, TOF_ERROR_HANDLER{});
397 std::vector<uint32_t> vec(size);
398 size = tof_camera_config_maximum_integration_time(this->ptr_, frame, vec.data(), vec.size(), TOF_ERROR_HANDLER{});
407 return tof_camera_config_get_mipi_speed(this->ptr_, TOF_ERROR_HANDLER{});
415 return tof_camera_config_set_mipi_speed(this->ptr_, mipi_speed, TOF_ERROR_HANDLER{});
423 return tof_camera_config_get_mlx_preheat(this->ptr_, frame, TOF_ERROR_HANDLER{});
431 return tof_camera_config_set_mlx_preheat(this->ptr_, frame, preheat, TOF_ERROR_HANDLER{});
439 return tof_camera_config_get_mlx_preheat_enable(this->ptr_, frame, TOF_ERROR_HANDLER{});
447 return tof_camera_config_set_mlx_preheat_enable(this->ptr_, frame, enable, TOF_ERROR_HANDLER{});
454 return tof_camera_config_set_opt_kea_nios_hex(this->ptr_, file_location, TOF_ERROR_HANDLER{});
461 std::array<int32_t, 2> array;
462 auto data = tof_camera_config_get_opt_kea_sub_quad(this->ptr_, TOF_ERROR_HANDLER{});
463 std::copy(data, data + array.size(), array.data());
471 return tof_camera_config_set_opt_kea_sub_quad(this->ptr_, subs_quads.data(), TOF_ERROR_HANDLER{});
479 ProcessingConfig new_processing_config(
static_cast<tof_processing_config_t
>(
nullptr));
480 auto ptr =
reinterpret_cast<tof_processing_config_t*
>(&new_processing_config);
481 *ptr = tof_camera_config_get_processing(this->ptr_, TOF_ERROR_HANDLER{});
482 return new_processing_config;
490 return tof_camera_config_set_processing(this->ptr_, *
reinterpret_cast<tof_processing_config_t*
>(&processing), TOF_ERROR_HANDLER{});
499 return tof_camera_config_get_frame_time(this->ptr_, frame, TOF_ERROR_HANDLER{});
508 return tof_camera_config_set_frame_time(this->ptr_, frame, frame_time, TOF_ERROR_HANDLER{});
519 std::array<float, 2> array;
520 auto data = tof_camera_config_get_global_phase_offset(this->ptr_, frame, TOF_ERROR_HANDLER{});
521 std::copy(data, data + array.size(), array.data());
533 return tof_camera_config_set_global_phase_offset(this->ptr_, frame, phase_offset.data(), TOF_ERROR_HANDLER{});
542 return tof_camera_config_get_illumination_mode(this->ptr_, frame, TOF_ERROR_HANDLER{});
551 return tof_camera_config_set_illumination_mode(this->ptr_, frame, illumination_mode, TOF_ERROR_HANDLER{});
560 size_t size = tof_camera_config_get_image_offsets(this->ptr_, frame,
nullptr, 0, TOF_ERROR_HANDLER{});
561 std::vector<float> vec(size);
562 size = tof_camera_config_get_image_offsets(this->ptr_, frame, vec.data(), vec.size(), TOF_ERROR_HANDLER{});
572 return tof_camera_config_set_image_offsets(this->ptr_, frame, image_offsets.data(), image_offsets.size(), TOF_ERROR_HANDLER{});
579 return tof_camera_config_get_rgb_width(this->ptr_, TOF_ERROR_HANDLER{});
586 return tof_camera_config_get_rgb_height(this->ptr_, TOF_ERROR_HANDLER{});
593 return static_cast<TriggerMode
>(tof_camera_config_get_trigger_mode(this->ptr_, TOF_ERROR_HANDLER{}));
600 return tof_camera_config_set_trigger_mode(this->ptr_,
static_cast<tof_trigger_mode
>(trigger_mode), TOF_ERROR_HANDLER{});
607 return tof_camera_config_get_depth_fps(this->ptr_, TOF_ERROR_HANDLER{});
614 return tof_camera_config_get_name(this->ptr_, TOF_ERROR_HANDLER{});
621 return tof_camera_config_set_name(this->ptr_, name, TOF_ERROR_HANDLER{});
628 return tof_camera_config_get_description(this->ptr_, TOF_ERROR_HANDLER{});
635 return tof_camera_config_set_description(this->ptr_, description, TOF_ERROR_HANDLER{});
642 return static_cast<LightPower
>(tof_camera_config_get_light_power(this->ptr_, TOF_ERROR_HANDLER{}));
649 return tof_camera_config_set_light_power(this->ptr_,
static_cast<tof_light_power
>(light_power), TOF_ERROR_HANDLER{});
656 return tof_camera_config_has_light_power(this->ptr_, TOF_ERROR_HANDLER{});
664 return static_cast<GpioMode
>(tof_camera_config_get_gpio_mode(this->ptr_, pin, TOF_ERROR_HANDLER{}));
672 return tof_camera_config_set_gpio_mode(this->ptr_, pin,
static_cast<tof_gpio_mode
>(gpio_mode), TOF_ERROR_HANDLER{});
682inline bool camera_config_equal(
const CameraConfig &lhs,
const CameraConfig &rhs) {
683 return tof_camera_config_equal(*
reinterpret_cast<const tof_camera_config_t*
>(&lhs), *
reinterpret_cast<const tof_camera_config_t*
>(&rhs), TOF_ERROR_HANDLER{});
690inline const char* light_power_name(LightPower light_power) {
691 return tof_light_power_name(
static_cast<tof_light_power
>(light_power), TOF_ERROR_HANDLER{});
698inline const char* gpio_mode_name(GpioMode gpio_mode) {
699 return tof_gpio_mode_name(
static_cast<tof_gpio_mode
>(gpio_mode), 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.
bool has_light_power() const
Light power is set.
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 frame_size() const
Get the amount of frames in the config.
GpioMode get_gpio_mode(size_t pin) const
Get configured gpio mode.
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_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.
size_t get_rgb_width() const
Get the width of the rgb sensor.
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.
float get_depth_fps() const
Get the maximum theoretical fps the camera can run.
void set_mipi_speed(int32_t mipi_speed)
Set the mipi speed.
void add_frame()
Add a default frame to the camera config.
void set_gpio_mode(size_t pin, GpioMode gpio_mode)
Set gpio mode.
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.
std::vector< uint32_t > maximum_integration_time(size_t frame) const
Get the maximum integration time possible.
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.
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.
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.
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.
size_t get_rgb_height() const
Get the height of the rgb sensor.
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.