1#ifndef _CHRONOPTICS_TOF_CAMERA_HPP_
2#define _CHRONOPTICS_TOF_CAMERA_HPP_
4#include <chronoptics/tof/camera.h>
6#include <chronoptics/tof/stream.hpp>
7#include <chronoptics/tof/processing_config.hpp>
8#include <chronoptics/tof/data.hpp>
9#include <chronoptics/tof/camera_config.hpp>
10#include <chronoptics/tof/calibration.hpp>
12namespace chronoptics {
17class Camera :
public detail::Base<tof_camera, tof_camera_delete> {
27 return tof_camera_start(this->ptr_, TOF_ERROR_HANDLER{});
33 return tof_camera_stop(this->ptr_, TOF_ERROR_HANDLER{});
40 return tof_camera_is_streaming(this->ptr_, TOF_ERROR_HANDLER{});
47 return tof_camera_is_connected(this->ptr_, TOF_ERROR_HANDLER{});
54 size_t size = tof_camera_get_stream_list(this->ptr_,
nullptr, 0, TOF_ERROR_HANDLER{});
55 std::vector<Stream> vec;
57 for (
size_t i = 0; i < size; i++)
58 vec.emplace_back(
static_cast<tof_stream_t
>(
nullptr));
59 auto data =
reinterpret_cast<tof_stream_t*
>(vec.data());
60 size = tof_camera_get_stream_list(this->ptr_, data, vec.size(), TOF_ERROR_HANDLER{});
68 ProcessingConfig new_processing_config(
static_cast<tof_processing_config_t
>(
nullptr));
69 auto ptr =
reinterpret_cast<tof_processing_config_t*
>(&new_processing_config);
70 *ptr = tof_camera_get_process_config(this->ptr_, TOF_ERROR_HANDLER{});
71 return new_processing_config;
78 return tof_camera_has_frames(this->ptr_, TOF_ERROR_HANDLER{});
85 size_t size = tof_camera_get_frames(this->ptr_,
nullptr, 0, TOF_ERROR_HANDLER{});
86 std::vector<Data> vec;
88 for (
size_t i = 0; i < size; i++)
89 vec.emplace_back(
static_cast<tof_data_t
>(
nullptr));
90 auto data =
reinterpret_cast<tof_data_t*
>(vec.data());
91 size = tof_camera_get_frames(this->ptr_, data, vec.size(), TOF_ERROR_HANDLER{});
98 return tof_camera_clear_buffer(this->ptr_, TOF_ERROR_HANDLER{});
106 return tof_camera_get_buffer_size(this->ptr_, TOF_ERROR_HANDLER{});
114 return tof_camera_set_buffer_size(this->ptr_, size, TOF_ERROR_HANDLER{});
121 CameraConfig new_camera_config(
static_cast<tof_camera_config_t
>(
nullptr));
122 auto ptr =
reinterpret_cast<tof_camera_config_t*
>(&new_camera_config);
123 *ptr = tof_camera_get_camera_config(this->ptr_, TOF_ERROR_HANDLER{});
124 return new_camera_config;
131 return tof_camera_get_serial(this->ptr_, TOF_ERROR_HANDLER{});
138 Calibration new_calibration(
static_cast<tof_calibration_t
>(
nullptr));
139 auto ptr =
reinterpret_cast<tof_calibration_t*
>(&new_calibration);
140 *ptr = tof_camera_get_calibration(this->ptr_, TOF_ERROR_HANDLER{});
141 return new_calibration;
148 return tof_camera_get_user_pointer_capacity(this->ptr_, TOF_ERROR_HANDLER{});
155 return tof_camera_set_user_pointer_capacity(this->ptr_, capacity, TOF_ERROR_HANDLER{});
167 void add_user_pointer(uint8_t* pointer,
size_t capacity, user_pointer_destructed_fn &callback, FrameType frame_type) {
168 return tof_camera_add_user_pointer(this->ptr_, pointer, capacity, user_pointer_destructed_cb_handler, &callback,
static_cast<tof_frame_type
>(frame_type), TOF_ERROR_HANDLER{});
181 void add_user_pointer(uint8_t* pointer,
size_t capacity, tof_user_pointer_destructed_t callback,
void* callback_user_data, FrameType frame_type) {
182 return tof_camera_add_user_pointer(this->ptr_, pointer, capacity, callback, callback_user_data,
static_cast<tof_frame_type
>(frame_type), TOF_ERROR_HANDLER{});
188 return tof_camera_clear_user_pointers(this->ptr_, TOF_ERROR_HANDLER{});
195 return tof_camera_config_index(this->ptr_, TOF_ERROR_HANDLER{});
203 return tof_camera_switch_config(this->ptr_,
config_index, TOF_ERROR_HANDLER{});
210 size_t size = tof_camera_possible_frame_types(this->ptr_,
nullptr, 0, TOF_ERROR_HANDLER{});
211 std::vector<FrameType> vec(size);
212 size = tof_camera_possible_frame_types(this->ptr_,
reinterpret_cast<tof_frame_type*
>(vec.data()), vec.size(), TOF_ERROR_HANDLER{});
220 return tof_camera_output_frame_types_set(this->ptr_, TOF_ERROR_HANDLER{});
227 size_t size = tof_camera_get_output_frame_types(this->ptr_,
nullptr, 0, TOF_ERROR_HANDLER{});
228 std::vector<FrameType> vec(size);
229 size = tof_camera_get_output_frame_types(this->ptr_,
reinterpret_cast<tof_frame_type*
>(vec.data()), vec.size(), TOF_ERROR_HANDLER{});
237 return tof_camera_set_output_frame_types(this->ptr_,
reinterpret_cast<const tof_frame_type*
>(output_frame_types.data()), output_frame_types.size(), TOF_ERROR_HANDLER{});
245 return tof_camera_has_multiple_configurations(this->ptr_, TOF_ERROR_HANDLER{});
252 size_t size = tof_camera_get_multiple_camera_configurations(this->ptr_,
nullptr, 0, TOF_ERROR_HANDLER{});
253 std::vector<CameraConfig> vec;
255 for (
size_t i = 0; i < size; i++)
256 vec.emplace_back(
static_cast<tof_camera_config_t
>(
nullptr));
257 auto data =
reinterpret_cast<tof_camera_config_t*
>(vec.data());
258 size = tof_camera_get_multiple_camera_configurations(this->ptr_, data, vec.size(), TOF_ERROR_HANDLER{});
266 size_t size = tof_camera_get_multiple_processing_configurations(this->ptr_,
nullptr, 0, TOF_ERROR_HANDLER{});
267 std::vector<ProcessingConfig> vec;
269 for (
size_t i = 0; i < size; i++)
270 vec.emplace_back(
static_cast<tof_processing_config_t
>(
nullptr));
271 auto data =
reinterpret_cast<tof_processing_config_t*
>(vec.data());
272 size = tof_camera_get_multiple_processing_configurations(this->ptr_, data, vec.size(), TOF_ERROR_HANDLER{});
280 size_t size = tof_camera_get_multiple_names(this->ptr_,
nullptr, 0, TOF_ERROR_HANDLER{});
281 std::vector<const char*> vec(size);
282 size = tof_camera_get_multiple_names(this->ptr_, vec.data(), vec.size(), TOF_ERROR_HANDLER{});
290 size_t size = tof_camera_get_multiple_descriptions(this->ptr_,
nullptr, 0, TOF_ERROR_HANDLER{});
291 std::vector<const char*> vec(size);
292 size = tof_camera_get_multiple_descriptions(this->ptr_, vec.data(), vec.size(), TOF_ERROR_HANDLER{});
300class PersistentIp :
public detail::Base<tof_persistent_ip, tof_persistent_ip_delete> {
313 PersistentIp(StringView ip, StringView netmask, StringView gateway,
bool enabled) :
PersistentIp(tof_persistent_ip_new(ip, netmask, gateway, enabled, TOF_ERROR_HANDLER{})) {}
319 return tof_persistent_ip_get_ip(this->ptr_, TOF_ERROR_HANDLER{});
326 return tof_persistent_ip_set_ip(this->ptr_, ip, TOF_ERROR_HANDLER{});
333 return tof_persistent_ip_get_netmask(this->ptr_, TOF_ERROR_HANDLER{});
340 return tof_persistent_ip_set_netmask(this->ptr_, netmask, TOF_ERROR_HANDLER{});
347 return tof_persistent_ip_get_gateway(this->ptr_, TOF_ERROR_HANDLER{});
354 return tof_persistent_ip_set_gateway(this->ptr_, gateway, TOF_ERROR_HANDLER{});
361 return tof_persistent_ip_get_enabled(this->ptr_, TOF_ERROR_HANDLER{});
368 return tof_persistent_ip_set_enabled(this->ptr_, enabled, TOF_ERROR_HANDLER{});
378 LiveCamera(tof_live_camera_t ptr =
nullptr) :
Camera(reinterpret_cast<tof_camera_t>(ptr)) {}
384 auto this_class =
reinterpret_cast<tof_live_camera_t
>(this->ptr_);
385 return tof_live_camera_version(this_class, TOF_ERROR_HANDLER{});
392 auto this_class =
reinterpret_cast<tof_live_camera_t
>(this->ptr_);
393 return tof_live_camera_remote_update_capable(this_class, TOF_ERROR_HANDLER{});
404 auto this_class =
reinterpret_cast<tof_live_camera_t
>(this->ptr_);
405 return tof_live_camera_remote_update(this_class, file_location, TOF_ERROR_HANDLER{});
412 auto this_class =
reinterpret_cast<tof_live_camera_t
>(this->ptr_);
413 return tof_live_camera_persistent_ip_capable(this_class, TOF_ERROR_HANDLER{});
420 auto this_class =
reinterpret_cast<tof_live_camera_t
>(this->ptr_);
421 PersistentIp new_persistent_ip(
static_cast<tof_persistent_ip_t
>(
nullptr));
422 auto ptr =
reinterpret_cast<tof_persistent_ip_t*
>(&new_persistent_ip);
423 *ptr = tof_live_camera_get_persistent_ip(this_class, TOF_ERROR_HANDLER{});
424 return new_persistent_ip;
432 auto this_class =
reinterpret_cast<tof_live_camera_t
>(this->ptr_);
433 return tof_live_camera_set_persistent_ip(this_class, *
reinterpret_cast<const tof_persistent_ip_t*
>(&persistent_ip), TOF_ERROR_HANDLER{});
440 auto this_class =
reinterpret_cast<tof_live_camera_t
>(this->ptr_);
441 return tof_live_camera_apply_persistent_ip_capable(this_class, TOF_ERROR_HANDLER{});
448 auto this_class =
reinterpret_cast<tof_live_camera_t
>(this->ptr_);
449 return tof_live_camera_apply_persistent_ip(this_class, TOF_ERROR_HANDLER{});
456 auto this_class =
reinterpret_cast<tof_live_camera_t
>(this->ptr_);
457 return tof_live_camera_software_trigger_capable(this_class, TOF_ERROR_HANDLER{});
463 auto this_class =
reinterpret_cast<tof_live_camera_t
>(this->ptr_);
464 return tof_live_camera_software_trigger(this_class, TOF_ERROR_HANDLER{});
472 auto this_class =
reinterpret_cast<tof_live_camera_t
>(this->ptr_);
473 return tof_live_camera_get_delay(this_class, TOF_ERROR_HANDLER{});
481 auto this_class =
reinterpret_cast<tof_live_camera_t
>(this->ptr_);
482 return tof_live_camera_set_delay(this_class, delay, TOF_ERROR_HANDLER{});
489 auto this_class =
reinterpret_cast<tof_live_camera_t
>(this->ptr_);
490 return tof_live_camera_get_packet_size(this_class, TOF_ERROR_HANDLER{});
497 auto this_class =
reinterpret_cast<tof_live_camera_t
>(this->ptr_);
498 return tof_live_camera_set_packet_size(this_class, size, TOF_ERROR_HANDLER{});
505 auto this_class =
reinterpret_cast<tof_live_camera_t
>(this->ptr_);
506 return tof_live_camera_get_temperatures_capable(this_class, TOF_ERROR_HANDLER{});
513 auto this_class =
reinterpret_cast<tof_live_camera_t
>(this->ptr_);
514 size_t size = tof_live_camera_get_temperatures(this_class,
nullptr, 0, TOF_ERROR_HANDLER{});
515 std::vector<float> vec(size);
516 size = tof_live_camera_get_temperatures(this_class, vec.data(), vec.size(), TOF_ERROR_HANDLER{});
525 auto this_class =
reinterpret_cast<tof_live_camera_t
>(this->ptr_);
526 return tof_live_camera_get_gpio(this_class, pin, TOF_ERROR_HANDLER{});
534 auto this_class =
reinterpret_cast<tof_live_camera_t
>(this->ptr_);
535 return tof_live_camera_set_gpio(this_class, pin, level, TOF_ERROR_HANDLER{});
This class contains all the calibration information.
This class allows you to view/edit the camera settings.
The main interface to the depth cameras.
const char * get_serial() const
Get the serial number of the current camera.
bool is_streaming() const
Check whether the camera is streaming.
bool is_connected() const
Check whether the camera is still connected.
void clear_buffer()
Clear the circular buffer used to store frames.
void stop()
Stop streaming of the camera.
void set_user_pointer_capacity(size_t capacity)
Set the amount of user pointers that can be stored.
std::vector< Stream > get_stream_list() const
Get the different output streams the camera can provide.
std::vector< FrameType > possible_frame_types() const
Get the frame types that this camera can output.
std::vector< CameraConfig > get_multiple_camera_configurations() const
Get all the set camera configurations.
CameraConfig get_camera_config() const
Get the currently active camera config.
bool output_frame_types_set()
Whether output frame types have been set.
void clear_user_pointers()
Clear all user pointers in memory.
std::vector< const char * > get_multiple_descriptions() const
Get the description for each configuration.
std::vector< FrameType > get_output_frame_types() const
Get the frame types the camera should output.
Camera(tof_camera_t ptr=nullptr)
Construct from pointer.
void add_user_pointer(uint8_t *pointer, size_t capacity, tof_user_pointer_destructed_t callback, void *callback_user_data, FrameType frame_type)
Add a pointer that will be filled with the specified data type.
size_t get_user_pointer_capacity() const
Get the amount of user pointers that can be stored.
void set_output_frame_types(const std::vector< FrameType > &output_frame_types)
Set the frame types the camera should output.
ProcessingConfig get_process_config() const
the processing config of the camera
bool has_frames() const
Check if the camera has frames available.
uint32_t config_index() const
Get the currently set configuration index.
size_t get_buffer_size() const
Get the circular buffer size.
std::vector< const char * > get_multiple_names() const
Get the name for each configuration.
void set_buffer_size(size_t size)
Set the circular buffer size.
void add_user_pointer(uint8_t *pointer, size_t capacity, user_pointer_destructed_fn &callback, FrameType frame_type)
Add a pointer that will be filled with the specified data type.
std::vector< ProcessingConfig > get_multiple_processing_configurations() const
Get all the set processing configurations.
Calibration get_calibration() const
Get calibration from the camera.
void switch_config(uint32_t config_index)
Switch to a different config in real time, depending on configuration and camera, this can take 100-3...
std::vector< Data > get_frames()
Get data frames from camera.
void start()
Start streaming of the camera.
bool has_multiple_configurations() const
Check if multiple configurations are set.
Functions shared across all live cameras.
const char * version()
Get the tof library version running on the camera.
void set_persistent_ip(const PersistentIp &persistent_ip)
Set the persistent ip settings.
uint32_t get_delay() const
Get delay between network packets.
void set_delay(uint32_t delay)
Set delay between network packets.
void apply_persistent_ip()
Apply persistent ip by rebooting the camera, power cycling the camera is discouraged because the appl...
void set_packet_size(uint16_t size)
Set maximum size of each network packet transmitted.
std::vector< float > get_temperatures()
Get the current on camera temperatures.
bool get_temperatures_capable()
Whether the camera is capable of returning temperatures.
void remote_update(StringView file_location)
Update the camera remotely.
void set_gpio(size_t pin, bool level)
Set voltage level on given pin.
void software_trigger()
Software trigger the camera.
uint16_t get_packet_size() const
Get maximum size of each network packet transmitted.
bool apply_persistent_ip_capable() const
Whether the camera is capable of applying the persistent ip.
PersistentIp get_persistent_ip()
Get the current persistent ip settings.
bool remote_update_capable()
Check whether the camera is capable of updating remotely.
bool software_trigger_capable()
Check whether the camera is capable of software trigger.
LiveCamera(tof_live_camera_t ptr=nullptr)
Construct from pointer.
bool get_gpio(size_t pin)
Get voltage level on given pin.
bool persistent_ip_capable() const
Whether the camera is capable of setting persistent ip.
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.
Processing that can be done.