Time-of-Flight Library(ToF) 4.0.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 LiveCamera {
16 public:
17 /** Construct from pointer */
18 KeaCamera(tof_kea_camera_t ptr = nullptr) : LiveCamera(reinterpret_cast<tof_live_camera_t>(ptr)) {}
19
20 /** Construct the kea camera with the given processing and camera config.
21 * @param serial The serial number of the camera to connect to, if the camera
22 * is available over both usb and gige it will be connected over usb. If an
23 * empty string is supplied the camera will connect to the first usb camera,
24 * if no usb camera is connected it will connect to the first gige camera that
25 * replies (this reply time is random, so you might connect to a different
26 * camera each time if you've got multiple cameras connected to your network).
27 * If no camera is found with the given serial number a nullptr and error is
28 * returned.
29 * @param processing_config The processing config
30 * @param camera_config The camera config
31 */
32 KeaCamera(StringView serial, const ProcessingConfig &processing_config, const CameraConfig &camera_config) : KeaCamera(tof_kea_camera_new_both_configs(serial, *reinterpret_cast<const tof_processing_config_t*>(&processing_config), *reinterpret_cast<const tof_camera_config_t*>(&camera_config), TOF_ERROR_HANDLER{})) {}
33
34 /** Construct the kea camera
35 * @param serial The serial number of the camera to connect to, if the camera
36 * is available over both usb and gige it will be connected over usb. If an
37 * empty string is supplied the camera will connect to the first usb camera,
38 * if no usb camera is connected it will connect to the first gige camera that
39 * replies (this reply time is random, so you might connect to a different
40 * camera each time if you've got multiple cameras connected to your network).
41 * If no camera is found with the given serial number a nullptr and error is
42 * returned.
43 * @param processing_config The processing config
44 */
45 KeaCamera(StringView serial, const ProcessingConfig &processing_config) : KeaCamera(tof_kea_camera_new(serial, *reinterpret_cast<const tof_processing_config_t*>(&processing_config), TOF_ERROR_HANDLER{})) {}
46
47 /** Construct the kea camera with a processing config generated by
48 * default_processing from the camera config
49 * @param serial The serial number of the camera to connect to, if the camera
50 * is available over both usb and gige it will be connected over usb. If an
51 * empty string is supplied the camera will connect to the first usb camera,
52 * if no usb camera is connected it will connect to the first gige camera that
53 * replies (this reply time is random, so you might connect to a different
54 * camera each time if you've got multiple cameras connected to your network).
55 * If no camera is found with the given serial number a nullptr and error is
56 * returned.
57 */
58 KeaCamera(StringView serial) : KeaCamera(tof_kea_camera_new_simple(serial, TOF_ERROR_HANDLER{})) {}
59
60 /** Check whether this kea camera can do on camera processing
61 * @return On camera processing capable
62 */
64 auto this_class = reinterpret_cast<tof_kea_camera_t>(this->ptr_);
65 return tof_kea_camera_on_camera_processing_capable(this_class, TOF_ERROR_HANDLER{});
66 }
67
68 /** Get on camera processing
69 * @return True on camera processing, false on host processing
70 */
72 auto this_class = reinterpret_cast<tof_kea_camera_t>(this->ptr_);
73 return tof_kea_camera_get_on_camera_processing(this_class, TOF_ERROR_HANDLER{});
74 }
75
76 /** Set on camera processing
77 * @param on_camera_processing True on camera processing, false on host
78 * processing
79 */
80 void set_on_camera_processing(bool on_camera_processing) {
81 auto this_class = reinterpret_cast<tof_kea_camera_t>(this->ptr_);
82 return tof_kea_camera_set_on_camera_processing(this_class, on_camera_processing, TOF_ERROR_HANDLER{});
83 }
84
85 /** Set the camera config
86 * @param camera_config Camera config
87 */
88 void set_camera_config(const CameraConfig &camera_config) {
89 auto this_class = reinterpret_cast<tof_kea_camera_t>(this->ptr_);
90 return tof_kea_camera_set_camera_config(this_class, *reinterpret_cast<const tof_camera_config_t*>(&camera_config), TOF_ERROR_HANDLER{});
91 }
92
93 /** Set both the camera and processing config
94 * @param camera_config Camera config
95 * @param processing_config Processing config
96 */
97 void set_configurations(const CameraConfig &camera_config, const ProcessingConfig &processing_config) {
98 auto this_class = reinterpret_cast<tof_kea_camera_t>(this->ptr_);
99 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{});
100 }
101
102 /** Check whether camera supports multiple configurations
103 * @return Multiple configurations possible
104 */
106 auto this_class = reinterpret_cast<tof_kea_camera_t>(this->ptr_);
107 return tof_kea_camera_multiple_configurations_possible(this_class, TOF_ERROR_HANDLER{});
108 }
109
110 /** Set multiple configurations
111 * @param camera_configs Camera configurations
112 * @param pro_configs Processing configurations
113 */
114 void set_multiple_configurations(const std::vector<CameraConfig> &camera_configs, const std::vector<ProcessingConfig> &pro_configs) {
115 auto this_class = reinterpret_cast<tof_kea_camera_t>(this->ptr_);
116 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{});
117 }
118
119 /** the processing config of the camera
120 * @param config The processing config
121 */
123 auto this_class = reinterpret_cast<tof_kea_camera_t>(this->ptr_);
124 return tof_kea_camera_set_process_config(this_class, *reinterpret_cast<const tof_processing_config_t*>(&config), TOF_ERROR_HANDLER{});
125 }
126
127};
128
129/** Simple class containing information about found cameras
130*/
131class DiscoveredCamera : public detail::Base<tof_discovered_camera, tof_discovered_camera_delete> {
132 public:
133 /** Construct from pointer */
134 DiscoveredCamera(tof_discovered_camera_t ptr = nullptr) {
135 this->ptr_ = ptr;
136 }
137
138 /** The serial
139 * @return Serial
140 */
141 const char* serial() const {
142 return tof_discovered_camera_serial(this->ptr_, TOF_ERROR_HANDLER{});
143 }
144
145 /** Additional information about the discovered camera
146 * @return Additional information
147 */
148 const char* info() const {
149 return tof_discovered_camera_info(this->ptr_, TOF_ERROR_HANDLER{});
150 }
151
152 /** Get the camera model name
153 * @return Camera model
154 */
155 const char* model() const {
156 return tof_discovered_camera_model(this->ptr_, TOF_ERROR_HANDLER{});
157 }
158
159 /** Check whether this camera is a TUI camera
160 * @return Is tui
161 */
162 bool is_tui() const {
163 return tof_discovered_camera_is_tui(this->ptr_, TOF_ERROR_HANDLER{});
164 }
165
166};
167
168/** Discover all available cameras
169 * @return All available cameras
170 */
171inline std::vector<DiscoveredCamera> discover_cameras() {
172 size_t size = tof_discover_cameras(nullptr, 0, TOF_ERROR_HANDLER{});
173 std::vector<DiscoveredCamera> vec;
174 vec.reserve(size);
175 for (size_t i = 0; i < size; i++)
176 vec.emplace_back(static_cast<tof_discovered_camera_t>(nullptr));
177 auto data = reinterpret_cast<tof_discovered_camera_t*>(vec.data());
178 size = tof_discover_cameras(data, vec.size(), TOF_ERROR_HANDLER{});
179 return vec;
180}
181
182/** Construct a kea camera using the gige interface. This could be useful in two
183 * cases. The first is when the camera is connected with both usb and ethernet
184 * but you want to use ethernet. The second is when for some reason the default
185 * maximum packet size is too large.
186 * @param processing_config The processing config
187 * @param serial The serial number of the camera to connect to, if the camera is
188 * available over both usb and gige it will be connected over usb. If an empty
189 * string is supplied the camera will connect to the first usb camera, if no usb
190 * camera is connected it will connect to the first gige camera that replies
191 * (this reply time is random, so you might connect to a different camera each
192 * time if you've got multiple cameras connected to your network). If no camera
193 * is found with the given serial number a nullptr and error is returned.
194 * @param packet_size The packet size to use for communication over ethernet
195 * @return A kea camera
196 */
197inline KeaCamera create_kea_camera_gige(const ProcessingConfig &processing_config, StringView serial, uint16_t packet_size = 1472) {
198 KeaCamera new_kea_camera(static_cast<tof_kea_camera_t>(nullptr));
199 auto ptr = reinterpret_cast<tof_kea_camera_t*>(&new_kea_camera);
200 *ptr = tof_create_kea_camera_gige(*reinterpret_cast<const tof_processing_config_t*>(&processing_config), serial, packet_size, TOF_ERROR_HANDLER{});
201 return new_kea_camera;
202}
203
204} // tof
205} // chronoptics
206
207#endif
This class allows you to view/edit the camera settings.
Simple class containing information about found cameras.
Definition: kea_camera.hpp:131
bool is_tui() const
Check whether this camera is a TUI camera.
Definition: kea_camera.hpp:162
const char * model() const
Get the camera model name.
Definition: kea_camera.hpp:155
const char * info() const
Additional information about the discovered camera.
Definition: kea_camera.hpp:148
const char * serial() const
The serial.
Definition: kea_camera.hpp:141
DiscoveredCamera(tof_discovered_camera_t ptr=nullptr)
Construct from pointer.
Definition: kea_camera.hpp:134
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:105
bool on_camera_processing_capable() const
Check whether this kea camera can do on camera processing.
Definition: kea_camera.hpp:63
KeaCamera(tof_kea_camera_t ptr=nullptr)
Construct from pointer.
Definition: kea_camera.hpp:18
KeaCamera(StringView serial, const ProcessingConfig &processing_config)
Construct the kea camera.
Definition: kea_camera.hpp:45
void set_on_camera_processing(bool on_camera_processing)
Set on camera processing.
Definition: kea_camera.hpp:80
void set_process_config(const ProcessingConfig &config)
the processing config of the camera
Definition: kea_camera.hpp:122
void set_multiple_configurations(const std::vector< CameraConfig > &camera_configs, const std::vector< ProcessingConfig > &pro_configs)
Set multiple configurations.
Definition: kea_camera.hpp:114
bool get_on_camera_processing() const
Get on camera processing.
Definition: kea_camera.hpp:71
void set_configurations(const CameraConfig &camera_config, const ProcessingConfig &processing_config)
Set both the camera and processing config.
Definition: kea_camera.hpp:97
KeaCamera(StringView serial, const ProcessingConfig &processing_config, const CameraConfig &camera_config)
Construct the kea camera with the given processing and camera config.
Definition: kea_camera.hpp:32
void set_camera_config(const CameraConfig &camera_config)
Set the camera config.
Definition: kea_camera.hpp:88
KeaCamera(StringView serial)
Construct the kea camera with a processing config generated by default_processing from the camera con...
Definition: kea_camera.hpp:58
Functions shared across all live cameras.
Definition: camera.hpp:375
Processing that can be done.