Time-of-Flight Library(ToF) 4.0.1
 
camera.h
1#ifndef _CHRONOPTICS_TOF_CAMERA_H_
2#define _CHRONOPTICS_TOF_CAMERA_H_
3
4#include <chronoptics/tof/stream.h>
5#include <chronoptics/tof/processing_config.h>
6#include <chronoptics/tof/data.h>
7#include <chronoptics/tof/camera_config.h>
8#include <chronoptics/tof/calibration.h>
9
10#ifdef __cplusplus
11extern "C" {
12#endif
13
14/** The main interface to the depth cameras
15 */
16typedef struct tof_camera* tof_camera_t;
17
18typedef struct tof_camera const* tof_camera_ct;
19
20/** Destruct tof_camera */
21TOF_EXPORT void tof_camera_delete(tof_camera_t ptr);
22
23/** Start streaming of the camera
24 * @param ptr Pointer to class
25 * @param error Pointer to error
26 */
27TOF_EXPORT void tof_camera_start(tof_camera_t ptr, tof_error_t *error);
28
29/** Stop streaming of the camera
30 * @param ptr Pointer to class
31 * @param error Pointer to error
32 */
33TOF_EXPORT void tof_camera_stop(tof_camera_t ptr, tof_error_t *error);
34
35/** Check whether the camera is streaming
36 * @param ptr Pointer to class
37 * @param error Pointer to error
38 * @return Is streaming
39 */
40TOF_EXPORT bool tof_camera_is_streaming(tof_camera_ct ptr, tof_error_t *error);
41
42/** Check whether the camera is still connected
43 * @param ptr Pointer to class
44 * @param error Pointer to error
45 * @return Is connected
46 */
47TOF_EXPORT bool tof_camera_is_connected(tof_camera_ct ptr, tof_error_t *error);
48
49/** Get the different output streams the camera can provide
50 * @param ptr Pointer to class
51 * @param streams The streams
52 * @param capacity The amount of data the above pointer can hold
53 * @param error Pointer to error
54 * @return Number of pointers filled or complete array size
55 */
56TOF_EXPORT size_t tof_camera_get_stream_list(tof_camera_ct ptr, tof_stream_t* streams, size_t capacity, tof_error_t *error);
57
58/** the processing config of the camera
59 * @param ptr Pointer to class
60 * @param error Pointer to error
61 * @return The processing config
62 */
63TOF_EXPORT tof_processing_config_t tof_camera_get_process_config(tof_camera_ct ptr, tof_error_t *error);
64
65/** Check if the camera has frames available
66 * @param ptr Pointer to class
67 * @param error Pointer to error
68 * @return Has frames available
69 */
70TOF_EXPORT bool tof_camera_has_frames(tof_camera_ct ptr, tof_error_t *error);
71
72/** Get data frames from camera
73 * @param ptr Pointer to class
74 * @param frames Data frames
75 * @param capacity The amount of data the above pointer can hold
76 * @param error Pointer to error
77 * @return Number of pointers filled or complete array size
78 */
79TOF_EXPORT size_t tof_camera_get_frames(tof_camera_t ptr, tof_data_t* frames, size_t capacity, tof_error_t *error);
80
81/** Clear the circular buffer used to store frames
82 * @param ptr Pointer to class
83 * @param error Pointer to error
84 */
85TOF_EXPORT void tof_camera_clear_buffer(tof_camera_t ptr, tof_error_t *error);
86
87/** Get the circular buffer size
88 * @param ptr Pointer to class
89 * @param error Pointer to error
90 * @return The maximum number of sets of frames that is stored before the oldest
91 * is overwritten
92 */
93TOF_EXPORT size_t tof_camera_get_buffer_size(tof_camera_ct ptr, tof_error_t *error);
94
95/** Set the circular buffer size
96 * @param ptr Pointer to class
97 * @param size The maximum number of sets of frames that is stored before the
98 * oldest is overwritten
99 * @param error Pointer to error
100 */
101TOF_EXPORT void tof_camera_set_buffer_size(tof_camera_t ptr, size_t size, tof_error_t *error);
102
103/** Get the currently active camera config
104 * @param ptr Pointer to class
105 * @param error Pointer to error
106 * @return The camera config
107 */
108TOF_EXPORT tof_camera_config_t tof_camera_get_camera_config(tof_camera_ct ptr, tof_error_t *error);
109
110/** Get the serial number of the current camera
111 * @param ptr Pointer to class
112 * @param error Pointer to error
113 * @return The serial
114 */
115TOF_EXPORT const char* tof_camera_get_serial(tof_camera_ct ptr, tof_error_t *error);
116
117/** Get calibration from the camera
118 * @param ptr Pointer to class
119 * @param error Pointer to error
120 * @return The calibration
121 */
122TOF_EXPORT tof_calibration_t tof_camera_get_calibration(tof_camera_ct ptr, tof_error_t *error);
123
124/** Get the amount of user pointers that can be stored
125 * @param ptr Pointer to class
126 * @param error Pointer to error
127 * @return The capacity
128 */
129TOF_EXPORT size_t tof_camera_get_user_pointer_capacity(tof_camera_ct ptr, tof_error_t *error);
130
131/** Set the amount of user pointers that can be stored
132 * @param ptr Pointer to class
133 * @param capacity The capacity
134 * @param error Pointer to error
135 */
136TOF_EXPORT void tof_camera_set_user_pointer_capacity(tof_camera_t ptr, size_t capacity, tof_error_t *error);
137
138/** Add a pointer that will be filled with the specified data type. This method
139 * allows you to fill data straight into your own data type without any
140 * additional copying.
141 * @param ptr Pointer to class
142 * @param pointer The pointer to the data to write into
143 * @param capacity The amount of data the pointer can hold
144 * @param callback Callback that will be called when pointer is no longer in use
145 * @param callback_user_data User data that will be passed back when the function pointer is called
146 * @param frame_type The frame type that will be filled into the pointer
147 * @param error Pointer to error
148 */
149TOF_EXPORT void tof_camera_add_user_pointer(tof_camera_t ptr, uint8_t* pointer, size_t capacity, tof_user_pointer_destructed_t callback, void* callback_user_data, enum tof_frame_type frame_type, tof_error_t *error);
150
151/** Clear all user pointers in memory
152 * @param ptr Pointer to class
153 * @param error Pointer to error
154 */
155TOF_EXPORT void tof_camera_clear_user_pointers(tof_camera_t ptr, tof_error_t *error);
156
157/** Get the currently set configuration index
158 * @param ptr Pointer to class
159 * @param error Pointer to error
160 * @return config index
161 */
162TOF_EXPORT uint32_t tof_camera_config_index(tof_camera_ct ptr, tof_error_t *error);
163
164/** Switch to a different config in real time, depending on configuration and
165 * camera, this can take 100-300ms
166 * @param ptr Pointer to class
167 * @param config_index Config index to switch to
168 * @param error Pointer to error
169 */
170TOF_EXPORT void tof_camera_switch_config(tof_camera_t ptr, uint32_t config_index, tof_error_t *error);
171
172/** Get the frame types that this camera can output
173 * @param ptr Pointer to class
174 * @param frame_types Possible frame types
175 * @param capacity The amount of data the above pointer can hold
176 * @param error Pointer to error
177 * @return Number of pointers filled or complete array size
178 */
179TOF_EXPORT size_t tof_camera_possible_frame_types(tof_camera_ct ptr, enum tof_frame_type* frame_types, size_t capacity, tof_error_t *error);
180
181/** Whether output frame types have been set
182 * @param ptr Pointer to class
183 * @param error Pointer to error
184 * @return Output frame types set
185 */
186TOF_EXPORT bool tof_camera_output_frame_types_set(tof_camera_t ptr, tof_error_t *error);
187
188/** Get the frame types the camera should output
189 * @param ptr Pointer to class
190 * @param output_frame_types Output frame types
191 * @param capacity The amount of data the above pointer can hold
192 * @param error Pointer to error
193 * @return Number of pointers filled or complete array size
194 */
195TOF_EXPORT size_t tof_camera_get_output_frame_types(tof_camera_ct ptr, enum tof_frame_type* output_frame_types, size_t capacity, tof_error_t *error);
196
197/** Set the frame types the camera should output
198 * @param ptr Pointer to class
199 * @param output_frame_types Output frame types
200 * @param output_frame_types_size The size of the above array
201 * @param error Pointer to error
202 */
203TOF_EXPORT void tof_camera_set_output_frame_types(tof_camera_t ptr, const enum tof_frame_type* output_frame_types, size_t output_frame_types_size, tof_error_t *error);
204
205/** Check if multiple configurations are set. Switch config can only be used
206 * when this is the case.
207 * @param ptr Pointer to class
208 * @param error Pointer to error
209 * @return Is set
210 */
211TOF_EXPORT bool tof_camera_has_multiple_configurations(tof_camera_ct ptr, tof_error_t *error);
212
213/** Get all the set camera configurations
214 * @param ptr Pointer to class
215 * @param cam_configs Multiple camera configurations
216 * @param capacity The amount of data the above pointer can hold
217 * @param error Pointer to error
218 * @return Number of pointers filled or complete array size
219 */
220TOF_EXPORT size_t tof_camera_get_multiple_camera_configurations(tof_camera_ct ptr, tof_camera_config_t* cam_configs, size_t capacity, tof_error_t *error);
221
222/** Get all the set processing configurations
223 * @param ptr Pointer to class
224 * @param processing_configs Multiple processing configurations
225 * @param capacity The amount of data the above pointer can hold
226 * @param error Pointer to error
227 * @return Number of pointers filled or complete array size
228 */
229TOF_EXPORT size_t tof_camera_get_multiple_processing_configurations(tof_camera_ct ptr, tof_processing_config_t* processing_configs, size_t capacity, tof_error_t *error);
230
231/** Get the name for each configuration
232 * @param ptr Pointer to class
233 * @param names Names
234 * @param capacity The amount of data the above pointer can hold
235 * @param error Pointer to error
236 * @return Number of pointers filled or complete array size
237 */
238TOF_EXPORT size_t tof_camera_get_multiple_names(tof_camera_ct ptr, const char** names, size_t capacity, tof_error_t *error);
239
240/** Get the description for each configuration
241 * @param ptr Pointer to class
242 * @param description Descriptions
243 * @param capacity The amount of data the above pointer can hold
244 * @param error Pointer to error
245 * @return Number of pointers filled or complete array size
246 */
247TOF_EXPORT size_t tof_camera_get_multiple_descriptions(tof_camera_ct ptr, const char** description, size_t capacity, tof_error_t *error);
248
249/** A persistent ip data structure
250 */
251typedef struct tof_persistent_ip* tof_persistent_ip_t;
252
253typedef struct tof_persistent_ip const* tof_persistent_ip_ct;
254
255/** Destruct tof_persistent_ip */
256TOF_EXPORT void tof_persistent_ip_delete(tof_persistent_ip_t ptr);
257
258/** Create persistent ip
259 * @param ptr Pointer to class
260 * @param ip IP address
261 * @param netmask Netmask
262 * @param gateway Gateway
263 * @param enabled Enable or disable persistent ip
264 * @param error Pointer to error
265 * @return New object
266 */
267TOF_EXPORT tof_persistent_ip_t tof_persistent_ip_new(const char* ip, const char* netmask, const char* gateway, bool enabled, tof_error_t *error);
268
269/** Get the IP address
270 * @param ptr Pointer to class
271 * @param error Pointer to error
272 * @return the IP address
273 */
274TOF_EXPORT const char* tof_persistent_ip_get_ip(tof_persistent_ip_ct ptr, tof_error_t *error);
275
276/** Set the IP address
277 * @param ptr Pointer to class
278 * @param ip the IP address
279 * @param error Pointer to error
280 */
281TOF_EXPORT void tof_persistent_ip_set_ip(tof_persistent_ip_t ptr, const char* ip, tof_error_t *error);
282
283/** Get the netmask
284 * @param ptr Pointer to class
285 * @param error Pointer to error
286 * @return The netmask
287 */
288TOF_EXPORT const char* tof_persistent_ip_get_netmask(tof_persistent_ip_ct ptr, tof_error_t *error);
289
290/** Set the netmask
291 * @param ptr Pointer to class
292 * @param netmask The netmask
293 * @param error Pointer to error
294 */
295TOF_EXPORT void tof_persistent_ip_set_netmask(tof_persistent_ip_t ptr, const char* netmask, tof_error_t *error);
296
297/** Get the gateway
298 * @param ptr Pointer to class
299 * @param error Pointer to error
300 * @return The gateway
301 */
302TOF_EXPORT const char* tof_persistent_ip_get_gateway(tof_persistent_ip_ct ptr, tof_error_t *error);
303
304/** Set the gateway
305 * @param ptr Pointer to class
306 * @param gateway The gateway
307 * @param error Pointer to error
308 */
309TOF_EXPORT void tof_persistent_ip_set_gateway(tof_persistent_ip_t ptr, const char* gateway, tof_error_t *error);
310
311/** Get if persistent ip is enabled
312 * @param ptr Pointer to class
313 * @param error Pointer to error
314 * @return Is enabled
315 */
316TOF_EXPORT bool tof_persistent_ip_get_enabled(tof_persistent_ip_ct ptr, tof_error_t *error);
317
318/** Set if persistent ip is enabled
319 * @param ptr Pointer to class
320 * @param enabled Is enabled
321 * @param error Pointer to error
322 */
323TOF_EXPORT void tof_persistent_ip_set_enabled(tof_persistent_ip_t ptr, bool enabled, tof_error_t *error);
324
325/** Functions shared across all live cameras
326 */
327typedef struct tof_live_camera* tof_live_camera_t;
328
329typedef struct tof_live_camera const* tof_live_camera_ct;
330
331/** Destruct tof_live_camera */
332TOF_EXPORT void tof_live_camera_delete(tof_live_camera_t ptr);
333
334/** Get the tof library version running on the camera
335 * @param ptr Pointer to class
336 * @param error Pointer to error
337 * @return Version
338 */
339TOF_EXPORT const char* tof_live_camera_version(tof_live_camera_t ptr, tof_error_t *error);
340
341/** Check whether the camera is capable of updating remotely
342 * @param ptr Pointer to class
343 * @param error Pointer to error
344 * @return Remote update capable
345 */
346TOF_EXPORT bool tof_live_camera_remote_update_capable(tof_live_camera_t ptr, tof_error_t *error);
347
348/** Update the camera remotely. After uploading the update file the function
349 * will return. If a correct update file was uploaded, the camera will flash the
350 * update and reboot. This generally takes about a minute. The camera can also
351 * be updated via a web interface by visiting the ip address of the camera on
352 * port 8080, for example http://192.168.1.208:8080
353 * @param ptr Pointer to class
354 * @param file_location Location of the update file
355 * @param error Pointer to error
356 */
357TOF_EXPORT void tof_live_camera_remote_update(tof_live_camera_t ptr, const char* file_location, tof_error_t *error);
358
359/** Whether the camera is capable of setting persistent ip
360 * @param ptr Pointer to class
361 * @param error Pointer to error
362 * @return Persistent ip capable
363 */
364TOF_EXPORT bool tof_live_camera_persistent_ip_capable(tof_live_camera_ct ptr, tof_error_t *error);
365
366/** Get the current persistent ip settings
367 * @param ptr Pointer to class
368 * @param error Pointer to error
369 * @return Persistent IP
370 */
371TOF_EXPORT tof_persistent_ip_t tof_live_camera_get_persistent_ip(tof_live_camera_t ptr, tof_error_t *error);
372
373/** Set the persistent ip settings. To activate persistent ip settings run
374 * apply_persistent_ip.
375 * @param ptr Pointer to class
376 * @param persistent_ip The persistent ip
377 * @param error Pointer to error
378 */
379TOF_EXPORT void tof_live_camera_set_persistent_ip(tof_live_camera_t ptr, tof_persistent_ip_ct persistent_ip, tof_error_t *error);
380
381/** Whether the camera is capable of applying the persistent ip
382 * @param ptr Pointer to class
383 * @param error Pointer to error
384 * @return Capable
385 */
386TOF_EXPORT bool tof_live_camera_apply_persistent_ip_capable(tof_live_camera_ct ptr, tof_error_t *error);
387
388/** Apply persistent ip by rebooting the camera, power cycling the camera is
389 * discouraged because the applied ip settings might not stick.
390 * @param ptr Pointer to class
391 * @param error Pointer to error
392 */
393TOF_EXPORT void tof_live_camera_apply_persistent_ip(tof_live_camera_t ptr, tof_error_t *error);
394
395/** Check whether the camera is capable of software trigger
396 * @param ptr Pointer to class
397 * @param error Pointer to error
398 * @return Software trigger capable
399 */
400TOF_EXPORT bool tof_live_camera_software_trigger_capable(tof_live_camera_t ptr, tof_error_t *error);
401
402/** Software trigger the camera
403 * @param ptr Pointer to class
404 * @param error Pointer to error
405 */
406TOF_EXPORT void tof_live_camera_software_trigger(tof_live_camera_t ptr, tof_error_t *error);
407
408/** Get delay between network packets
409 * @param ptr Pointer to class
410 * @param error Pointer to error
411 * @return The delay, depending on the camera software it is in nanoseconds or
412 * in cpu instruction
413 */
414TOF_EXPORT uint32_t tof_live_camera_get_delay(tof_live_camera_ct ptr, tof_error_t *error);
415
416/** Set delay between network packets
417 * @param ptr Pointer to class
418 * @param delay The delay, depending on the camera software it is in nanoseconds
419 * or in cpu instruction
420 * @param error Pointer to error
421 */
422TOF_EXPORT void tof_live_camera_set_delay(tof_live_camera_t ptr, uint32_t delay, tof_error_t *error);
423
424/** Get maximum size of each network packet transmitted
425 * @param ptr Pointer to class
426 * @param error Pointer to error
427 * @return Packet size in bytes
428 */
429TOF_EXPORT uint16_t tof_live_camera_get_packet_size(tof_live_camera_ct ptr, tof_error_t *error);
430
431/** Set maximum size of each network packet transmitted
432 * @param ptr Pointer to class
433 * @param size Packet size in bytes
434 * @param error Pointer to error
435 */
436TOF_EXPORT void tof_live_camera_set_packet_size(tof_live_camera_t ptr, uint16_t size, tof_error_t *error);
437
438/** Whether the camera is capable of returning temperatures
439 * @param ptr Pointer to class
440 * @param error Pointer to error
441 * @return Capable
442 */
443TOF_EXPORT bool tof_live_camera_get_temperatures_capable(tof_live_camera_t ptr, tof_error_t *error);
444
445/** Get the current on camera temperatures
446 * @param ptr Pointer to class
447 * @param temperatures Temperatures
448 * @param capacity The amount of data the above pointer can hold
449 * @param error Pointer to error
450 * @return Number of pointers filled or complete array size
451 */
452TOF_EXPORT size_t tof_live_camera_get_temperatures(tof_live_camera_t ptr, float* temperatures, size_t capacity, tof_error_t *error);
453
454/** Get voltage level on given pin
455 * @param ptr Pointer to class
456 * @param pin Pin
457 * @param error Pointer to error
458 * @return Voltage 3.3V
459 */
460TOF_EXPORT bool tof_live_camera_get_gpio(tof_live_camera_t ptr, size_t pin, tof_error_t *error);
461
462/** Set voltage level on given pin
463 * @param ptr Pointer to class
464 * @param pin Pin
465 * @param level Voltage level
466 * @param error Pointer to error
467 */
468TOF_EXPORT void tof_live_camera_set_gpio(tof_live_camera_t ptr, size_t pin, bool level, tof_error_t *error);
469
470#ifdef __cplusplus
471}
472#endif
473
474#endif