Time-of-Flight Library(ToF) 3.13.3
 
kea_camera.hpp
1#ifndef _CHRONOPTICS_TOF_KEA_CAMERA_HPP_
2#define _CHRONOPTICS_TOF_KEA_CAMERA_HPP_
3
4#include <chronoptics/tof/kea_camera.h>
5
6#include <chronoptics/tof/camera.hpp>
7#include <chronoptics/tof/processing_config.hpp>
8#include <chronoptics/tof/camera_config.hpp>
9#include <chronoptics/tof/gige_interface.hpp>
10
11namespace chronoptics {
12namespace tof {
13
14/** The main interface to the kea camera
15*/
16class KeaCamera : public Camera {
17 public:
18 /** Construct from pointer */
19 KeaCamera(tof_kea_camera_t ptr = nullptr) : Camera(reinterpret_cast<tof_camera_t>(ptr)) {}
20
21 /** Construct the kea camera
22 * @param processing_config The processing config
23 * @param serial The serial number of the camera to connect to, if the camera
24 * is available over both usb and gige it will be connected over usb. If an
25 * empty string is supplied the camera will connect to the first usb camera,
26 * if no usb camera is connected it will connect to the first gige camera that
27 * replies (this reply time is random, so you might connect to a different
28 * camera each time if you've got multiple cameras connected to your network).
29 * If no camera is found with the given serial number a nullptr and error is
30 * returned.
31 */
32 KeaCamera(const ProcessingConfig &processing_config, StringView serial) {
33 this->ptr_ = reinterpret_cast<tof_camera_t>(tof_kea_camera_new(*reinterpret_cast<const tof_processing_config_t*>(&processing_config), serial, TOF_ERROR_HANDLER{}));
34 }
35
36 /** Construct the kea camera with a processing config generated by
37 * default_processing from the camera config
38 * @param serial The serial number of the camera to connect to, if the camera
39 * is available over both usb and gige it will be connected over usb. If an
40 * empty string is supplied the camera will connect to the first usb camera,
41 * if no usb camera is connected it will connect to the first gige camera that
42 * replies (this reply time is random, so you might connect to a different
43 * camera each time if you've got multiple cameras connected to your network).
44 * If no camera is found with the given serial number a nullptr and error is
45 * returned.
46 */
47 KeaCamera(StringView serial) {
48 this->ptr_ = reinterpret_cast<tof_camera_t>(tof_kea_camera_new_simple(serial, TOF_ERROR_HANDLER{}));
49 }
50
51 /** Construct the kea camera with the given processing and camera config.
52 * @param processing_config The processing config
53 * @param serial The serial number of the camera to connect to, if the camera
54 * is available over both usb and gige it will be connected over usb. If an
55 * empty string is supplied the camera will connect to the first usb camera,
56 * if no usb camera is connected it will connect to the first gige camera that
57 * replies (this reply time is random, so you might connect to a different
58 * camera each time if you've got multiple cameras connected to your network).
59 * If no camera is found with the given serial number a nullptr and error is
60 * returned.
61 * @param camera_config The camera config
62 */
63 KeaCamera(const ProcessingConfig &processing_config, StringView serial, const CameraConfig &camera_config) {
64 this->ptr_ = reinterpret_cast<tof_camera_t>(tof_kea_camera_new_both_configs(*reinterpret_cast<const tof_processing_config_t*>(&processing_config), serial, *reinterpret_cast<const tof_camera_config_t*>(&camera_config), TOF_ERROR_HANDLER{}));
65 }
66
67 /** Check whether this kea camera can do on camera processing
68 * @return On camera processing capable
69 */
71 auto this_class = reinterpret_cast<tof_kea_camera_t>(this->ptr_);
72 return tof_kea_camera_on_camera_processing_capable(this_class, TOF_ERROR_HANDLER{});
73 }
74
75 /** Get on camera processing
76 * @return True on camera processing, false on host processing
77 */
79 auto this_class = reinterpret_cast<tof_kea_camera_t>(this->ptr_);
80 return tof_kea_camera_get_on_camera_processing(this_class, TOF_ERROR_HANDLER{});
81 }
82
83 /** Set on camera processing
84 * @param on_camera_processing True on camera processing, false on host
85 * processing
86 */
87 void set_on_camera_processing(bool on_camera_processing) {
88 auto this_class = reinterpret_cast<tof_kea_camera_t>(this->ptr_);
89 return tof_kea_camera_set_on_camera_processing(this_class, on_camera_processing, TOF_ERROR_HANDLER{});
90 }
91
92 /** Get delay between network packets
93 * @return The delay, depending on the camera software it is in nanoseconds or
94 * in cpu instruction
95 */
96 uint32_t get_delay() const {
97 auto this_class = reinterpret_cast<tof_kea_camera_t>(this->ptr_);
98 return tof_kea_camera_get_delay(this_class, TOF_ERROR_HANDLER{});
99 }
100
101 /** Set delay between network packets
102 * @param delay The delay, depending on the camera software it is in
103 * nanoseconds or in cpu instruction
104 */
105 void set_delay(uint32_t delay) {
106 auto this_class = reinterpret_cast<tof_kea_camera_t>(this->ptr_);
107 return tof_kea_camera_set_delay(this_class, delay, TOF_ERROR_HANDLER{});
108 }
109
110 /** Get maximum size of each network packet transmitted
111 * @return Packet size in bytes
112 */
113 uint16_t get_packet_size() const {
114 auto this_class = reinterpret_cast<tof_kea_camera_t>(this->ptr_);
115 return tof_kea_camera_get_packet_size(this_class, TOF_ERROR_HANDLER{});
116 }
117
118 /** Set maximum size of each network packet transmitted
119 * @param size Packet size in bytes
120 */
121 void set_packet_size(uint16_t size) {
122 auto this_class = reinterpret_cast<tof_kea_camera_t>(this->ptr_);
123 return tof_kea_camera_set_packet_size(this_class, size, TOF_ERROR_HANDLER{});
124 }
125
126 /** Set the camera config
127 * @param camera_config Camera config
128 */
129 void set_camera_config(const CameraConfig &camera_config) {
130 auto this_class = reinterpret_cast<tof_kea_camera_t>(this->ptr_);
131 return tof_kea_camera_set_camera_config(this_class, *reinterpret_cast<const tof_camera_config_t*>(&camera_config), TOF_ERROR_HANDLER{});
132 }
133
134 /** Set both the camera and processing config
135 * @param camera_config Camera config
136 * @param processing_config Processing config
137 */
138 void set_configurations(const CameraConfig &camera_config, const ProcessingConfig &processing_config) {
139 auto this_class = reinterpret_cast<tof_kea_camera_t>(this->ptr_);
140 return tof_kea_camera_set_configurations(this_class, *reinterpret_cast<const tof_camera_config_t*>(&camera_config), *reinterpret_cast<const tof_processing_config_t*>(&processing_config), TOF_ERROR_HANDLER{});
141 }
142
143 /** Get the tof library version running on the camera
144 * @return Version
145 */
146 const char* version() {
147 auto this_class = reinterpret_cast<tof_kea_camera_t>(this->ptr_);
148 return tof_kea_camera_version(this_class, TOF_ERROR_HANDLER{});
149 }
150
151 /** Check whether the camera is capable of software trigger
152 * @return Software trigger capable
153 */
155 auto this_class = reinterpret_cast<tof_kea_camera_t>(this->ptr_);
156 return tof_kea_camera_software_trigger_capable(this_class, TOF_ERROR_HANDLER{});
157 }
158
159 /** Software trigger the camera
160 */
162 auto this_class = reinterpret_cast<tof_kea_camera_t>(this->ptr_);
163 return tof_kea_camera_software_trigger(this_class, TOF_ERROR_HANDLER{});
164 }
165
166 /** Check whether the camera is capable of updating remotely
167 * @return Remote update capable
168 */
170 auto this_class = reinterpret_cast<tof_kea_camera_t>(this->ptr_);
171 return tof_kea_camera_remote_update_capable(this_class, TOF_ERROR_HANDLER{});
172 }
173
174 /** Update the camera remotely. After uploading the update file the function
175 * will return. If a correct update file was uploaded, the camera will flash
176 * the update and reboot. This generally takes about a minute. The camera can
177 * also be updated via a web interface by visiting the ip address of the
178 * camera on port 8080, for example http://192.168.1.208:8080
179 * @param file_location Location of the update file
180 */
181 void remote_update(StringView file_location) {
182 auto this_class = reinterpret_cast<tof_kea_camera_t>(this->ptr_);
183 return tof_kea_camera_remote_update(this_class, file_location, TOF_ERROR_HANDLER{});
184 }
185
186 /** Check whether camera supports multiple configurations
187 * @return Multiple configurations possible
188 */
190 auto this_class = reinterpret_cast<tof_kea_camera_t>(this->ptr_);
191 return tof_kea_camera_multiple_configurations_possible(this_class, TOF_ERROR_HANDLER{});
192 }
193
194 /** Set multiple configurations
195 * @param camera_configs Camera configurations
196 * @param pro_configs Processing configurations
197 */
198 void set_multiple_configurations(const std::vector<CameraConfig> &camera_configs, const std::vector<ProcessingConfig> &pro_configs) {
199 auto this_class = reinterpret_cast<tof_kea_camera_t>(this->ptr_);
200 return tof_kea_camera_set_multiple_configurations(this_class, reinterpret_cast<const tof_camera_config_t*>(camera_configs.data()), camera_configs.size(), reinterpret_cast<const tof_processing_config_t*>(pro_configs.data()), pro_configs.size(), TOF_ERROR_HANDLER{});
201 }
202
203 /** Whether the camera is capable of returning temperatures
204 * @return Capable
205 */
207 auto this_class = reinterpret_cast<tof_kea_camera_t>(this->ptr_);
208 return tof_kea_camera_get_temperatures_capable(this_class, TOF_ERROR_HANDLER{});
209 }
210
211 /** Get the current on camera temperatures
212 * @return Temperatures
213 */
214 std::vector<float> get_temperatures() {
215 auto this_class = reinterpret_cast<tof_kea_camera_t>(this->ptr_);
216 size_t size = tof_kea_camera_get_temperatures(this_class, nullptr, 0, TOF_ERROR_HANDLER{});
217 std::vector<float> vec(size);
218 size = tof_kea_camera_get_temperatures(this_class, vec.data(), vec.size(), TOF_ERROR_HANDLER{});
219 return vec;
220 }
221
222 /** Whether the camera is persistent ip capable
223 * @return Persistent IP capable
224 */
226 auto this_class = reinterpret_cast<tof_kea_camera_t>(this->ptr_);
227 return tof_kea_camera_persistent_ip_capable(this_class, TOF_ERROR_HANDLER{});
228 }
229
230 /** Get the current persistent ip settings
231 * @return Persistent IP
232 */
234 auto this_class = reinterpret_cast<tof_kea_camera_t>(this->ptr_);
235 PersistentIp new_persistent_ip(static_cast<tof_persistent_ip_t>(nullptr));
236 auto ptr = reinterpret_cast<tof_persistent_ip_t*>(&new_persistent_ip);
237 *ptr = tof_kea_camera_get_persistent_ip(this_class, TOF_ERROR_HANDLER{});
238 return new_persistent_ip;
239 }
240
241 /** Set the persistent ip settings. To activate persistent ip settings run
242 * apply_persistent_ip.
243 * @param persistent_ip The persistent ip
244 */
245 void set_persistent_ip(const PersistentIp &persistent_ip) {
246 auto this_class = reinterpret_cast<tof_kea_camera_t>(this->ptr_);
247 return tof_kea_camera_set_persistent_ip(this_class, *reinterpret_cast<const tof_persistent_ip_t*>(&persistent_ip), TOF_ERROR_HANDLER{});
248 }
249
250 /** Whether the camera is capable of applying the persistent ip
251 * @return Capable
252 */
254 auto this_class = reinterpret_cast<tof_kea_camera_t>(this->ptr_);
255 return tof_kea_camera_apply_persistent_ip_capable(this_class, TOF_ERROR_HANDLER{});
256 }
257
258 /** Apply persistent ip by rebooting the camera, power cycling the camera is
259 * discouraged because the applied ip settings might not stick.
260 */
262 auto this_class = reinterpret_cast<tof_kea_camera_t>(this->ptr_);
263 return tof_kea_camera_apply_persistent_ip(this_class, TOF_ERROR_HANDLER{});
264 }
265
266};
267
268/** Simple class containing information about found kea cameras
269*/
270class DiscoveredKea : public detail::Base<tof_discovered_kea, tof_discovered_kea_delete> {
271 public:
272 /** Construct from pointer */
273 DiscoveredKea(tof_discovered_kea_t ptr = nullptr) {
274 this->ptr_ = ptr;
275 }
276
277 /** The serial
278 * @return Serial
279 */
280 const char* serial() const {
281 return tof_discovered_kea_serial(this->ptr_, TOF_ERROR_HANDLER{});
282 }
283
284 /** Additional information about the discovered camera
285 * @return Additional information
286 */
287 const char* info() const {
288 return tof_discovered_kea_info(this->ptr_, TOF_ERROR_HANDLER{});
289 }
290
291 /** Get the camera model name
292 * @return Camera model
293 */
294 const char* model() const {
295 return tof_discovered_kea_model(this->ptr_, TOF_ERROR_HANDLER{});
296 }
297
298 /** Check whether this camera is a TUI camera
299 * @return Is tui
300 */
301 bool is_tui() const {
302 return tof_discovered_kea_is_tui(this->ptr_, TOF_ERROR_HANDLER{});
303 }
304
305};
306
307/** Discover all available kea cameras
308 * @return All available kea cameras
309 */
310inline std::vector<DiscoveredKea> discover_kea_cameras() {
311 size_t size = tof_discover_kea_cameras(nullptr, 0, TOF_ERROR_HANDLER{});
312 std::vector<DiscoveredKea> vec;
313 vec.reserve(size);
314 for (size_t i = 0; i < size; i++)
315 vec.emplace_back(static_cast<tof_discovered_kea_t>(nullptr));
316 auto data = reinterpret_cast<tof_discovered_kea_t*>(vec.data());
317 size = tof_discover_kea_cameras(data, vec.size(), TOF_ERROR_HANDLER{});
318 return vec;
319}
320
321/** Construct a kea camera using the gige interface. This could be useful in two
322 * cases. The first is when the camera is connected with both usb and ethernet
323 * but you want to use ethernet. The second is when for some reason the default
324 * maximum packet size is too large.
325 * @param processing_config The processing config
326 * @param serial The serial number of the camera to connect to, if the camera is
327 * available over both usb and gige it will be connected over usb. If an empty
328 * string is supplied the camera will connect to the first usb camera, if no usb
329 * camera is connected it will connect to the first gige camera that replies
330 * (this reply time is random, so you might connect to a different camera each
331 * time if you've got multiple cameras connected to your network). If no camera
332 * is found with the given serial number a nullptr and error is returned.
333 * @param packet_size The packet size to use for communication over ethernet
334 * @return A kea camera
335 */
336inline KeaCamera create_kea_camera_gige(const ProcessingConfig &processing_config, StringView serial, uint16_t packet_size = 1472) {
337 KeaCamera new_kea_camera(static_cast<tof_kea_camera_t>(nullptr));
338 auto ptr = reinterpret_cast<tof_kea_camera_t*>(&new_kea_camera);
339 *ptr = tof_create_kea_camera_gige(*reinterpret_cast<const tof_processing_config_t*>(&processing_config), serial, packet_size, TOF_ERROR_HANDLER{});
340 return new_kea_camera;
341}
342
343} // tof
344} // chronoptics
345
346#endif
This class allows you to view/edit the camera settings.
The main interface to the depth cameras.
Definition: camera.hpp:17
Simple class containing information about found kea cameras.
Definition: kea_camera.hpp:270
bool is_tui() const
Check whether this camera is a TUI camera.
Definition: kea_camera.hpp:301
const char * info() const
Additional information about the discovered camera.
Definition: kea_camera.hpp:287
const char * serial() const
The serial.
Definition: kea_camera.hpp:280
DiscoveredKea(tof_discovered_kea_t ptr=nullptr)
Construct from pointer.
Definition: kea_camera.hpp:273
const char * model() const
Get the camera model name.
Definition: kea_camera.hpp:294
The main interface to the kea camera.
Definition: kea_camera.hpp:16
bool multiple_configurations_possible() const
Check whether camera supports multiple configurations.
Definition: kea_camera.hpp:189
bool on_camera_processing_capable() const
Check whether this kea camera can do on camera processing.
Definition: kea_camera.hpp:70
KeaCamera(tof_kea_camera_t ptr=nullptr)
Construct from pointer.
Definition: kea_camera.hpp:19
bool remote_update_capable()
Check whether the camera is capable of updating remotely.
Definition: kea_camera.hpp:169
void software_trigger()
Software trigger the camera.
Definition: kea_camera.hpp:161
void set_on_camera_processing(bool on_camera_processing)
Set on camera processing.
Definition: kea_camera.hpp:87
void set_multiple_configurations(const std::vector< CameraConfig > &camera_configs, const std::vector< ProcessingConfig > &pro_configs)
Set multiple configurations.
Definition: kea_camera.hpp:198
bool software_trigger_capable()
Check whether the camera is capable of software trigger.
Definition: kea_camera.hpp:154
void set_packet_size(uint16_t size)
Set maximum size of each network packet transmitted.
Definition: kea_camera.hpp:121
bool apply_persistent_ip_capable() const
Whether the camera is capable of applying the persistent ip.
Definition: kea_camera.hpp:253
bool get_temperatures_capable()
Whether the camera is capable of returning temperatures.
Definition: kea_camera.hpp:206
bool get_on_camera_processing() const
Get on camera processing.
Definition: kea_camera.hpp:78
void set_configurations(const CameraConfig &camera_config, const ProcessingConfig &processing_config)
Set both the camera and processing config.
Definition: kea_camera.hpp:138
PersistentIp get_persistent_ip() const
Get the current persistent ip settings.
Definition: kea_camera.hpp:233
uint32_t get_delay() const
Get delay between network packets.
Definition: kea_camera.hpp:96
uint16_t get_packet_size() const
Get maximum size of each network packet transmitted.
Definition: kea_camera.hpp:113
KeaCamera(const ProcessingConfig &processing_config, StringView serial, const CameraConfig &camera_config)
Construct the kea camera with the given processing and camera config.
Definition: kea_camera.hpp:63
const char * version()
Get the tof library version running on the camera.
Definition: kea_camera.hpp:146
void remote_update(StringView file_location)
Update the camera remotely.
Definition: kea_camera.hpp:181
void set_persistent_ip(const PersistentIp &persistent_ip)
Set the persistent ip settings.
Definition: kea_camera.hpp:245
std::vector< float > get_temperatures()
Get the current on camera temperatures.
Definition: kea_camera.hpp:214
void set_camera_config(const CameraConfig &camera_config)
Set the camera config.
Definition: kea_camera.hpp:129
void set_delay(uint32_t delay)
Set delay between network packets.
Definition: kea_camera.hpp:105
KeaCamera(StringView serial)
Construct the kea camera with a processing config generated by default_processing from the camera con...
Definition: kea_camera.hpp:47
void apply_persistent_ip()
Apply persistent ip by rebooting the camera, power cycling the camera is discouraged because the appl...
Definition: kea_camera.hpp:261
KeaCamera(const ProcessingConfig &processing_config, StringView serial)
Construct the kea camera.
Definition: kea_camera.hpp:32
bool persistent_ip_capable() const
Whether the camera is persistent ip capable.
Definition: kea_camera.hpp:225
A persistent ip data structure.
Processing that can be done.