Time-of-Flight Library(ToF)  3.2.2
usb_interface.h
1 #ifndef _CHRONOPTICS_TOF_USB_INTERFACE_H_
2 #define _CHRONOPTICS_TOF_USB_INTERFACE_H_
3 
4 #include <chronoptics/tof/camera_config.h>
5 #include <chronoptics/tof/calibration.h>
6 #include <chronoptics/tof/data.h>
7 #include <chronoptics/tof/gige_interface.h>
8 
9 #ifdef __cplusplus
10 extern "C" {
11 #endif
12 
13 /** USB device
14  */
15 typedef struct tof_usb_device* tof_usb_device_t;
16 
17 /** Destruct tof_usb_device */
18 TOF_EXPORT void tof_usb_device_delete(tof_usb_device_t ptr);
19 
20 /** Get serial corresponding with USB device
21  * @param ptr Pointer to class
22  * @param error Pointer to error
23  * @return Serial
24  */
25 TOF_EXPORT const char* tof_usb_device_serial(tof_usb_device_t ptr, tof_error_t *error);
26 
27 /** Connect to a camera directly using the USB interface
28  */
29 typedef struct tof_usb_interface* tof_usb_interface_t;
30 
31 /** Destruct tof_usb_interface */
32 TOF_EXPORT void tof_usb_interface_delete(tof_usb_interface_t ptr);
33 
34 /** Create USB camera from a usb device
35  * @param ptr Pointer to class
36  * @param usb_device USB device
37  * @param error Pointer to error
38  * @return New object
39  */
40 TOF_EXPORT tof_usb_interface_t tof_usb_interface_new(tof_usb_device_t usb_device, tof_error_t *error);
41 
42 /** Check whether a connection is still maintained with the camera
43  * @param ptr Pointer to class
44  * @param error Pointer to error
45  * @return Is connected
46  */
47 TOF_EXPORT bool tof_usb_interface_is_connected(const tof_usb_interface_t ptr, tof_error_t *error);
48 
49 /** Tests the connection speed of the USB port. This is useful to check whether
50  * a hub or USB port works well. The maximum speed that the camera is able to
51  * transmit is ~3.0 Gbps.
52  * @param ptr Pointer to class
53  * @param error Pointer to error
54  * @return Connection speed in Gpbs (bits)
55  */
56 TOF_EXPORT double tof_usb_interface_test_stream_speed(tof_usb_interface_t ptr, tof_error_t *error);
57 
58 /** Download camera configuration from the camera
59  * @param ptr Pointer to class
60  * @param error Pointer to error
61  * @return Camera configuration
62  */
63 TOF_EXPORT tof_camera_config_t tof_usb_interface_download_configuration(tof_usb_interface_t ptr, tof_error_t *error);
64 
65 /** Download calibration from the camera
66  * @param ptr Pointer to class
67  * @param error Pointer to error
68  * @return Calibration
69  */
70 TOF_EXPORT tof_calibration_t tof_usb_interface_download_calibration(tof_usb_interface_t ptr, tof_error_t *error);
71 
72 /** Upload camera configuration to the camera
73  * @param ptr Pointer to class
74  * @param config Camera configuration
75  * @param error Pointer to error
76  */
77 TOF_EXPORT void tof_usb_interface_upload_configuration(tof_usb_interface_t ptr, const tof_camera_config_t config, tof_error_t *error);
78 
79 /** Check whether this camera is capable of streaming the specified type
80  * @param ptr Pointer to class
81  * @param stream Depth stream type
82  * @param error Pointer to error
83  * @return Is capable
84  */
85 TOF_EXPORT bool tof_usb_interface_depth_stream_capable(const tof_usb_interface_t ptr, enum tof_depth_stream_type stream, tof_error_t *error);
86 
87 /** Start the depth stream
88  * @param ptr Pointer to class
89  * @param stream Depth stream type
90  * @param error Pointer to error
91  */
92 TOF_EXPORT void tof_usb_interface_start_depth_stream(tof_usb_interface_t ptr, enum tof_depth_stream_type stream, tof_error_t *error);
93 
94 /** Stop the depth stream
95  * @param ptr Pointer to class
96  * @param error Pointer to error
97  */
98 TOF_EXPORT void tof_usb_interface_stop_depth_stream(tof_usb_interface_t ptr, tof_error_t *error);
99 
100 /** Returns true if a depth frame is available
101  * @param ptr Pointer to class
102  * @param error Pointer to error
103  * @return Depth frame available
104  */
105 TOF_EXPORT bool tof_usb_interface_has_depth_data(const tof_usb_interface_t ptr, tof_error_t *error);
106 
107 /** Get a depth frame
108  * @param ptr Pointer to class
109  * @param error Pointer to error
110  * @return Depth frame
111  */
112 TOF_EXPORT tof_data_t tof_usb_interface_get_depth_data(tof_usb_interface_t ptr, tof_error_t *error);
113 
114 /** Check whether camera supports an image stream
115  * @param ptr Pointer to class
116  * @param error Pointer to error
117  * @return Camera supports an image stream
118  */
119 TOF_EXPORT bool tof_usb_interface_image_stream_capable(const tof_usb_interface_t ptr, tof_error_t *error);
120 
121 /** Start image stream
122  * @param ptr Pointer to class
123  * @param error Pointer to error
124  */
125 TOF_EXPORT void tof_usb_interface_start_image_stream(tof_usb_interface_t ptr, tof_error_t *error);
126 
127 /** Stop image stream
128  * @param ptr Pointer to class
129  * @param error Pointer to error
130  */
131 TOF_EXPORT void tof_usb_interface_stop_image_stream(tof_usb_interface_t ptr, tof_error_t *error);
132 
133 /** Check whether image frame is available
134  * @param ptr Pointer to class
135  * @param error Pointer to error
136  * @return Image frame available
137  */
138 TOF_EXPORT bool tof_usb_interface_has_image_data(const tof_usb_interface_t ptr, tof_error_t *error);
139 
140 /** Get image frame
141  * @param ptr Pointer to class
142  * @param error Pointer to error
143  * @return Image data
144  */
145 TOF_EXPORT tof_data_t tof_usb_interface_get_image_data(tof_usb_interface_t ptr, tof_error_t *error);
146 
147 /** Get the image frame into the supplied pointer
148  * @param ptr Pointer to class
149  * @param pointer The pointer to the data to write into
150  * @param capacity The amount of data the pointer can hold
151  * @param callback Callback that will be called when pointer is no longer in
152  * use
153  * @param callback_user_data User data that will be passed back when the function pointer is called
154  * @param error Pointer to error
155  * @return Image data
156  */
157 TOF_EXPORT tof_data_t tof_usb_interface_get_image_data_into_pointer(tof_usb_interface_t ptr, uint8_t* pointer, size_t capacity, tof_user_pointer_destructed_t callback, void* callback_user_data, tof_error_t *error);
158 
159 /** Get the capacity for amount of user pointers that can be registered
160  * @param ptr Pointer to class
161  * @param error Pointer to error
162  * @return User pointer capacity
163  */
164 TOF_EXPORT size_t tof_usb_interface_get_user_pointer_capacity(const tof_usb_interface_t ptr, tof_error_t *error);
165 
166 /** Set the capacity for amount of user pointers that can be registered
167  * @param ptr Pointer to class
168  * @param capacity User pointer capacity
169  * @param error Pointer to error
170  */
171 TOF_EXPORT void tof_usb_interface_set_user_pointer_capacity(tof_usb_interface_t ptr, size_t capacity, tof_error_t *error);
172 
173 /** Add a pointer that will be filled with depth data. This method allows you to
174  * fill data straight into your own data structure without any additional
175  * copying.
176  * @param ptr Pointer to class
177  * @param pointer The pointer to the data to write into
178  * @param capacity The amount of data the pointer can hold
179  * @param callback Callback that will be called when pointer is no longer in
180  * use
181  * @param callback_user_data User data that will be passed back when the function pointer is called
182  * @param error Pointer to error
183  */
184 TOF_EXPORT void tof_usb_interface_add_depth_user_pointer(tof_usb_interface_t ptr, uint8_t* pointer, size_t capacity, tof_user_pointer_destructed_t callback, void* callback_user_data, tof_error_t *error);
185 
186 /** Get the tof library version running on the camera
187  * @param ptr Pointer to class
188  * @param error Pointer to error
189  * @return Version
190  */
191 TOF_EXPORT const char* tof_usb_interface_version(tof_usb_interface_t ptr, tof_error_t *error);
192 
193 /** Discover all connected chronoptics usb cameras
194  * @param usb_devices The usb devices
195  * @param capacity The amount of data the above pointer can hold
196  * @param error Pointer to error
197  * @return Number of pointers filled or complete array size
198  */
199 TOF_EXPORT size_t tof_usb_device_discover(tof_usb_device_t* usb_devices, size_t capacity, tof_error_t *error);
200 
201 /** Discover one chronoptics usb camera
202  * @param error Pointer to error
203  * @return A USB device
204  */
205 TOF_EXPORT tof_usb_device_t tof_usb_device_discover_one(tof_error_t *error);
206 
207 /** Discover usb camera with the given serial
208  * @param serial Serial of the camera to find
209  * @param error Pointer to error
210  * @return A USB device
211  */
212 TOF_EXPORT tof_usb_device_t tof_usb_device_find(const char* serial, tof_error_t *error);
213 
214 #ifdef __cplusplus
215 }
216 #endif
217 
218 #endif