1#ifndef _CHRONOPTICS_TOF_USB_INTERFACE_HPP_
2#define _CHRONOPTICS_TOF_USB_INTERFACE_HPP_
4#include <chronoptics/tof/usb_interface.h>
6#include <chronoptics/tof/camera_config.hpp>
7#include <chronoptics/tof/calibration.hpp>
8#include <chronoptics/tof/data.hpp>
9#include <chronoptics/tof/gige_interface.hpp>
11namespace chronoptics {
16class UsbDevice :
public detail::Base<tof_usb_device, tof_usb_device_delete> {
27 return tof_usb_device_serial(this->ptr_, TOF_ERROR_HANDLER{});
35class UsbInterface :
public detail::Base<tof_usb_interface, tof_usb_interface_delete> {
46 this->ptr_ = tof_usb_interface_new(*
reinterpret_cast<tof_usb_device_t*
>(&usb_device), TOF_ERROR_HANDLER{});
53 return tof_usb_interface_is_connected(this->ptr_, TOF_ERROR_HANDLER{});
62 return tof_usb_interface_test_stream_speed(this->ptr_, TOF_ERROR_HANDLER{});
69 CameraConfig new_camera_config(
static_cast<tof_camera_config_t
>(
nullptr));
70 auto ptr =
reinterpret_cast<tof_camera_config_t*
>(&new_camera_config);
71 *ptr = tof_usb_interface_download_configuration(this->ptr_, TOF_ERROR_HANDLER{});
72 return new_camera_config;
79 Calibration new_calibration(
static_cast<tof_calibration_t
>(
nullptr));
80 auto ptr =
reinterpret_cast<tof_calibration_t*
>(&new_calibration);
81 *ptr = tof_usb_interface_download_calibration(this->ptr_, TOF_ERROR_HANDLER{});
82 return new_calibration;
89 return tof_usb_interface_upload_configuration(this->ptr_, *
reinterpret_cast<const tof_camera_config_t*
>(&config), TOF_ERROR_HANDLER{});
97 return tof_usb_interface_depth_stream_capable(this->ptr_,
static_cast<tof_depth_stream_type
>(stream), TOF_ERROR_HANDLER{});
104 return tof_usb_interface_start_depth_stream(this->ptr_,
static_cast<tof_depth_stream_type
>(stream), TOF_ERROR_HANDLER{});
110 return tof_usb_interface_stop_depth_stream(this->ptr_, TOF_ERROR_HANDLER{});
117 return tof_usb_interface_has_depth_data(this->ptr_, TOF_ERROR_HANDLER{});
124 Data new_data(
static_cast<tof_data_t
>(
nullptr));
125 auto ptr =
reinterpret_cast<tof_data_t*
>(&new_data);
126 *ptr = tof_usb_interface_get_depth_data(this->ptr_, TOF_ERROR_HANDLER{});
134 return tof_usb_interface_image_stream_capable(this->ptr_, TOF_ERROR_HANDLER{});
140 return tof_usb_interface_start_image_stream(this->ptr_, TOF_ERROR_HANDLER{});
146 return tof_usb_interface_stop_image_stream(this->ptr_, TOF_ERROR_HANDLER{});
153 return tof_usb_interface_has_image_data(this->ptr_, TOF_ERROR_HANDLER{});
160 Data new_data(
static_cast<tof_data_t
>(
nullptr));
161 auto ptr =
reinterpret_cast<tof_data_t*
>(&new_data);
162 *ptr = tof_usb_interface_get_image_data(this->ptr_, TOF_ERROR_HANDLER{});
174 Data new_data(
static_cast<tof_data_t
>(
nullptr));
175 auto ptr =
reinterpret_cast<tof_data_t*
>(&new_data);
176 *ptr = tof_usb_interface_get_image_data_into_pointer(this->ptr_, pointer, capacity, user_pointer_destructed_cb_handler, &callback, TOF_ERROR_HANDLER{});
189 Data new_data(
static_cast<tof_data_t
>(
nullptr));
190 auto ptr =
reinterpret_cast<tof_data_t*
>(&new_data);
191 *ptr = tof_usb_interface_get_image_data_into_pointer(this->ptr_, pointer, capacity, callback, callback_user_data, TOF_ERROR_HANDLER{});
199 return tof_usb_interface_get_user_pointer_capacity(this->ptr_, TOF_ERROR_HANDLER{});
206 return tof_usb_interface_set_user_pointer_capacity(this->ptr_, capacity, TOF_ERROR_HANDLER{});
218 return tof_usb_interface_add_depth_user_pointer(this->ptr_, pointer, capacity, user_pointer_destructed_cb_handler, &callback, TOF_ERROR_HANDLER{});
230 void add_depth_user_pointer(uint8_t* pointer,
size_t capacity, tof_user_pointer_destructed_t callback,
void* callback_user_data) {
231 return tof_usb_interface_add_depth_user_pointer(this->ptr_, pointer, capacity, callback, callback_user_data, TOF_ERROR_HANDLER{});
238 return tof_usb_interface_version(this->ptr_, TOF_ERROR_HANDLER{});
245 return tof_usb_interface_software_trigger_capable(this->ptr_, TOF_ERROR_HANDLER{});
251 return tof_usb_interface_software_trigger(this->ptr_, TOF_ERROR_HANDLER{});
259inline std::vector<UsbDevice> usb_device_discover() {
260 size_t size = tof_usb_device_discover(
nullptr, 0, TOF_ERROR_HANDLER{});
261 std::vector<UsbDevice> vec;
263 for (
size_t i = 0; i < size; i++)
264 vec.emplace_back(
static_cast<tof_usb_device_t
>(
nullptr));
265 auto data =
reinterpret_cast<tof_usb_device_t*
>(vec.data());
266 size = tof_usb_device_discover(data, vec.size(), TOF_ERROR_HANDLER{});
273inline UsbDevice usb_device_discover_one() {
274 UsbDevice new_usb_device(
static_cast<tof_usb_device_t
>(
nullptr));
275 auto ptr =
reinterpret_cast<tof_usb_device_t*
>(&new_usb_device);
276 *ptr = tof_usb_device_discover_one(TOF_ERROR_HANDLER{});
277 return new_usb_device;
284inline UsbDevice usb_device_find(StringView serial) {
285 UsbDevice new_usb_device(
static_cast<tof_usb_device_t
>(
nullptr));
286 auto ptr =
reinterpret_cast<tof_usb_device_t*
>(&new_usb_device);
287 *ptr = tof_usb_device_find(serial, TOF_ERROR_HANDLER{});
288 return new_usb_device;
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.
UsbDevice(tof_usb_device_t ptr=nullptr)
Construct from pointer.
const char * serial()
Get serial corresponding with USB device.
DEPRECATED, use KeaCamera.
bool depth_stream_capable(DepthStreamType stream) const
Check whether this camera is capable of streaming the specified type.
bool is_connected() const
Check whether a connection is still maintained with the camera.
void software_trigger()
Software trigger the camera.
bool image_stream_capable() const
Check whether camera supports an image stream.
void stop_image_stream()
Stop image stream.
UsbInterface(UsbDevice &usb_device)
Create USB camera from a usb device.
void set_user_pointer_capacity(size_t capacity)
Set the capacity for amount of user pointers that can be registered.
double test_stream_speed()
Tests the connection speed of the USB port.
void start_depth_stream(DepthStreamType stream)
Start the depth stream.
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.
bool has_depth_data() const
Returns true if a depth frame is available.
void stop_depth_stream()
Stop the depth stream.
Data get_image_data()
Get image frame.
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.
void start_image_stream()
Start image stream.
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.
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.
size_t get_user_pointer_capacity() const
Get the capacity for amount of user pointers that can be registered.
UsbInterface(tof_usb_interface_t ptr=nullptr)
Construct from pointer.
const char * version()
Get the tof library version running on the camera.
Calibration download_calibration()
Download calibration from the camera.
Data get_depth_data()
Get a depth frame.
bool software_trigger_capable()
Check whether the camera is capable of software trigger.
bool has_image_data() const
Check whether image frame is available.
CameraConfig download_configuration()
Download camera configuration from the camera.
void upload_configuration(const CameraConfig &config)
Upload camera configuration to the camera.