Time-of-Flight Library(ToF) 3.11.1
 
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 /** Check whether camera supports multiple configurations
186 * @return Multiple configurations possible
187 */
189 auto this_class = reinterpret_cast<tof_kea_camera_t>(this->ptr_);
190 return tof_kea_camera_multiple_configurations_possible(this_class, TOF_ERROR_HANDLER{});
191 }
192
193 /** Set multiple configurations
194 * @param camera_configs Camera configurations
195 * @param pro_configs Processing configurations
196 */
197 void set_multiple_configurations(const std::vector<CameraConfig> &camera_configs, const std::vector<ProcessingConfig> &pro_configs) {
198 auto this_class = reinterpret_cast<tof_kea_camera_t>(this->ptr_);
199 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{});
200 }
201
202};
203
204/** Simple class containing information about found kea cameras
205*/
206class DiscoveredKea : public detail::Base<tof_discovered_kea, tof_discovered_kea_delete> {
207 public:
208 /** Construct from pointer */
209 DiscoveredKea(tof_discovered_kea_t ptr = nullptr) {
210 this->ptr_ = ptr;
211 }
212
213 /** The serial
214 * @return Serial
215 */
216 const char* serial() const {
217 return tof_discovered_kea_serial(this->ptr_, TOF_ERROR_HANDLER{});
218 }
219
220 /** Additional information about the discovered camera
221 * @return Additional information
222 */
223 const char* info() const {
224 return tof_discovered_kea_info(this->ptr_, TOF_ERROR_HANDLER{});
225 }
226
227};
228
229/** Discover all available kea cameras
230 * @return All available kea cameras
231 */
232inline std::vector<DiscoveredKea> discover_kea_cameras() {
233 size_t size = tof_discover_kea_cameras(nullptr, 0, TOF_ERROR_HANDLER{});
234 std::vector<DiscoveredKea> vec;
235 vec.reserve(size);
236 for (size_t i = 0; i < size; i++)
237 vec.emplace_back(static_cast<tof_discovered_kea_t>(nullptr));
238 auto data = reinterpret_cast<tof_discovered_kea_t*>(vec.data());
239 size = tof_discover_kea_cameras(data, vec.size(), TOF_ERROR_HANDLER{});
240 return vec;
241}
242
243/** Construct a kea camera using the gige interface. This could be useful in two
244 * cases. The first is when the camera is connected with both usb and ethernet
245 * but you want to use ethernet. The second is when for some reason the default
246 * maximum packet size is too large.
247 * @param processing_config The processing config
248 * @param serial The serial number of the camera to connect to, if the camera is
249 * available over both usb and gige it will be connected over usb. If an empty
250 * string is supplied the camera will connect to the first usb camera, if no usb
251 * camera is connected it will connect to the first gige camera that replies
252 * (this reply time is random, so you might connect to a different camera each
253 * time if you've got multiple cameras connected to your network). If no camera
254 * is found with the given serial number a nullptr and error is returned.
255 * @param packet_size The packet size to use for communication over ethernet
256 * @return A kea camera
257 */
258inline KeaCamera create_kea_camera_gige(const ProcessingConfig &processing_config, StringView serial, uint16_t packet_size = 1472) {
259 KeaCamera new_kea_camera(static_cast<tof_kea_camera_t>(nullptr));
260 auto ptr = reinterpret_cast<tof_kea_camera_t*>(&new_kea_camera);
261 *ptr = tof_create_kea_camera_gige(*reinterpret_cast<const tof_processing_config_t*>(&processing_config), serial, packet_size, TOF_ERROR_HANDLER{});
262 return new_kea_camera;
263}
264
265} // tof
266} // chronoptics
267
268#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:206
const char * info() const
Additional information about the discovered camera.
Definition: kea_camera.hpp:223
const char * serial() const
The serial.
Definition: kea_camera.hpp:216
DiscoveredKea(tof_discovered_kea_t ptr=nullptr)
Construct from pointer.
Definition: kea_camera.hpp:209
The main interface to the kea camera.
Definition: kea_camera.hpp:15
bool multiple_configurations_possible() const
Check whether camera supports multiple configurations.
Definition: kea_camera.hpp:188
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
void set_multiple_configurations(const std::vector< CameraConfig > &camera_configs, const std::vector< ProcessingConfig > &pro_configs)
Set multiple configurations.
Definition: kea_camera.hpp:197
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.