Time-of-Flight Library(ToF)  3.2.2
user_config.hpp
1 #ifndef _CHRONOPTICS_TOF_USER_CONFIG_HPP_
2 #define _CHRONOPTICS_TOF_USER_CONFIG_HPP_
3 
4 #include <chronoptics/tof/user_config.h>
5 
6 #include <chronoptics/tof/camera_config.hpp>
7 #include <chronoptics/tof/camera.hpp>
8 
9 namespace chronoptics {
10 namespace tof {
11 
12 /** The integration time as fixed presets
13  */
14 enum class IntegrationTime {
15  SHORT = 0, /** 250 us */
16  MEDIUM = 1, /** 500 us */
17  LONG = 2, /** 1000us */
18 };
19 
20 /** The different imaging environments
21  */
22 enum class ImagingEnvironment {
23  INSIDE = 0, /** Inside buildings */
24  SUNLIGHT = 1, /** When bright sunlight is present */
25 };
26 
27 /** The optimization of the camera configuration
28  */
29 enum class Strategy {
30  BALANCED = 0, /** The balanced configuration */
31  SPEED = 1, /** Optimize for moving objects */
32  ACCURACY = 2, /** Optimize for high accuracy */
33 };
34 
35 /** Simple interface for camera configuration generation
36 */
37 class UserConfig : public detail::Base<tof_user_config, tof_user_config_delete> {
38  public:
39  /** Construct from pointer */
40  UserConfig(tof_user_config_t ptr) {
41  this->ptr_ = ptr;
42  }
43 
44  /** Create default user config
45  */
47  this->ptr_ = tof_user_config_new_default(TOF_ERROR_HANDLER{});
48  }
49 
50  /** Convert to a camera configuration
51  * @param camera The camera
52  * @return The camera configuration
53  */
55  CameraConfig new_camera_config(static_cast<tof_camera_config_t>(nullptr));
56  auto ptr = reinterpret_cast<tof_camera_config_t*>(&new_camera_config);
57  *ptr = tof_user_config_to_camera_config(this->ptr_, *reinterpret_cast<tof_camera_t*>(&camera), TOF_ERROR_HANDLER{});
58  return new_camera_config;
59  }
60 
61  /** Get the camera operating environment
62  * @return Imaging environment
63  */
64  ImagingEnvironment get_environment() const {
65  return static_cast<ImagingEnvironment>(tof_user_config_get_environment(this->ptr_, TOF_ERROR_HANDLER{}));
66  }
67 
68  /** Set the camera operating environment
69  * @param imaging_environment Imaging environment
70  */
71  void set_environment(ImagingEnvironment imaging_environment) {
72  return tof_user_config_set_environment(this->ptr_, static_cast<tof_imaging_environment>(imaging_environment), TOF_ERROR_HANDLER{});
73  }
74 
75  /** Get the maximum distance photons reflect from
76  * @return Maximum distance
77  */
78  float get_max_distance() const {
79  return tof_user_config_get_max_distance(this->ptr_, TOF_ERROR_HANDLER{});
80  }
81 
82  /** Set the maximum distance photons reflect from
83  * @param max_distance Maximum distance
84  */
85  void set_max_distance(float max_distance) {
86  return tof_user_config_set_max_distance(this->ptr_, max_distance, TOF_ERROR_HANDLER{});
87  }
88 
89  /** Get the depth frame rate
90  * @return The depth fps
91  */
92  float get_fps() const {
93  return tof_user_config_get_fps(this->ptr_, TOF_ERROR_HANDLER{});
94  }
95 
96  /** Set the depth frame rate
97  * @param fps The depth fps
98  */
99  void set_fps(float fps) {
100  return tof_user_config_set_fps(this->ptr_, fps, TOF_ERROR_HANDLER{});
101  }
102 
103  /** Get if lens flare is expected in the scene
104  * @return if lens flare is present
105  */
106  bool get_lens_flare() const {
107  return tof_user_config_get_lens_flare(this->ptr_, TOF_ERROR_HANDLER{});
108  }
109 
110  /** Set if lens flare is expected in the scene
111  * @param lens_flare if lens flare is present
112  */
113  void set_lens_flare(bool lens_flare) {
114  return tof_user_config_set_lens_flare(this->ptr_, lens_flare, TOF_ERROR_HANDLER{});
115  }
116 
117  /** Get if there are translucent objects in the scene
118  * @return If translucent objects
119  */
120  bool get_translucent() const {
121  return tof_user_config_get_translucent(this->ptr_, TOF_ERROR_HANDLER{});
122  }
123 
124  /** Set if there are translucent objects in the scene
125  * @param translucent If translucent objects
126  */
127  void set_translucent(bool translucent) {
128  return tof_user_config_set_translucent(this->ptr_, translucent, TOF_ERROR_HANDLER{});
129  }
130 
131  /** Get high dynamic range enabled. Enable this when pixel saturation occurs.
132  * This will only happen for retroreflectors or reflective objects close
133  * (<20cm) to the camera
134  * @return Enable high dynamic range
135  */
136  bool get_hdr() const {
137  return tof_user_config_get_hdr(this->ptr_, TOF_ERROR_HANDLER{});
138  }
139 
140  /** Set high dynamic range enabled. Enable this when pixel saturation occurs.
141  * This will only happen for retroreflectors or reflective objects close
142  * (<20cm) to the camera
143  * @param hdr Enable high dynamic range
144  */
145  void set_hdr(bool hdr) {
146  return tof_user_config_set_hdr(this->ptr_, hdr, TOF_ERROR_HANDLER{});
147  }
148 
149  /** Get the integration time
150  * @return The integration time
151  */
152  IntegrationTime get_integration_time() const {
153  return static_cast<IntegrationTime>(tof_user_config_get_integration_time(this->ptr_, TOF_ERROR_HANDLER{}));
154  }
155 
156  /** Set the integration time
157  * @param int_time The integration time
158  */
159  void set_integration_time(IntegrationTime int_time) {
160  return tof_user_config_set_integration_time(this->ptr_, static_cast<tof_integration_time>(int_time), TOF_ERROR_HANDLER{});
161  }
162 
163  /** Get what the configuration is being optimized for
164  * @return The user configuration strategy
165  */
166  Strategy get_strategy() const {
167  return static_cast<Strategy>(tof_user_config_get_strategy(this->ptr_, TOF_ERROR_HANDLER{}));
168  }
169 
170  /** Set what the configuration is being optimized for
171  * @param strategy The user configuration strategy
172  */
173  void set_strategy(Strategy strategy) {
174  return tof_user_config_set_strategy(this->ptr_, static_cast<tof_strategy>(strategy), TOF_ERROR_HANDLER{});
175  }
176 
177  /** Get The camera channel, increment to support multi-camera usage
178  * @return The channel number, set to 0, otherwise increment with number of
179  * cameras.
180  */
181  int32_t get_channel() const {
182  return tof_user_config_get_channel(this->ptr_, TOF_ERROR_HANDLER{});
183  }
184 
185  /** Set The camera channel, increment to support multi-camera usage
186  * @param channel The channel number, set to 0, otherwise increment with
187  * number of cameras.
188  */
189  void set_channel(int32_t channel) {
190  return tof_user_config_set_channel(this->ptr_, channel, TOF_ERROR_HANDLER{});
191  }
192 
193 };
194 
195 } // tof
196 } // chronoptics
197 
198 #endif
This class allows you to view/edit the camera settings.
The main interface to the depth cameras.
Definition: camera.hpp:17
Simple interface for camera configuration generation.
Definition: user_config.hpp:37
bool get_translucent() const
Get if there are translucent objects in the scene.
UserConfig(tof_user_config_t ptr)
Construct from pointer.
Definition: user_config.hpp:40
float get_max_distance() const
Get the maximum distance photons reflect from.
Definition: user_config.hpp:78
void set_translucent(bool translucent)
Set if there are translucent objects in the scene.
CameraConfig to_camera_config(Camera &camera) const
Convert to a camera configuration.
Definition: user_config.hpp:54
bool get_lens_flare() const
Get if lens flare is expected in the scene.
UserConfig()
Create default user config.
Definition: user_config.hpp:46
void set_integration_time(IntegrationTime int_time)
Set the integration time.
void set_fps(float fps)
Set the depth frame rate.
Definition: user_config.hpp:99
void set_lens_flare(bool lens_flare)
Set if lens flare is expected in the scene.
Strategy get_strategy() const
Get what the configuration is being optimized for.
void set_max_distance(float max_distance)
Set the maximum distance photons reflect from.
Definition: user_config.hpp:85
void set_hdr(bool hdr)
Set high dynamic range enabled.
bool get_hdr() const
Get high dynamic range enabled.
void set_environment(ImagingEnvironment imaging_environment)
Set the camera operating environment.
Definition: user_config.hpp:71
void set_channel(int32_t channel)
Set The camera channel, increment to support multi-camera usage.
ImagingEnvironment get_environment() const
Get the camera operating environment.
Definition: user_config.hpp:64
void set_strategy(Strategy strategy)
Set what the configuration is being optimized for.
float get_fps() const
Get the depth frame rate.
Definition: user_config.hpp:92
IntegrationTime get_integration_time() const
Get the integration time.
int32_t get_channel() const
Get The camera channel, increment to support multi-camera usage.