Time-of-Flight Library(ToF) 3.13.4
 
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#include <chronoptics/tof/processing_config.hpp>
9
10namespace chronoptics {
11namespace tof {
12
13/** The integration time as fixed presets
14 */
15enum class IntegrationTime {
16 SHORT = 0, /** 250 us */
17 MEDIUM = 1, /** 500 us */
18 LONG = 2, /** 1000us */
19};
20
21/** The different imaging environments
22 */
23enum class ImagingEnvironment {
24 INSIDE = 0, /** Inside buildings */
25 SUNLIGHT = 1, /** When bright sunlight is present */
26};
27
28/** The optimization of the camera configuration
29 */
30enum class Strategy {
31 BALANCED = 0, /** The balanced configuration */
32 SPEED = 1, /** Optimize for moving objects */
33 ACCURACY = 2, /** Optimize for high accuracy */
34};
35
36/** Optimized configurations for different use cases
37 */
38enum class ConfigMode {
39 LONG_RANGE_DYNAMIC_SCENE = 1, /** Suitable for most applications */
40 MEDIUM_RANGE_DYNAMIC_SCENE = 2, /** For fast moving applications */
41 MEDIUM_RANGE_BALANCED = 3, /** Balanced between range, speed and accuracy */
42 SHORT_RANGE_HIGH_SPEED = 4, /** Maximum speed mode for short range and fast moving applications */
43 LONG_RANGE_HIGH_RESOLUTION = 5, /** Full resolution long range */
44 MEDIUM_RANGE_STATIC_SCENE = 6, /** Full resolution for slow changing scene */
45 FAR_OUT_STATIC_SCENE = 7, /** Full resolution for slow changing scene */
46};
47
48/** DEPRECATED, use config_mode. Simple interface for camera configuration
49 * generation
50*/
51class UserConfig : public detail::Base<tof_user_config, tof_user_config_delete> {
52 public:
53 /** Construct from pointer */
54 UserConfig(tof_user_config_t ptr) {
55 this->ptr_ = ptr;
56 }
57
58 /** Create default user config
59 */
61 this->ptr_ = tof_user_config_new_default(TOF_ERROR_HANDLER{});
62 }
63
64 /** Convert to a camera configuration
65 * @param camera The camera
66 * @return The camera configuration
67 */
69 CameraConfig new_camera_config(static_cast<tof_camera_config_t>(nullptr));
70 auto ptr = reinterpret_cast<tof_camera_config_t*>(&new_camera_config);
71 *ptr = tof_user_config_to_camera_config(this->ptr_, *reinterpret_cast<tof_camera_t*>(&camera), TOF_ERROR_HANDLER{});
72 return new_camera_config;
73 }
74
75 /** Get the camera operating environment
76 * @return Imaging environment
77 */
78 ImagingEnvironment get_environment() const {
79 return static_cast<ImagingEnvironment>(tof_user_config_get_environment(this->ptr_, TOF_ERROR_HANDLER{}));
80 }
81
82 /** Set the camera operating environment
83 * @param imaging_environment Imaging environment
84 */
85 void set_environment(ImagingEnvironment imaging_environment) {
86 return tof_user_config_set_environment(this->ptr_, static_cast<tof_imaging_environment>(imaging_environment), TOF_ERROR_HANDLER{});
87 }
88
89 /** Get the maximum distance photons reflect from
90 * @return Maximum distance in meters
91 */
92 float get_max_distance() const {
93 return tof_user_config_get_max_distance(this->ptr_, TOF_ERROR_HANDLER{});
94 }
95
96 /** Set the maximum distance photons reflect from
97 * @param max_distance Maximum distance in meters
98 */
99 void set_max_distance(float max_distance) {
100 return tof_user_config_set_max_distance(this->ptr_, max_distance, TOF_ERROR_HANDLER{});
101 }
102
103 /** Get the depth frame rate
104 * @return The depth fps
105 */
106 float get_fps() const {
107 return tof_user_config_get_fps(this->ptr_, TOF_ERROR_HANDLER{});
108 }
109
110 /** Set the depth frame rate
111 * @param fps The depth fps
112 */
113 void set_fps(float fps) {
114 return tof_user_config_set_fps(this->ptr_, fps, TOF_ERROR_HANDLER{});
115 }
116
117 /** Get if lens flare is expected in the scene
118 * @return if lens flare is present
119 */
120 bool get_lens_flare() const {
121 return tof_user_config_get_lens_flare(this->ptr_, TOF_ERROR_HANDLER{});
122 }
123
124 /** Set if lens flare is expected in the scene
125 * @param lens_flare if lens flare is present
126 */
127 void set_lens_flare(bool lens_flare) {
128 return tof_user_config_set_lens_flare(this->ptr_, lens_flare, TOF_ERROR_HANDLER{});
129 }
130
131 /** Get if there are translucent objects in the scene
132 * @return If translucent objects
133 */
134 bool get_translucent() const {
135 return tof_user_config_get_translucent(this->ptr_, TOF_ERROR_HANDLER{});
136 }
137
138 /** Set if there are translucent objects in the scene
139 * @param translucent If translucent objects
140 */
141 void set_translucent(bool translucent) {
142 return tof_user_config_set_translucent(this->ptr_, translucent, TOF_ERROR_HANDLER{});
143 }
144
145 /** Get high dynamic range enabled. Enable this when pixel saturation occurs.
146 * This will only happen for retroreflectors or reflective objects close
147 * (<20cm) to the camera
148 * @return Enable high dynamic range
149 */
150 bool get_hdr() const {
151 return tof_user_config_get_hdr(this->ptr_, TOF_ERROR_HANDLER{});
152 }
153
154 /** Set high dynamic range enabled. Enable this when pixel saturation occurs.
155 * This will only happen for retroreflectors or reflective objects close
156 * (<20cm) to the camera
157 * @param hdr Enable high dynamic range
158 */
159 void set_hdr(bool hdr) {
160 return tof_user_config_set_hdr(this->ptr_, hdr, TOF_ERROR_HANDLER{});
161 }
162
163 /** Get the integration time
164 * @return The integration time
165 */
166 IntegrationTime get_integration_time() const {
167 return static_cast<IntegrationTime>(tof_user_config_get_integration_time(this->ptr_, TOF_ERROR_HANDLER{}));
168 }
169
170 /** Set the integration time
171 * @param int_time The integration time
172 */
173 void set_integration_time(IntegrationTime int_time) {
174 return tof_user_config_set_integration_time(this->ptr_, static_cast<tof_integration_time>(int_time), TOF_ERROR_HANDLER{});
175 }
176
177 /** Get what the configuration is being optimized for
178 * @return The user configuration strategy
179 */
180 Strategy get_strategy() const {
181 return static_cast<Strategy>(tof_user_config_get_strategy(this->ptr_, TOF_ERROR_HANDLER{}));
182 }
183
184 /** Set what the configuration is being optimized for
185 * @param strategy The user configuration strategy
186 */
187 void set_strategy(Strategy strategy) {
188 return tof_user_config_set_strategy(this->ptr_, static_cast<tof_strategy>(strategy), TOF_ERROR_HANDLER{});
189 }
190
191 /** Get The camera channel, increment to support multi-camera usage
192 * @return The channel number, set to 0, otherwise increment with number of
193 * cameras.
194 */
195 int32_t get_channel() const {
196 return tof_user_config_get_channel(this->ptr_, TOF_ERROR_HANDLER{});
197 }
198
199 /** Set The camera channel, increment to support multi-camera usage
200 * @param channel The channel number, set to 0, otherwise increment with
201 * number of cameras.
202 */
203 void set_channel(int32_t channel) {
204 return tof_user_config_set_channel(this->ptr_, channel, TOF_ERROR_HANDLER{});
205 }
206
207};
208
209/** Get the camera config associated with the config mode
210 * @param camera Camera
211 * @param config_mode Config mode
212 * @return Camera Config
213 */
214inline CameraConfig config_mode_camera_config(Camera &camera, ConfigMode config_mode) {
215 CameraConfig new_camera_config(static_cast<tof_camera_config_t>(nullptr));
216 auto ptr = reinterpret_cast<tof_camera_config_t*>(&new_camera_config);
217 *ptr = tof_config_mode_camera_config(*reinterpret_cast<tof_camera_t*>(&camera), static_cast<tof_config_mode>(config_mode), TOF_ERROR_HANDLER{});
218 return new_camera_config;
219}
220
221/** Get the processing config associated with the config mode
222 * @param camera Camera
223 * @param config_mode Config mode
224 * @return Processing Config
225 */
226inline ProcessingConfig config_mode_processing_config(Camera &camera, ConfigMode config_mode) {
227 ProcessingConfig new_processing_config(static_cast<tof_processing_config_t>(nullptr));
228 auto ptr = reinterpret_cast<tof_processing_config_t*>(&new_processing_config);
229 *ptr = tof_config_mode_processing_config(*reinterpret_cast<tof_camera_t*>(&camera), static_cast<tof_config_mode>(config_mode), TOF_ERROR_HANDLER{});
230 return new_processing_config;
231}
232
233/** Check whether hdr is possible with current camera config
234 * @param config The camera config to check
235 * @return Whether hdr is possible
236 */
237inline bool hdr_possible(CameraConfig &config) {
238 return tof_hdr_possible(*reinterpret_cast<tof_camera_config_t*>(&config), TOF_ERROR_HANDLER{});
239}
240
241/** Check whether phase unwrap is possible with current camera config
242 * @param config The camera config to check
243 * @return Whether phase unwrap is possible
244 */
245inline bool phase_unwrap_possible(CameraConfig &config) {
246 return tof_phase_unwrap_possible(*reinterpret_cast<tof_camera_config_t*>(&config), TOF_ERROR_HANDLER{});
247}
248
249/** Generate processing config based on camera configuration and calibration.
250 * @param camera A camera
251 */
252inline void apply_default_processing_config(Camera &camera) {
253 return tof_apply_default_processing_config(*reinterpret_cast<tof_camera_t*>(&camera), TOF_ERROR_HANDLER{});
254}
255
256} // tof
257} // chronoptics
258
259#endif
This class allows you to view/edit the camera settings.
The main interface to the depth cameras.
Definition: camera.hpp:17
DEPRECATED, use config_mode.
Definition: user_config.hpp:51
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:54
float get_max_distance() const
Get the maximum distance photons reflect from.
Definition: user_config.hpp:92
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:68
bool get_lens_flare() const
Get if lens flare is expected in the scene.
UserConfig()
Create default user config.
Definition: user_config.hpp:60
void set_integration_time(IntegrationTime int_time)
Set the integration time.
void set_fps(float fps)
Set the depth frame rate.
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:99
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:85
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:78
void set_strategy(Strategy strategy)
Set what the configuration is being optimized for.
float get_fps() const
Get the depth frame rate.
IntegrationTime get_integration_time() const
Get the integration time.
int32_t get_channel() const
Get The camera channel, increment to support multi-camera usage.