Time-of-Flight Library(ToF) 3.4.0
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 /** Check whether this kea camera can do on camera processing
36 * @return On camera processing capable
37 */
39 auto ptr = reinterpret_cast<tof_kea_camera_t>(this->ptr_);
40 return tof_kea_camera_on_camera_processing_capable(ptr, TOF_ERROR_HANDLER{});
41 }
42
43 /** Get on camera processing
44 * @return True on camera processing, false on host processing
45 */
47 auto ptr = reinterpret_cast<tof_kea_camera_t>(this->ptr_);
48 return tof_kea_camera_get_on_camera_processing(ptr, TOF_ERROR_HANDLER{});
49 }
50
51 /** Set on camera processing
52 * @param on_camera_processing True on camera processing, false on host
53 * processing
54 */
55 void set_on_camera_processing(bool on_camera_processing) {
56 auto ptr = reinterpret_cast<tof_kea_camera_t>(this->ptr_);
57 return tof_kea_camera_set_on_camera_processing(ptr, on_camera_processing, TOF_ERROR_HANDLER{});
58 }
59
60 /** Get delay between network packets
61 * @return The delay, depending on the camera software it is in nanoseconds or
62 * in cpu instruction
63 */
64 uint32_t get_delay() const {
65 auto ptr = reinterpret_cast<tof_kea_camera_t>(this->ptr_);
66 return tof_kea_camera_get_delay(ptr, TOF_ERROR_HANDLER{});
67 }
68
69 /** Set delay between network packets
70 * @param delay The delay, depending on the camera software it is in
71 * nanoseconds or in cpu instruction
72 */
73 void set_delay(uint32_t delay) {
74 auto ptr = reinterpret_cast<tof_kea_camera_t>(this->ptr_);
75 return tof_kea_camera_set_delay(ptr, delay, TOF_ERROR_HANDLER{});
76 }
77
78 /** Get maximum size of each network packet transmitted
79 * @return Packet size in bytes
80 */
81 uint16_t get_packet_size() const {
82 auto ptr = reinterpret_cast<tof_kea_camera_t>(this->ptr_);
83 return tof_kea_camera_get_packet_size(ptr, TOF_ERROR_HANDLER{});
84 }
85
86 /** Set maximum size of each network packet transmitted
87 * @param size Packet size in bytes
88 */
89 void set_packet_size(uint16_t size) {
90 auto ptr = reinterpret_cast<tof_kea_camera_t>(this->ptr_);
91 return tof_kea_camera_set_packet_size(ptr, size, TOF_ERROR_HANDLER{});
92 }
93
94 /** Set the camera config
95 * @param camera_config Camera config
96 */
97 void set_camera_config(const CameraConfig &camera_config) {
98 auto ptr = reinterpret_cast<tof_kea_camera_t>(this->ptr_);
99 return tof_kea_camera_set_camera_config(ptr, *reinterpret_cast<const tof_camera_config_t*>(&camera_config), TOF_ERROR_HANDLER{});
100 }
101
102 /** Set both the camera and processing config
103 * @param camera_config Camera config
104 * @param processing_config Processing config
105 */
106 void set_configurations(const CameraConfig &camera_config, const ProcessingConfig &processing_config) {
107 auto ptr = reinterpret_cast<tof_kea_camera_t>(this->ptr_);
108 return tof_kea_camera_set_configurations(ptr, *reinterpret_cast<const tof_camera_config_t*>(&camera_config), *reinterpret_cast<const tof_processing_config_t*>(&processing_config), TOF_ERROR_HANDLER{});
109 }
110
111 /** Get the tof library version running on the camera
112 * @return Version
113 */
114 const char* version() {
115 auto ptr = reinterpret_cast<tof_kea_camera_t>(this->ptr_);
116 return tof_kea_camera_version(ptr, TOF_ERROR_HANDLER{});
117 }
118
119 /** Check whether the camera is capable of software trigger
120 * @return Software trigger capable
121 */
123 auto ptr = reinterpret_cast<tof_kea_camera_t>(this->ptr_);
124 return tof_kea_camera_software_trigger_capable(ptr, TOF_ERROR_HANDLER{});
125 }
126
127 /** Software trigger the camera
128 */
130 auto ptr = reinterpret_cast<tof_kea_camera_t>(this->ptr_);
131 return tof_kea_camera_software_trigger(ptr, TOF_ERROR_HANDLER{});
132 }
133
134};
135
136/** Simple class containing information about found kea cameras
137*/
138class DiscoveredKea : public detail::Base<tof_discovered_kea, tof_discovered_kea_delete> {
139 public:
140 /** Construct from pointer */
141 DiscoveredKea(tof_discovered_kea_t ptr = nullptr) {
142 this->ptr_ = ptr;
143 }
144
145 /** The serial
146 * @return Serial
147 */
148 const char* serial() const {
149 return tof_discovered_kea_serial(this->ptr_, TOF_ERROR_HANDLER{});
150 }
151
152 /** Additional information about the discovered camera
153 * @return Additional information
154 */
155 const char* info() const {
156 return tof_discovered_kea_info(this->ptr_, TOF_ERROR_HANDLER{});
157 }
158
159};
160
161/** Discover all available kea cameras
162 * @return All available kea cameras
163 */
164inline std::vector<DiscoveredKea> discover_kea_cameras() {
165 size_t size = tof_discover_kea_cameras(nullptr, 0, TOF_ERROR_HANDLER{});
166 std::vector<DiscoveredKea> vec;
167 vec.reserve(size);
168 for (size_t i = 0; i < size; i++)
169 vec.emplace_back(static_cast<tof_discovered_kea_t>(nullptr));
170 auto data = reinterpret_cast<tof_discovered_kea_t*>(vec.data());
171 size = tof_discover_kea_cameras(data, vec.size(), TOF_ERROR_HANDLER{});
172 return vec;
173}
174
175} // tof
176} // chronoptics
177
178#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:138
const char * info() const
Additional information about the discovered camera.
Definition: kea_camera.hpp:155
const char * serial() const
The serial.
Definition: kea_camera.hpp:148
DiscoveredKea(tof_discovered_kea_t ptr=nullptr)
Construct from pointer.
Definition: kea_camera.hpp:141
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:38
KeaCamera(tof_kea_camera_t ptr=nullptr)
Construct from pointer.
Definition: kea_camera.hpp:18
void software_trigger()
Software trigger the camera.
Definition: kea_camera.hpp:129
void set_on_camera_processing(bool on_camera_processing)
Set on camera processing.
Definition: kea_camera.hpp:55
bool software_trigger_capable()
Check whether the camera is capable of software trigger.
Definition: kea_camera.hpp:122
void set_packet_size(uint16_t size)
Set maximum size of each network packet transmitted.
Definition: kea_camera.hpp:89
bool get_on_camera_processing() const
Get on camera processing.
Definition: kea_camera.hpp:46
void set_configurations(const CameraConfig &camera_config, const ProcessingConfig &processing_config)
Set both the camera and processing config.
Definition: kea_camera.hpp:106
uint32_t get_delay() const
Get delay between network packets.
Definition: kea_camera.hpp:64
uint16_t get_packet_size() const
Get maximum size of each network packet transmitted.
Definition: kea_camera.hpp:81
const char * version()
Get the tof library version running on the camera.
Definition: kea_camera.hpp:114
void set_camera_config(const CameraConfig &camera_config)
Set the camera config.
Definition: kea_camera.hpp:97
void set_delay(uint32_t delay)
Set delay between network packets.
Definition: kea_camera.hpp:73
KeaCamera(const ProcessingConfig &processing_config, StringView serial)
Construct the kea camera.
Definition: kea_camera.hpp:31
Processing that can be done.