Time-of-Flight Library(ToF) 3.10.9
 
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
10namespace chronoptics {
11namespace tof {
12
13/** The main interface to the kea camera
14*/
15class KeaCamera : public Camera {
16 public:
17 /** Construct from pointer */
18 KeaCamera(tof_kea_camera_t ptr = nullptr) : Camera(reinterpret_cast<tof_camera_t>(ptr)) {}
19
20 /** Construct the kea camera
21 * @param processing_config The processing config
22 * @param serial The serial number of the camera to connect to, if the camera
23 * is available over both usb and gige it will be connected over usb. If an
24 * empty string is supplied the camera will connect to the first usb camera,
25 * if no usb camera is connected it will connect to the first gige camera that
26 * replies (this reply time is random, so you might connect to a different
27 * camera each time if you've got multiple cameras connected to your network).
28 * If no camera is found with the given serial number a nullptr and error is
29 * returned.
30 */
31 KeaCamera(const ProcessingConfig &processing_config, StringView serial) {
32 this->ptr_ = reinterpret_cast<tof_camera_t>(tof_kea_camera_new(*reinterpret_cast<const tof_processing_config_t*>(&processing_config), serial, TOF_ERROR_HANDLER{}));
33 }
34
35 /** Construct the kea camera with a processing config generated by
36 * default_processing from the camera config
37 * @param serial The serial number of the camera to connect to, if the camera
38 * is available over both usb and gige it will be connected over usb. If an
39 * empty string is supplied the camera will connect to the first usb camera,
40 * if no usb camera is connected it will connect to the first gige camera that
41 * replies (this reply time is random, so you might connect to a different
42 * camera each time if you've got multiple cameras connected to your network).
43 * If no camera is found with the given serial number a nullptr and error is
44 * returned.
45 */
46 KeaCamera(StringView serial) {
47 this->ptr_ = reinterpret_cast<tof_camera_t>(tof_kea_camera_new_simple(serial, TOF_ERROR_HANDLER{}));
48 }
49
50 /** Construct the kea camera with the given processing and camera config.
51 * @param processing_config The processing config
52 * @param serial The serial number of the camera to connect to, if the camera
53 * is available over both usb and gige it will be connected over usb. If an
54 * empty string is supplied the camera will connect to the first usb camera,
55 * if no usb camera is connected it will connect to the first gige camera that
56 * replies (this reply time is random, so you might connect to a different
57 * camera each time if you've got multiple cameras connected to your network).
58 * If no camera is found with the given serial number a nullptr and error is
59 * returned.
60 * @param camera_config The camera config
61 */
62 KeaCamera(const ProcessingConfig &processing_config, StringView serial, const CameraConfig &camera_config) {
63 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{}));
64 }
65
66 /** Check whether this kea camera can do on camera processing
67 * @return On camera processing capable
68 */
70 auto this_class = reinterpret_cast<tof_kea_camera_t>(this->ptr_);
71 return tof_kea_camera_on_camera_processing_capable(this_class, TOF_ERROR_HANDLER{});
72 }
73
74 /** Get on camera processing
75 * @return True on camera processing, false on host processing
76 */
78 auto this_class = reinterpret_cast<tof_kea_camera_t>(this->ptr_);
79 return tof_kea_camera_get_on_camera_processing(this_class, TOF_ERROR_HANDLER{});
80 }
81
82 /** Set on camera processing
83 * @param on_camera_processing True on camera processing, false on host
84 * processing
85 */
86 void set_on_camera_processing(bool on_camera_processing) {
87 auto this_class = reinterpret_cast<tof_kea_camera_t>(this->ptr_);
88 return tof_kea_camera_set_on_camera_processing(this_class, on_camera_processing, TOF_ERROR_HANDLER{});
89 }
90
91 /** Get delay between network packets
92 * @return The delay, depending on the camera software it is in nanoseconds or
93 * in cpu instruction
94 */
95 uint32_t get_delay() const {
96 auto this_class = reinterpret_cast<tof_kea_camera_t>(this->ptr_);
97 return tof_kea_camera_get_delay(this_class, TOF_ERROR_HANDLER{});
98 }
99
100 /** Set delay between network packets
101 * @param delay The delay, depending on the camera software it is in
102 * nanoseconds or in cpu instruction
103 */
104 void set_delay(uint32_t delay) {
105 auto this_class = reinterpret_cast<tof_kea_camera_t>(this->ptr_);
106 return tof_kea_camera_set_delay(this_class, delay, TOF_ERROR_HANDLER{});
107 }
108
109 /** Get maximum size of each network packet transmitted
110 * @return Packet size in bytes
111 */
112 uint16_t get_packet_size() const {
113 auto this_class = reinterpret_cast<tof_kea_camera_t>(this->ptr_);
114 return tof_kea_camera_get_packet_size(this_class, TOF_ERROR_HANDLER{});
115 }
116
117 /** Set maximum size of each network packet transmitted
118 * @param size Packet size in bytes
119 */
120 void set_packet_size(uint16_t size) {
121 auto this_class = reinterpret_cast<tof_kea_camera_t>(this->ptr_);
122 return tof_kea_camera_set_packet_size(this_class, size, TOF_ERROR_HANDLER{});
123 }
124
125 /** Set the camera config
126 * @param camera_config Camera config
127 */
128 void set_camera_config(const CameraConfig &camera_config) {
129 auto this_class = reinterpret_cast<tof_kea_camera_t>(this->ptr_);
130 return tof_kea_camera_set_camera_config(this_class, *reinterpret_cast<const tof_camera_config_t*>(&camera_config), TOF_ERROR_HANDLER{});
131 }
132
133 /** Set both the camera and processing config
134 * @param camera_config Camera config
135 * @param processing_config Processing config
136 */
137 void set_configurations(const CameraConfig &camera_config, const ProcessingConfig &processing_config) {
138 auto this_class = reinterpret_cast<tof_kea_camera_t>(this->ptr_);
139 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{});
140 }
141
142 /** Get the tof library version running on the camera
143 * @return Version
144 */
145 const char* version() {
146 auto this_class = reinterpret_cast<tof_kea_camera_t>(this->ptr_);
147 return tof_kea_camera_version(this_class, TOF_ERROR_HANDLER{});
148 }
149
150 /** Check whether the camera is capable of software trigger
151 * @return Software trigger capable
152 */
154 auto this_class = reinterpret_cast<tof_kea_camera_t>(this->ptr_);
155 return tof_kea_camera_software_trigger_capable(this_class, TOF_ERROR_HANDLER{});
156 }
157
158 /** Software trigger the camera
159 */
161 auto this_class = reinterpret_cast<tof_kea_camera_t>(this->ptr_);
162 return tof_kea_camera_software_trigger(this_class, TOF_ERROR_HANDLER{});
163 }
164
165 /** Check whether the camera is capable of updating remotely
166 * @return Remote update capable
167 */
169 auto this_class = reinterpret_cast<tof_kea_camera_t>(this->ptr_);
170 return tof_kea_camera_remote_update_capable(this_class, TOF_ERROR_HANDLER{});
171 }
172
173 /** Update the camera remotely. After uploading the update file the function
174 * will return. If a correct update file was uploaded, the camera will flash
175 * the update and reboot. This generally takes about a minute. The camera can
176 * also be updated via a web interface by visiting the ip address of the
177 * camera on port 8080, for example http://192.168.1.208:8080
178 * @param file_location Location of the update file
179 */
180 void remote_update(StringView file_location) {
181 auto this_class = reinterpret_cast<tof_kea_camera_t>(this->ptr_);
182 return tof_kea_camera_remote_update(this_class, file_location, TOF_ERROR_HANDLER{});
183 }
184
185};
186
187/** Simple class containing information about found kea cameras
188*/
189class DiscoveredKea : public detail::Base<tof_discovered_kea, tof_discovered_kea_delete> {
190 public:
191 /** Construct from pointer */
192 DiscoveredKea(tof_discovered_kea_t ptr = nullptr) {
193 this->ptr_ = ptr;
194 }
195
196 /** The serial
197 * @return Serial
198 */
199 const char* serial() const {
200 return tof_discovered_kea_serial(this->ptr_, TOF_ERROR_HANDLER{});
201 }
202
203 /** Additional information about the discovered camera
204 * @return Additional information
205 */
206 const char* info() const {
207 return tof_discovered_kea_info(this->ptr_, TOF_ERROR_HANDLER{});
208 }
209
210};
211
212/** Discover all available kea cameras
213 * @return All available kea cameras
214 */
215inline std::vector<DiscoveredKea> discover_kea_cameras() {
216 size_t size = tof_discover_kea_cameras(nullptr, 0, TOF_ERROR_HANDLER{});
217 std::vector<DiscoveredKea> vec;
218 vec.reserve(size);
219 for (size_t i = 0; i < size; i++)
220 vec.emplace_back(static_cast<tof_discovered_kea_t>(nullptr));
221 auto data = reinterpret_cast<tof_discovered_kea_t*>(vec.data());
222 size = tof_discover_kea_cameras(data, vec.size(), TOF_ERROR_HANDLER{});
223 return vec;
224}
225
226/** Construct a kea camera using the gige interface. This could be useful in two
227 * cases. The first is when the camera is connected with both usb and ethernet
228 * but you want to use ethernet. The second is when for some reason the default
229 * maximum packet size is too large.
230 * @param processing_config The processing config
231 * @param serial The serial number of the camera to connect to, if the camera is
232 * available over both usb and gige it will be connected over usb. If an empty
233 * string is supplied the camera will connect to the first usb camera, if no usb
234 * camera is connected it will connect to the first gige camera that replies
235 * (this reply time is random, so you might connect to a different camera each
236 * time if you've got multiple cameras connected to your network). If no camera
237 * is found with the given serial number a nullptr and error is returned.
238 * @param packet_size The packet size to use for communication over ethernet
239 * @return A kea camera
240 */
241inline KeaCamera create_kea_camera_gige(const ProcessingConfig &processing_config, StringView serial, uint16_t packet_size = 1472) {
242 KeaCamera new_kea_camera(static_cast<tof_kea_camera_t>(nullptr));
243 auto ptr = reinterpret_cast<tof_kea_camera_t*>(&new_kea_camera);
244 *ptr = tof_create_kea_camera_gige(*reinterpret_cast<const tof_processing_config_t*>(&processing_config), serial, packet_size, TOF_ERROR_HANDLER{});
245 return new_kea_camera;
246}
247
248} // tof
249} // chronoptics
250
251#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:189
const char * info() const
Additional information about the discovered camera.
Definition: kea_camera.hpp:206
const char * serial() const
The serial.
Definition: kea_camera.hpp:199
DiscoveredKea(tof_discovered_kea_t ptr=nullptr)
Construct from pointer.
Definition: kea_camera.hpp:192
The main interface to the kea camera.
Definition: kea_camera.hpp:15
bool on_camera_processing_capable() const
Check whether this kea camera can do on camera processing.
Definition: kea_camera.hpp:69
KeaCamera(tof_kea_camera_t ptr=nullptr)
Construct from pointer.
Definition: kea_camera.hpp:18
bool remote_update_capable()
Check whether the camera is capable of updating remotely.
Definition: kea_camera.hpp:168
void software_trigger()
Software trigger the camera.
Definition: kea_camera.hpp:160
void set_on_camera_processing(bool on_camera_processing)
Set on camera processing.
Definition: kea_camera.hpp:86
bool software_trigger_capable()
Check whether the camera is capable of software trigger.
Definition: kea_camera.hpp:153
void set_packet_size(uint16_t size)
Set maximum size of each network packet transmitted.
Definition: kea_camera.hpp:120
bool get_on_camera_processing() const
Get on camera processing.
Definition: kea_camera.hpp:77
void set_configurations(const CameraConfig &camera_config, const ProcessingConfig &processing_config)
Set both the camera and processing config.
Definition: kea_camera.hpp:137
uint32_t get_delay() const
Get delay between network packets.
Definition: kea_camera.hpp:95
uint16_t get_packet_size() const
Get maximum size of each network packet transmitted.
Definition: kea_camera.hpp:112
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:62
const char * version()
Get the tof library version running on the camera.
Definition: kea_camera.hpp:145
void remote_update(StringView file_location)
Update the camera remotely.
Definition: kea_camera.hpp:180
void set_camera_config(const CameraConfig &camera_config)
Set the camera config.
Definition: kea_camera.hpp:128
void set_delay(uint32_t delay)
Set delay between network packets.
Definition: kea_camera.hpp:104
KeaCamera(StringView serial)
Construct the kea camera with a processing config generated by default_processing from the camera con...
Definition: kea_camera.hpp:46
KeaCamera(const ProcessingConfig &processing_config, StringView serial)
Construct the kea camera.
Definition: kea_camera.hpp:31
Processing that can be done.