1#ifndef _CHRONOPTICS_TOF_GIGE_INTERFACE_HPP_
2#define _CHRONOPTICS_TOF_GIGE_INTERFACE_HPP_
4#include <chronoptics/tof/gige_interface.h>
6#include <chronoptics/tof/camera_config.hpp>
7#include <chronoptics/tof/calibration.hpp>
8#include <chronoptics/tof/data.hpp>
10namespace chronoptics {
15enum class DepthStreamType {
24class DiscoveryMessage :
public detail::Base<tof_discovery_message, tof_discovery_message_delete> {
34 const char*
ip()
const {
35 return tof_discovery_message_ip(this->ptr_, TOF_ERROR_HANDLER{});
42 return tof_discovery_message_serial(this->ptr_, TOF_ERROR_HANDLER{});
49class PersistentIp :
public detail::Base<tof_persistent_ip, tof_persistent_ip_delete> {
62 PersistentIp(StringView ip, StringView netmask, StringView gateway,
bool enabled) {
63 this->ptr_ = tof_persistent_ip_new(ip, netmask, gateway, enabled, TOF_ERROR_HANDLER{});
70 return tof_persistent_ip_get_ip(this->ptr_, TOF_ERROR_HANDLER{});
77 return tof_persistent_ip_set_ip(this->ptr_, ip, TOF_ERROR_HANDLER{});
84 return tof_persistent_ip_get_netmask(this->ptr_, TOF_ERROR_HANDLER{});
91 return tof_persistent_ip_set_netmask(this->ptr_, netmask, TOF_ERROR_HANDLER{});
98 return tof_persistent_ip_get_gateway(this->ptr_, TOF_ERROR_HANDLER{});
105 return tof_persistent_ip_set_gateway(this->ptr_, gateway, TOF_ERROR_HANDLER{});
112 return tof_persistent_ip_get_enabled(this->ptr_, TOF_ERROR_HANDLER{});
119 return tof_persistent_ip_set_enabled(this->ptr_, enabled, TOF_ERROR_HANDLER{});
127class GigeInterface :
public detail::Base<tof_gige_interface, tof_gige_interface_delete> {
139 this->ptr_ = tof_gige_interface_new(port, TOF_ERROR_HANDLER{});
146 size_t size = tof_gige_interface_discover(this->ptr_,
nullptr, 0, TOF_ERROR_HANDLER{});
147 std::vector<DiscoveryMessage> vec;
149 for (
size_t i = 0; i < size; i++)
150 vec.emplace_back(
static_cast<tof_discovery_message_t
>(
nullptr));
151 auto data =
reinterpret_cast<tof_discovery_message_t*
>(vec.data());
152 size = tof_gige_interface_discover(this->ptr_, data, vec.size(), TOF_ERROR_HANDLER{});
160 DiscoveryMessage new_discovery_message(
static_cast<tof_discovery_message_t
>(
nullptr));
161 auto ptr =
reinterpret_cast<tof_discovery_message_t*
>(&new_discovery_message);
162 *ptr = tof_gige_interface_discover_one(this->ptr_, TOF_ERROR_HANDLER{});
163 return new_discovery_message;
172 DiscoveryMessage new_discovery_message(
static_cast<tof_discovery_message_t
>(
nullptr));
173 auto ptr =
reinterpret_cast<tof_discovery_message_t*
>(&new_discovery_message);
174 *ptr = tof_gige_interface_find(this->ptr_, serial, TOF_ERROR_HANDLER{});
175 return new_discovery_message;
182 return tof_gige_interface_connect(this->ptr_, *
reinterpret_cast<const tof_discovery_message_t*
>(&message), TOF_ERROR_HANDLER{});
188 return tof_gige_interface_disconnect(this->ptr_, TOF_ERROR_HANDLER{});
195 return tof_gige_interface_is_connected(this->ptr_, TOF_ERROR_HANDLER{});
202 return tof_gige_interface_get_stream_packet_size(this->ptr_, TOF_ERROR_HANDLER{});
209 return tof_gige_interface_set_stream_packet_size(this->ptr_, packet_size, TOF_ERROR_HANDLER{});
217 return tof_gige_interface_test_stream_packet_size(this->ptr_, port, TOF_ERROR_HANDLER{});
225 return tof_gige_interface_get_delay(this->ptr_, TOF_ERROR_HANDLER{});
233 return tof_gige_interface_set_delay(this->ptr_, delay, TOF_ERROR_HANDLER{});
241 CameraConfig new_camera_config(
static_cast<tof_camera_config_t
>(
nullptr));
242 auto ptr =
reinterpret_cast<tof_camera_config_t*
>(&new_camera_config);
243 *ptr = tof_gige_interface_download_configuration(this->ptr_, port, TOF_ERROR_HANDLER{});
244 return new_camera_config;
252 Calibration new_calibration(
static_cast<tof_calibration_t
>(
nullptr));
253 auto ptr =
reinterpret_cast<tof_calibration_t*
>(&new_calibration);
254 *ptr = tof_gige_interface_download_calibration(this->ptr_, port, TOF_ERROR_HANDLER{});
255 return new_calibration;
263 return tof_gige_interface_upload_configuration(this->ptr_, *
reinterpret_cast<const tof_camera_config_t*
>(&config), port, TOF_ERROR_HANDLER{});
271 return tof_gige_interface_depth_stream_capable(this->ptr_,
static_cast<tof_depth_stream_type
>(stream), TOF_ERROR_HANDLER{});
279 return tof_gige_interface_start_depth_stream(this->ptr_,
static_cast<tof_depth_stream_type
>(stream), port, TOF_ERROR_HANDLER{});
285 return tof_gige_interface_stop_depth_stream(this->ptr_, TOF_ERROR_HANDLER{});
292 return tof_gige_interface_has_depth_data(this->ptr_, TOF_ERROR_HANDLER{});
299 Data new_data(
static_cast<tof_data_t
>(
nullptr));
300 auto ptr =
reinterpret_cast<tof_data_t*
>(&new_data);
301 *ptr = tof_gige_interface_get_depth_data(this->ptr_, TOF_ERROR_HANDLER{});
309 return tof_gige_interface_image_stream_capable(this->ptr_, TOF_ERROR_HANDLER{});
316 return tof_gige_interface_start_image_stream(this->ptr_, port, TOF_ERROR_HANDLER{});
322 return tof_gige_interface_stop_image_stream(this->ptr_, TOF_ERROR_HANDLER{});
329 return tof_gige_interface_has_image_data(this->ptr_, TOF_ERROR_HANDLER{});
336 Data new_data(
static_cast<tof_data_t
>(
nullptr));
337 auto ptr =
reinterpret_cast<tof_data_t*
>(&new_data);
338 *ptr = tof_gige_interface_get_image_data(this->ptr_, TOF_ERROR_HANDLER{});
350 Data new_data(
static_cast<tof_data_t
>(
nullptr));
351 auto ptr =
reinterpret_cast<tof_data_t*
>(&new_data);
352 *ptr = tof_gige_interface_get_image_data_into_pointer(this->ptr_, pointer, capacity, user_pointer_destructed_cb_handler, &callback, TOF_ERROR_HANDLER{});
365 Data new_data(
static_cast<tof_data_t
>(
nullptr));
366 auto ptr =
reinterpret_cast<tof_data_t*
>(&new_data);
367 *ptr = tof_gige_interface_get_image_data_into_pointer(this->ptr_, pointer, capacity, callback, callback_user_data, TOF_ERROR_HANDLER{});
375 return tof_gige_interface_persistent_ip_capable(this->ptr_, TOF_ERROR_HANDLER{});
382 PersistentIp new_persistent_ip(
static_cast<tof_persistent_ip_t
>(
nullptr));
383 auto ptr =
reinterpret_cast<tof_persistent_ip_t*
>(&new_persistent_ip);
384 *ptr = tof_gige_interface_get_persistent_ip(this->ptr_, TOF_ERROR_HANDLER{});
385 return new_persistent_ip;
393 return tof_gige_interface_set_persistent_ip(this->ptr_, *
reinterpret_cast<const tof_persistent_ip_t*
>(&persistent_ip), TOF_ERROR_HANDLER{});
400 return tof_gige_interface_get_user_pointer_capacity(this->ptr_, TOF_ERROR_HANDLER{});
407 return tof_gige_interface_set_user_pointer_capacity(this->ptr_, capacity, TOF_ERROR_HANDLER{});
419 return tof_gige_interface_add_depth_user_pointer(this->ptr_, pointer, capacity, user_pointer_destructed_cb_handler, &callback, TOF_ERROR_HANDLER{});
431 void add_depth_user_pointer(uint8_t* pointer,
size_t capacity, tof_user_pointer_destructed_t callback,
void* callback_user_data) {
432 return tof_gige_interface_add_depth_user_pointer(this->ptr_, pointer, capacity, callback, callback_user_data, TOF_ERROR_HANDLER{});
439 return tof_gige_interface_version(this->ptr_, TOF_ERROR_HANDLER{});
446 return tof_gige_interface_software_trigger_capable(this->ptr_, TOF_ERROR_HANDLER{});
452 return tof_gige_interface_software_trigger(this->ptr_, TOF_ERROR_HANDLER{});
This class contains all the calibration information.
This class allows you to view/edit the camera settings.
This is the class that contains depth or image data.
A gige discovery message containing camera information.
const char * ip() const
Get the camera's ip address.
const char * serial() const
Get the camera's serial.
DiscoveryMessage(tof_discovery_message_t ptr=nullptr)
Construct from pointer.
DEPRECATED, use KeaCamera.
DiscoveryMessage discover_one()
Returns a message of the first camera that responded.
bool depth_stream_capable(DepthStreamType stream) const
Check whether this camera is capable of streaming the specified type.
CameraConfig download_configuration(uint16_t port=0)
Download camera configuration from the camera.
std::vector< DiscoveryMessage > discover()
Detect all the cameras on the network.
void disconnect()
Disconnect from the camera.
void set_stream_packet_size(uint16_t packet_size)
Set stream packet size.
void start_image_stream(uint16_t port=0)
Start image stream.
void stop_depth_stream()
Stop the depth stream.
GigeInterface(tof_gige_interface_t ptr)
Construct from pointer.
void add_depth_user_pointer(uint8_t *pointer, size_t capacity, tof_user_pointer_destructed_t callback, void *callback_user_data)
Add a pointer that will be filled with depth data.
GigeInterface(uint16_t port=0)
Create an instance of the gige interface.
bool image_stream_capable() const
Check whether camera supports an image stream.
void connect(const DiscoveryMessage &message)
Connect to the camera and gain exclusive access.
Data get_image_data()
Get image frame.
bool persistent_ip_capable() const
Get whether the camera is persistent ip capable.
Calibration download_calibration(uint16_t port=0)
Download calibration from the camera.
uint32_t get_delay() const
Get delay between network packets.
size_t get_user_pointer_capacity() const
Get the capacity for amount of user pointers that can be registered.
Data get_depth_data()
Get a depth frame.
void start_depth_stream(DepthStreamType stream, uint16_t port=0)
Start the depth stream.
bool has_depth_data() const
Returns true if a depth frame is available.
bool software_trigger_capable()
Check whether the camera is capable of software trigger.
uint16_t get_stream_packet_size() const
Get stream packet size.
bool test_stream_packet_size(uint16_t port=0)
Test whether using the set packet size works.
void set_user_pointer_capacity(size_t capacity)
Set the capacity for amount of user pointers that can be registered.
void set_persistent_ip(const PersistentIp &persistent_ip)
Set the persistent ip settings.
const char * version()
Get the tof library version running on the camera.
void add_depth_user_pointer(uint8_t *pointer, size_t capacity, user_pointer_destructed_fn &callback)
Add a pointer that will be filled with depth data.
Data get_image_data_into_pointer(uint8_t *pointer, size_t capacity, tof_user_pointer_destructed_t callback, void *callback_user_data)
Get the image frame into the supplied pointer.
void upload_configuration(const CameraConfig &config, uint16_t port=0)
Upload camera configuration to the camera.
void software_trigger()
Software trigger the camera.
void set_delay(uint32_t delay)
Set delay between network packets.
PersistentIp get_persistent_ip() const
Get the current persistent ip settings.
bool has_image_data() const
Check whether image frame is available.
void stop_image_stream()
Stop image stream.
DiscoveryMessage find(StringView serial)
Detect a specific camera on the network, will throw an error if it can't find the camera.
bool is_connected() const
Check whether a connection is still maintained with the camera.
Data get_image_data_into_pointer(uint8_t *pointer, size_t capacity, user_pointer_destructed_fn &callback)
Get the image frame into the supplied pointer.
A persistent ip data structure.
void set_gateway(StringView gateway)
Set the gateway.
bool get_enabled() const
Get if persistent ip is enabled.
void set_enabled(bool enabled)
Set if persistent ip is enabled.
const char * get_ip() const
Get the IP address.
void set_netmask(StringView netmask)
Set the netmask.
const char * get_netmask() const
Get the netmask.
PersistentIp(tof_persistent_ip_t ptr=nullptr)
Construct from pointer.
void set_ip(StringView ip)
Set the IP address.
PersistentIp(StringView ip, StringView netmask, StringView gateway, bool enabled)
Create persistent ip.
const char * get_gateway() const
Get the gateway.