Time-of-Flight Library(ToF) 4.0.2
 
camera_config.hpp
1#ifndef _CHRONOPTICS_TOF_CAMERA_CONFIG_HPP_
2#define _CHRONOPTICS_TOF_CAMERA_CONFIG_HPP_
3
4#include <chronoptics/tof/camera_config.h>
5
6#include <chronoptics/tof/processing_config.hpp>
7
8namespace chronoptics {
9namespace tof {
10
11/** ToF cameras made by Chronoptics
12 */
13enum class CameraType {
14 OPT8241 = 1, /** Original Moa and first generation Kea camera with opt sensor */
15 OPT8241_EXT = 4, /** First generation Kea camera with opt sensor and external modulation */
16 MLX75027 = 6, /** Newer generation Kea cameras with mlx sensor */
17 VD55H1 = 9, /** Kea st camera */
18};
19
20/** Operating mode of the cameras' sensor
21 */
22enum class SensorMode {
23 NORMAL = 0, /** Normal mode ToF sensor mod (A - B) */
24 COMMON = 1, /** Common mode (A + B) */
25 EXTERNAL_DEMOD = 4, /** Use external demodulation */
26 EXTERNAL_SIGNAL = 5, /** Use the light source as an input */
27 TAP_A = 8, /** Only tap a is read out */
28 TAP_B = 9, /** Only tap b is read out */
29 TAP_AB = 10, /** Both A and B tap are read out, this means double the data transmission */
30 TAP_AB_HDR = 12, /** Both A and B tap are read out for both a short and long integration time */
31};
32
33/** The trigger mode of the camera
34 */
35enum class TriggerMode {
36 CONTINUOUS = 0, /** The camera is continuously running and outputting frames */
37 HARDWARE = 1, /** The camera waits for a hardware trigger */
38 SOFTWARE = 2, /** The camera waits for a software trigger */
39};
40
41/** The amount of light power to output
42 */
43enum class LightPower {
44 FULL = 0, /** Full, 100% light power, all 4 vcsels operating */
45 HALF = 1, /** Half, 50% light power, 2 vcsels operating */
46 ZERO = 2, /** Zero, 0% light power, 0 vcsels operating */
47};
48
49/** Which configuration the gpio is in
50 */
51enum class GpioMode {
52 DISABLED = 0, /** GPIO Pin is not in use, can be used by other applications on camera */
53 HW_TRIGGER_IN = 1, /** Start sensor using trigger in */
54 HW_TRIGGER_OUT = 2, /** Send pulse whenever sensor is started */
55 GENERAL_INPUT = 3, /** Allow to read GPIO using the live camera */
56 GENERAL_OUTPUT = 4, /** Allow to read/set GPIO using the live camera */
57};
58
59/** Region of interest
60*/
61class Roi : public detail::Base<tof_roi, tof_roi_delete> {
62 public:
63 /** Construct from pointer */
64 Roi(tof_roi_t ptr = nullptr) {
65 this->ptr_ = ptr;
66 }
67
68 /** Get the number of rows in the image sensor
69 * @return Number of rows
70 */
71 int32_t sensor_rows() const {
72 return tof_roi_sensor_rows(this->ptr_, TOF_ERROR_HANDLER{});
73 }
74
75 /** Get the number of columns in the image sensor
76 * @return Number of columsn
77 */
78 int32_t sensor_cols() const {
79 return tof_roi_sensor_cols(this->ptr_, TOF_ERROR_HANDLER{});
80 }
81
82 /** Get the row offset in pixels
83 * @return Row offset
84 */
85 int32_t get_row_offset() const {
86 return tof_roi_get_row_offset(this->ptr_, TOF_ERROR_HANDLER{});
87 }
88
89 /** Set the row offset in pixels
90 * @param row_offset Row offset
91 */
92 void set_row_offset(int32_t row_offset) {
93 return tof_roi_set_row_offset(this->ptr_, row_offset, TOF_ERROR_HANDLER{});
94 }
95
96 /** Get the column offset in pixels
97 * @return Column offset
98 */
99 int32_t get_col_offset() const {
100 return tof_roi_get_col_offset(this->ptr_, TOF_ERROR_HANDLER{});
101 }
102
103 /** Set the column offset in pixels
104 * @param col_offset Column offset
105 */
106 void set_col_offset(int32_t col_offset) {
107 return tof_roi_set_col_offset(this->ptr_, col_offset, TOF_ERROR_HANDLER{});
108 }
109
110 /** Get the number of rows in the output image
111 * @return Image rows
112 */
113 int32_t get_img_rows() const {
114 return tof_roi_get_img_rows(this->ptr_, TOF_ERROR_HANDLER{});
115 }
116
117 /** Set the number of rows in the output image
118 * @param img_rows Image rows
119 */
120 void set_img_rows(int32_t img_rows) {
121 return tof_roi_set_img_rows(this->ptr_, img_rows, TOF_ERROR_HANDLER{});
122 }
123
124 /** Get the number of columns in the output image
125 * @return Image columns
126 */
127 int32_t get_img_cols() const {
128 return tof_roi_get_img_cols(this->ptr_, TOF_ERROR_HANDLER{});
129 }
130
131 /** Set the number of columns in the output image
132 * @param img_cols Image columns
133 */
134 void set_img_cols(int32_t img_cols) {
135 return tof_roi_set_img_cols(this->ptr_, img_cols, TOF_ERROR_HANDLER{});
136 }
137
138};
139
140/** This class allows you to view/edit the camera settings
141*/
142class CameraConfig : public detail::Base<tof_camera_config, tof_camera_config_delete> {
143 public:
144 /** Construct from pointer */
145 CameraConfig(tof_camera_config_t ptr = nullptr) {
146 this->ptr_ = ptr;
147 }
148
149 /** Read camera config from disk
150 * @param file_location Location of camera config on disk
151 */
152 CameraConfig(StringView file_location) : CameraConfig(tof_camera_config_new_from_disk(file_location, TOF_ERROR_HANDLER{})) {}
153
154 /** Write camera config to disk
155 * @param file_location Location to save camera config to
156 */
157 void write(StringView file_location) const {
158 return tof_camera_config_write(this->ptr_, file_location, TOF_ERROR_HANDLER{});
159 }
160
161 /** Get the camera type
162 * @return Camera type
163 */
164 CameraType get_type() const {
165 return static_cast<CameraType>(tof_camera_config_get_type(this->ptr_, TOF_ERROR_HANDLER{}));
166 }
167
168 /** Reset camera config to default
169 */
170 void reset() {
171 return tof_camera_config_reset(this->ptr_, TOF_ERROR_HANDLER{});
172 }
173
174 /** Get the amount of frames in the config. Having multiple frames allows you
175 * to configure different modulation frequencies or integration times per
176 * frame.
177 * @return Frame size
178 */
179 size_t frame_size() const {
180 return tof_camera_config_frame_size(this->ptr_, TOF_ERROR_HANDLER{});
181 }
182
183 /** Add a default frame to the camera config
184 */
185 void add_frame() {
186 return tof_camera_config_add_frame(this->ptr_, TOF_ERROR_HANDLER{});
187 }
188
189 /** Generate default processing config from camera configuration
190 * @return The default processing config
191 */
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;
197 }
198
199 /** Erase specified frame
200 * @param frame Frame number
201 */
202 void erase_frame(size_t frame) {
203 return tof_camera_config_erase_frame(this->ptr_, frame, TOF_ERROR_HANDLER{});
204 }
205
206 /** Get the phase shifts. Value ranges from 0.0 to 1.0 which translates to 0-2
207 * pi
208 * @param frame Frame number
209 * @return Phase shifts
210 */
211 std::vector<float> get_phase_shifts(size_t frame) const {
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{});
215 return vec;
216 }
217
218 /** Set the phase shifts. Value ranges from 0.0 to 1.0 which translates to 0-2
219 * pi
220 * @param frame Frame number
221 * @param phase_shifts Phase shifts
222 */
223 void set_phase_shifts(size_t frame, const std::vector<float> &phase_shifts) {
224 return tof_camera_config_set_phase_shifts(this->ptr_, frame, phase_shifts.data(), phase_shifts.size(), TOF_ERROR_HANDLER{});
225 }
226
227 /** Get the integration time
228 * @param frame Frame number
229 * @return Integration time in micro seconds
230 */
231 std::vector<uint32_t> get_integration_time(size_t frame) const {
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{});
235 return vec;
236 }
237
238 /** Set the integration time
239 * @param frame Frame number
240 * @param integration_time Integration time in micro seconds
241 */
242 void set_integration_time(size_t frame, const std::vector<uint32_t> &integration_time) {
243 return tof_camera_config_set_integration_time(this->ptr_, frame, integration_time.data(), integration_time.size(), TOF_ERROR_HANDLER{});
244 }
245
246 /** Get the mode to set the camera's depth sensor to
247 * @param frame Frame number
248 * @return Sensor mode
249 */
250 SensorMode get_sensor_mode(size_t frame) const {
251 return static_cast<SensorMode>(tof_camera_config_get_sensor_mode(this->ptr_, frame, TOF_ERROR_HANDLER{}));
252 }
253
254 /** Set the mode to set the camera's depth sensor to
255 * @param frame Frame number
256 * @param sensor_mode Sensor mode
257 */
258 void set_sensor_mode(size_t frame, SensorMode sensor_mode) {
259 return tof_camera_config_set_sensor_mode(this->ptr_, frame, static_cast<tof_sensor_mode>(sensor_mode), TOF_ERROR_HANDLER{});
260 }
261
262 /** Get the modulation frequency
263 * @param frame Frame number
264 * @return Modulation frequency in MHz
265 */
266 float get_modulation_frequency(size_t frame) const {
267 return tof_camera_config_get_modulation_frequency(this->ptr_, frame, TOF_ERROR_HANDLER{});
268 }
269
270 /** Set the modulation frequency
271 * @param frame Frame number
272 * @param modulation_frequency Modulation frequency in MHz
273 */
274 void set_modulation_frequency(size_t frame, float modulation_frequency) {
275 return tof_camera_config_set_modulation_frequency(this->ptr_, frame, modulation_frequency, TOF_ERROR_HANDLER{});
276 }
277
278 /** Get the duty cycle
279 * @param frame Frame number
280 * @return Duty cycle 0.0 to 1.0
281 */
282 float get_duty_cycle(size_t frame) const {
283 return tof_camera_config_get_duty_cycle(this->ptr_, frame, TOF_ERROR_HANDLER{});
284 }
285
286 /** Set the duty cycle
287 * @param frame Frame number
288 * @param duty_cycle Duty cycle 0.0 to 1.0
289 */
290 void set_duty_cycle(size_t frame, float duty_cycle) {
291 return tof_camera_config_set_duty_cycle(this->ptr_, frame, duty_cycle, TOF_ERROR_HANDLER{});
292 }
293
294 /** Get the region of interest
295 * @param frame Frame number
296 * @return Region of interest
297 */
298 Roi get_roi(size_t frame) const {
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{});
302 return new_roi;
303 }
304
305 /** Set the region of interest
306 * @param frame Frame number
307 * @param roi Region of interest
308 */
309 void set_roi(size_t frame, Roi &roi) {
310 return tof_camera_config_set_roi(this->ptr_, frame, *reinterpret_cast<tof_roi_t*>(&roi), TOF_ERROR_HANDLER{});
311 }
312
313 /** Get the amount of binning
314 * @param frame Frame number
315 * @return Amount of binning 0=none, 1=x2, 2=x4, 3=x8
316 */
317 uint8_t get_binning(size_t frame) const {
318 return tof_camera_config_get_binning(this->ptr_, frame, TOF_ERROR_HANDLER{});
319 }
320
321 /** Set the amount of binning
322 * @param frame Frame number
323 * @param binning Amount of binning 0=none, 1=x2, 2=x4, 3=x8
324 */
325 void set_binning(size_t frame, uint8_t binning) {
326 return tof_camera_config_set_binning(this->ptr_, frame, binning, TOF_ERROR_HANDLER{});
327 }
328
329 /** Get is the image flipped
330 * @param frame Frame number
331 * @return Image is flipped
332 */
333 bool get_flip(size_t frame) const {
334 return tof_camera_config_get_flip(this->ptr_, frame, TOF_ERROR_HANDLER{});
335 }
336
337 /** Set is the image flipped
338 * @param frame Frame number
339 * @param flip Image is flipped
340 */
341 void set_flip(size_t frame, bool flip) {
342 return tof_camera_config_set_flip(this->ptr_, frame, flip, TOF_ERROR_HANDLER{});
343 }
344
345 /** Get is the image mirrored
346 * @param frame Frame number
347 * @return Image is mirrored
348 */
349 bool get_mirror(size_t frame) const {
350 return tof_camera_config_get_mirror(this->ptr_, frame, TOF_ERROR_HANDLER{});
351 }
352
353 /** Set is the image mirrored
354 * @param frame Frame number
355 * @param mirror Image is mirrored
356 */
357 void set_mirror(size_t frame, bool mirror) {
358 return tof_camera_config_set_mirror(this->ptr_, frame, mirror, TOF_ERROR_HANDLER{});
359 }
360
361 /** Get the image sensor gain
362 * @return Image sensor gain
363 */
364 float get_gain() const {
365 return tof_camera_config_get_gain(this->ptr_, TOF_ERROR_HANDLER{});
366 }
367
368 /** Set the image sensor gain
369 * @param gain Image sensor gain
370 */
371 void set_gain(float gain) {
372 return tof_camera_config_set_gain(this->ptr_, gain, TOF_ERROR_HANDLER{});
373 }
374
375 /** Get the kind of camera synchronization
376 * @return The kind of sync mode. 0 waits for the vsync pulse before starting
377 * the next frame. 1 optional vsync 2 is no frame syncing
378 */
379 int32_t get_sync_mode() const {
380 return tof_camera_config_get_sync_mode(this->ptr_, TOF_ERROR_HANDLER{});
381 }
382
383 /** Set the kind of camera synchronization
384 * @param sync_mode The kind of sync mode. 0 waits for the vsync pulse before
385 * starting the next frame. 1 optional vsync 2 is no frame syncing
386 */
387 void set_sync_mode(int32_t sync_mode) {
388 return tof_camera_config_set_sync_mode(this->ptr_, sync_mode, TOF_ERROR_HANDLER{});
389 }
390
391 /** Get the maximum integration time possible
392 * @param frame Frame number
393 * @return Maximum integration time in micro seconds
394 */
395 std::vector<uint32_t> maximum_integration_time(size_t frame) const {
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{});
399 return vec;
400 }
401
402 /** Get the mipi speed
403 * @return The mipi speed. For the MLX75027 sensor these values can only be
404 * 300, 600, 704, 800 and 960
405 */
406 int32_t get_mipi_speed() const {
407 return tof_camera_config_get_mipi_speed(this->ptr_, TOF_ERROR_HANDLER{});
408 }
409
410 /** Set the mipi speed
411 * @param mipi_speed The mipi speed. For the MLX75027 sensor these values can
412 * only be 300, 600, 704, 800 and 960
413 */
414 void set_mipi_speed(int32_t mipi_speed) {
415 return tof_camera_config_set_mipi_speed(this->ptr_, mipi_speed, TOF_ERROR_HANDLER{});
416 }
417
418 /** Get the preheat time
419 * @param frame Frame number
420 * @return The preheat time
421 */
422 uint32_t get_mlx_preheat(size_t frame) const {
423 return tof_camera_config_get_mlx_preheat(this->ptr_, frame, TOF_ERROR_HANDLER{});
424 }
425
426 /** Set the preheat time
427 * @param frame Frame number
428 * @param preheat The preheat time
429 */
430 void set_mlx_preheat(size_t frame, uint32_t preheat) {
431 return tof_camera_config_set_mlx_preheat(this->ptr_, frame, preheat, TOF_ERROR_HANDLER{});
432 }
433
434 /** Get enable preheat
435 * @param frame Frame number
436 * @return Enable preheating
437 */
438 bool get_mlx_preheat_enable(size_t frame) const {
439 return tof_camera_config_get_mlx_preheat_enable(this->ptr_, frame, TOF_ERROR_HANDLER{});
440 }
441
442 /** Set enable preheat
443 * @param frame Frame number
444 * @param enable Enable preheating
445 */
446 void set_mlx_preheat_enable(size_t frame, bool enable) {
447 return tof_camera_config_set_mlx_preheat_enable(this->ptr_, frame, enable, TOF_ERROR_HANDLER{});
448 }
449
450 /** Set the Nios hex for the keaB cameras
451 * @param file_location File location of the nios hex file
452 */
453 void set_opt_kea_nios_hex(StringView file_location) {
454 return tof_camera_config_set_opt_kea_nios_hex(this->ptr_, file_location, TOF_ERROR_HANDLER{});
455 }
456
457 /** Get the opt8241 number of sub and quad frames
458 * @return Number of subs and quads respectively
459 */
460 std::array<int32_t, 2> get_opt_kea_sub_quad() const {
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());
464 return array;
465 }
466
467 /** Set the opt8241 number of sub and quad frames
468 * @param subs_quads Number of subs and quads respectively
469 */
470 void set_opt_kea_sub_quad(const std::array<int32_t, 2> &subs_quads) {
471 return tof_camera_config_set_opt_kea_sub_quad(this->ptr_, subs_quads.data(), TOF_ERROR_HANDLER{});
472 }
473
474 /** Get the processing configuration for when the depth is calculated on
475 * camera
476 * @return The pipeline processing to be done on camera
477 */
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;
483 }
484
485 /** Set the processing configuration for when the depth is calculated on
486 * camera
487 * @param processing The pipeline processing to be done on camera
488 */
490 return tof_camera_config_set_processing(this->ptr_, *reinterpret_cast<tof_processing_config_t*>(&processing), TOF_ERROR_HANDLER{});
491 }
492
493 /** Get the time this depth frame will take. This is useful when you want a
494 * steady but lower framerate.
495 * @param frame Frame number
496 * @return Frame time in micro seconds
497 */
498 uint32_t get_frame_time(size_t frame) const {
499 return tof_camera_config_get_frame_time(this->ptr_, frame, TOF_ERROR_HANDLER{});
500 }
501
502 /** Set the time this depth frame will take. This is useful when you want a
503 * steady but lower framerate.
504 * @param frame Frame number
505 * @param frame_time Frame time in micro seconds
506 */
507 void set_frame_time(size_t frame, uint32_t frame_time) {
508 return tof_camera_config_set_frame_time(this->ptr_, frame, frame_time, TOF_ERROR_HANDLER{});
509 }
510
511 /** Get phase offset for illumination and sensor. The phase offsets are two
512 * floating point values corresponding to the phase delay for the illumination
513 * and sensor respectively. The values should be between 0.0 and 1.0 where 0.0
514 * is no phase offset and 1.0 is 360 degree phase offset
515 * @param frame Frame number
516 * @return Image is mirrored
517 */
518 std::array<float, 2> get_global_phase_offset(size_t frame) const {
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());
522 return array;
523 }
524
525 /** Set phase offset for illumination and sensor. The phase offsets are two
526 * floating point values corresponding to the phase delay for the illumination
527 * and sensor respectively. The values should be between 0.0 and 1.0 where 0.0
528 * is no phase offset and 1.0 is 360 degree phase offset
529 * @param frame Frame number
530 * @param phase_offset Image is mirrored
531 */
532 void set_global_phase_offset(size_t frame, const std::array<float, 2> &phase_offset) {
533 return tof_camera_config_set_global_phase_offset(this->ptr_, frame, phase_offset.data(), TOF_ERROR_HANDLER{});
534 }
535
536 /** Get the illumination mode
537 * @param frame Frame number
538 * @return Illumination mode. 0 is actively modulating, 2 is active low
539 * (illumination disabled) and 3 is active high
540 */
541 uint8_t get_illumination_mode(size_t frame) const {
542 return tof_camera_config_get_illumination_mode(this->ptr_, frame, TOF_ERROR_HANDLER{});
543 }
544
545 /** Set the illumination mode
546 * @param frame Frame number
547 * @param illumination_mode Illumination mode. 0 is actively modulating, 2 is
548 * active low (illumination disabled) and 3 is active high
549 */
550 void set_illumination_mode(size_t frame, uint8_t illumination_mode) {
551 return tof_camera_config_set_illumination_mode(this->ptr_, frame, illumination_mode, TOF_ERROR_HANDLER{});
552 }
553
554 /** Get the image offsets. This configuration is only for sensors with column
555 * phase offsets.
556 * @param frame Frame number
557 * @return The image offset per column in 0.0 to 1.0
558 */
559 std::vector<float> get_image_offsets(size_t frame) const {
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{});
563 return vec;
564 }
565
566 /** Set the image offsets. This configuration is only for sensors with column
567 * phase offsets.
568 * @param frame Frame number
569 * @param image_offsets The image offset per column in 0.0 to 1.0
570 */
571 void set_image_offsets(size_t frame, const std::vector<float> &image_offsets) {
572 return tof_camera_config_set_image_offsets(this->ptr_, frame, image_offsets.data(), image_offsets.size(), TOF_ERROR_HANDLER{});
573 }
574
575 /** Get the width of the rgb sensor
576 * @return Width in pixels
577 */
578 size_t get_rgb_width() const {
579 return tof_camera_config_get_rgb_width(this->ptr_, TOF_ERROR_HANDLER{});
580 }
581
582 /** Get the height of the rgb sensor
583 * @return Height in pixels
584 */
585 size_t get_rgb_height() const {
586 return tof_camera_config_get_rgb_height(this->ptr_, TOF_ERROR_HANDLER{});
587 }
588
589 /** Get the trigger mode
590 * @return The trigger mode of the camera
591 */
592 TriggerMode get_trigger_mode() const {
593 return static_cast<TriggerMode>(tof_camera_config_get_trigger_mode(this->ptr_, TOF_ERROR_HANDLER{}));
594 }
595
596 /** Set the trigger mode
597 * @param trigger_mode The trigger mode of the camera
598 */
599 void set_trigger_mode(TriggerMode trigger_mode) {
600 return tof_camera_config_set_trigger_mode(this->ptr_, static_cast<tof_trigger_mode>(trigger_mode), TOF_ERROR_HANDLER{});
601 }
602
603 /** Get the maximum theoretical fps the camera can run
604 * @return The fps in Hz
605 */
606 float get_depth_fps() const {
607 return tof_camera_config_get_depth_fps(this->ptr_, TOF_ERROR_HANDLER{});
608 }
609
610 /** Get the configuration name
611 * @return Name
612 */
613 const char* get_name() const {
614 return tof_camera_config_get_name(this->ptr_, TOF_ERROR_HANDLER{});
615 }
616
617 /** Set the configuration name
618 * @param name Name
619 */
620 void set_name(StringView name) {
621 return tof_camera_config_set_name(this->ptr_, name, TOF_ERROR_HANDLER{});
622 }
623
624 /** Get the description
625 * @return Description
626 */
627 const char* get_description() const {
628 return tof_camera_config_get_description(this->ptr_, TOF_ERROR_HANDLER{});
629 }
630
631 /** Set the description
632 * @param description Description
633 */
634 void set_description(StringView description) {
635 return tof_camera_config_set_description(this->ptr_, description, TOF_ERROR_HANDLER{});
636 }
637
638 /** Get the light power
639 * @return Light power
640 */
641 LightPower get_light_power() const {
642 return static_cast<LightPower>(tof_camera_config_get_light_power(this->ptr_, TOF_ERROR_HANDLER{}));
643 }
644
645 /** Set the light power
646 * @param light_power Light power
647 */
648 void set_light_power(LightPower light_power) {
649 return tof_camera_config_set_light_power(this->ptr_, static_cast<tof_light_power>(light_power), TOF_ERROR_HANDLER{});
650 }
651
652 /** Light power is set
653 * @return Has light power
654 */
655 bool has_light_power() const {
656 return tof_camera_config_has_light_power(this->ptr_, TOF_ERROR_HANDLER{});
657 }
658
659 /** Get configured gpio mode
660 * @param pin Pin
661 * @return GPIO Mode
662 */
663 GpioMode get_gpio_mode(size_t pin) const {
664 return static_cast<GpioMode>(tof_camera_config_get_gpio_mode(this->ptr_, pin, TOF_ERROR_HANDLER{}));
665 }
666
667 /** Set gpio mode
668 * @param pin Pin
669 * @param gpio_mode GPIO Mode
670 */
671 void set_gpio_mode(size_t pin, GpioMode gpio_mode) {
672 return tof_camera_config_set_gpio_mode(this->ptr_, pin, static_cast<tof_gpio_mode>(gpio_mode), TOF_ERROR_HANDLER{});
673 }
674
675};
676
677/** Test whether camera configurations are equal
678 * @param lhs First camera config
679 * @param rhs Second camera config
680 * @return Camera configurations are equal
681 */
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{});
684}
685
686/** Get the name of the light power
687 * @param light_power Light Power
688 * @return Name
689 */
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{});
692}
693
694/** Get the name of the GPIO mode
695 * @param gpio_mode GPIO Mode
696 * @return Name
697 */
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{});
700}
701
702} // tof
703} // chronoptics
704
705#endif
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.
Region of interest.
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.