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 {
43class Roi :
public detail::Base<tof_roi, tof_roi_delete> {
46 Roi(tof_roi_t ptr =
nullptr) {
54 return tof_roi_sensor_rows(this->ptr_, TOF_ERROR_HANDLER{});
61 return tof_roi_sensor_cols(this->ptr_, TOF_ERROR_HANDLER{});
68 return tof_roi_get_row_offset(this->ptr_, TOF_ERROR_HANDLER{});
75 return tof_roi_set_row_offset(this->ptr_, row_offset, TOF_ERROR_HANDLER{});
82 return tof_roi_get_col_offset(this->ptr_, TOF_ERROR_HANDLER{});
89 return tof_roi_set_col_offset(this->ptr_, col_offset, TOF_ERROR_HANDLER{});
96 return tof_roi_get_img_rows(this->ptr_, TOF_ERROR_HANDLER{});
103 return tof_roi_set_img_rows(this->ptr_, img_rows, TOF_ERROR_HANDLER{});
110 return tof_roi_get_img_cols(this->ptr_, TOF_ERROR_HANDLER{});
117 return tof_roi_set_img_cols(this->ptr_, img_cols, TOF_ERROR_HANDLER{});
124class CameraConfig :
public detail::Base<tof_camera_config, tof_camera_config_delete> {
135 this->ptr_ = tof_camera_config_new_from_disk(file_location, TOF_ERROR_HANDLER{});
141 void write(StringView file_location)
const {
142 return tof_camera_config_write(this->ptr_, file_location, TOF_ERROR_HANDLER{});
149 return static_cast<CameraType
>(tof_camera_config_get_type(this->ptr_, TOF_ERROR_HANDLER{}));
155 return tof_camera_config_reset(this->ptr_, TOF_ERROR_HANDLER{});
164 return tof_camera_config_frame_size(this->ptr_, TOF_ERROR_HANDLER{});
170 return tof_camera_config_add_frame(this->ptr_, TOF_ERROR_HANDLER{});
177 ProcessingConfig new_processing_config(
static_cast<tof_processing_config_t
>(
nullptr));
178 auto ptr =
reinterpret_cast<tof_processing_config_t*
>(&new_processing_config);
179 *ptr = tof_camera_config_default_processing(this->ptr_, TOF_ERROR_HANDLER{});
180 return new_processing_config;
187 return tof_camera_config_erase_frame(this->ptr_, frame, TOF_ERROR_HANDLER{});
196 size_t size = tof_camera_config_get_phase_shifts(this->ptr_, frame,
nullptr, 0, TOF_ERROR_HANDLER{});
197 std::vector<float> vec(size);
198 size = tof_camera_config_get_phase_shifts(this->ptr_, frame, vec.data(), vec.size(), TOF_ERROR_HANDLER{});
208 return tof_camera_config_set_phase_shifts(this->ptr_, frame, phase_shifts.data(), phase_shifts.size(), TOF_ERROR_HANDLER{});
216 size_t size = tof_camera_config_get_integration_time(this->ptr_, frame,
nullptr, 0, TOF_ERROR_HANDLER{});
217 std::vector<uint32_t> vec(size);
218 size = tof_camera_config_get_integration_time(this->ptr_, frame, vec.data(), vec.size(), TOF_ERROR_HANDLER{});
227 return tof_camera_config_set_integration_time(this->ptr_, frame, integration_time.data(), integration_time.size(), TOF_ERROR_HANDLER{});
235 return static_cast<SensorMode
>(tof_camera_config_get_sensor_mode(this->ptr_, frame, TOF_ERROR_HANDLER{}));
243 return tof_camera_config_set_sensor_mode(this->ptr_, frame,
static_cast<tof_sensor_mode
>(sensor_mode), TOF_ERROR_HANDLER{});
251 return tof_camera_config_get_modulation_frequency(this->ptr_, frame, TOF_ERROR_HANDLER{});
259 return tof_camera_config_set_modulation_frequency(this->ptr_, frame, modulation_frequency, TOF_ERROR_HANDLER{});
267 return tof_camera_config_get_duty_cycle(this->ptr_, frame, TOF_ERROR_HANDLER{});
275 return tof_camera_config_set_duty_cycle(this->ptr_, frame, duty_cycle, TOF_ERROR_HANDLER{});
283 Roi new_roi(
static_cast<tof_roi_t
>(
nullptr));
284 auto ptr =
reinterpret_cast<tof_roi_t*
>(&new_roi);
285 *ptr = tof_camera_config_get_roi(this->ptr_, frame, TOF_ERROR_HANDLER{});
294 return tof_camera_config_set_roi(this->ptr_, frame, *
reinterpret_cast<tof_roi_t*
>(&roi), TOF_ERROR_HANDLER{});
302 return tof_camera_config_get_binning(this->ptr_, frame, TOF_ERROR_HANDLER{});
310 return tof_camera_config_set_binning(this->ptr_, frame, binning, TOF_ERROR_HANDLER{});
318 return tof_camera_config_get_flip(this->ptr_, frame, TOF_ERROR_HANDLER{});
326 return tof_camera_config_set_flip(this->ptr_, frame, flip, TOF_ERROR_HANDLER{});
334 return tof_camera_config_get_mirror(this->ptr_, frame, TOF_ERROR_HANDLER{});
342 return tof_camera_config_set_mirror(this->ptr_, frame, mirror, TOF_ERROR_HANDLER{});
349 return tof_camera_config_get_gain(this->ptr_, TOF_ERROR_HANDLER{});
356 return tof_camera_config_set_gain(this->ptr_, gain, TOF_ERROR_HANDLER{});
364 return tof_camera_config_get_sync_mode(this->ptr_, TOF_ERROR_HANDLER{});
372 return tof_camera_config_set_sync_mode(this->ptr_, sync_mode, TOF_ERROR_HANDLER{});
380 size_t size = tof_camera_config_maximum_integration_time(this->ptr_, frame,
nullptr, 0, TOF_ERROR_HANDLER{});
381 std::vector<uint32_t> vec(size);
382 size = tof_camera_config_maximum_integration_time(this->ptr_, frame, vec.data(), vec.size(), TOF_ERROR_HANDLER{});
390 size_t size = tof_camera_config_get_dac(this->ptr_,
nullptr, 0, TOF_ERROR_HANDLER{});
391 std::vector<uint16_t> vec(size);
392 size = tof_camera_config_get_dac(this->ptr_, vec.data(), vec.size(), TOF_ERROR_HANDLER{});
399 void set_dac(
const std::vector<uint16_t> &dac) {
400 return tof_camera_config_set_dac(this->ptr_, dac.data(), dac.size(), TOF_ERROR_HANDLER{});
407 return tof_camera_config_get_mlx_mipi_speed(this->ptr_, TOF_ERROR_HANDLER{});
415 return tof_camera_config_set_mlx_mipi_speed(this->ptr_, mipi_speed, TOF_ERROR_HANDLER{});
422 return tof_camera_config_get_mipi_speed(this->ptr_, TOF_ERROR_HANDLER{});
429 return tof_camera_config_set_mipi_speed(this->ptr_, mipi_speed, TOF_ERROR_HANDLER{});
437 return tof_camera_config_get_mlx_preheat(this->ptr_, frame, TOF_ERROR_HANDLER{});
445 return tof_camera_config_set_mlx_preheat(this->ptr_, frame, preheat, TOF_ERROR_HANDLER{});
453 return tof_camera_config_get_mlx_preheat_enable(this->ptr_, frame, TOF_ERROR_HANDLER{});
461 return tof_camera_config_set_mlx_preheat_enable(this->ptr_, frame, enable, TOF_ERROR_HANDLER{});
468 return tof_camera_config_set_opt_kea_nios_hex(this->ptr_, file_location, TOF_ERROR_HANDLER{});
475 std::array<int32_t, 2> array;
476 auto data = tof_camera_config_get_opt_kea_sub_quad(this->ptr_, TOF_ERROR_HANDLER{});
477 std::copy(data, data + array.size(), array.data());
485 return tof_camera_config_set_opt_kea_sub_quad(this->ptr_, subs_quads.data(), TOF_ERROR_HANDLER{});
493 ProcessingConfig new_processing_config(
static_cast<tof_processing_config_t
>(
nullptr));
494 auto ptr =
reinterpret_cast<tof_processing_config_t*
>(&new_processing_config);
495 *ptr = tof_camera_config_get_processing(this->ptr_, TOF_ERROR_HANDLER{});
496 return new_processing_config;
504 return tof_camera_config_set_processing(this->ptr_, *
reinterpret_cast<tof_processing_config_t*
>(&processing), TOF_ERROR_HANDLER{});
513 return tof_camera_config_get_frame_time(this->ptr_, frame, TOF_ERROR_HANDLER{});
522 return tof_camera_config_set_frame_time(this->ptr_, frame, frame_time, TOF_ERROR_HANDLER{});
533 std::array<float, 2> array;
534 auto data = tof_camera_config_get_global_phase_offset(this->ptr_, frame, TOF_ERROR_HANDLER{});
535 std::copy(data, data + array.size(), array.data());
547 return tof_camera_config_set_global_phase_offset(this->ptr_, frame, phase_offset.data(), TOF_ERROR_HANDLER{});
556 return tof_camera_config_get_illumination_mode(this->ptr_, frame, TOF_ERROR_HANDLER{});
565 return tof_camera_config_set_illumination_mode(this->ptr_, frame, illumination_mode, TOF_ERROR_HANDLER{});
574 size_t size = tof_camera_config_get_image_offsets(this->ptr_, frame,
nullptr, 0, TOF_ERROR_HANDLER{});
575 std::vector<float> vec(size);
576 size = tof_camera_config_get_image_offsets(this->ptr_, frame, vec.data(), vec.size(), TOF_ERROR_HANDLER{});
586 return tof_camera_config_set_image_offsets(this->ptr_, frame, image_offsets.data(), image_offsets.size(), TOF_ERROR_HANDLER{});
593 return tof_camera_config_get_rgb_width(this->ptr_, TOF_ERROR_HANDLER{});
600 return tof_camera_config_get_rgb_height(this->ptr_, TOF_ERROR_HANDLER{});
607 return static_cast<TriggerMode
>(tof_camera_config_get_trigger_mode(this->ptr_, TOF_ERROR_HANDLER{}));
614 return tof_camera_config_set_trigger_mode(this->ptr_,
static_cast<tof_trigger_mode
>(trigger_mode), TOF_ERROR_HANDLER{});
621 return tof_camera_config_get_depth_fps(this->ptr_, TOF_ERROR_HANDLER{});
631inline bool camera_config_equal(
const CameraConfig &lhs,
const CameraConfig &rhs) {
632 return tof_camera_config_equal(*
reinterpret_cast<const tof_camera_config_t*
>(&lhs), *
reinterpret_cast<const tof_camera_config_t*
>(&rhs), 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.
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_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.
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.
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.
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.