Time-of-Flight Library(ToF) 4.0.2
 
tui_camera.hpp
1#ifndef _CHRONOPTICS_TOF_TUI_CAMERA_HPP_
2#define _CHRONOPTICS_TOF_TUI_CAMERA_HPP_
3
4#include <chronoptics/tof/tui_camera.h>
5
6#include <chronoptics/tof/camera.hpp>
7#include <chronoptics/tof/camera_config.hpp>
8
9namespace chronoptics {
10namespace tof {
11
12/** The main interface to the tui camera
13*/
14class TuiCamera : public LiveCamera {
15 public:
16 /** Construct from pointer */
17 TuiCamera(tof_tui_camera_t ptr = nullptr) : LiveCamera(reinterpret_cast<tof_live_camera_t>(ptr)) {}
18
19 /** Construct the tui camera
20 * @param serial The serial number of the camera to connect to, if the camera
21 * is available over both usb and gige it will be connected over usb. If an
22 * empty string is supplied the camera will connect to the first usb camera,
23 * if no usb camera is connected it will connect to the first gige camera that
24 * replies (this reply time is random, so you might connect to a different
25 * camera each time if you've got multiple cameras connected to your network).
26 */
27 TuiCamera(StringView serial) : TuiCamera(tof_tui_camera_new(serial, TOF_ERROR_HANDLER{})) {}
28
29 /** Set GPIO mode for a certain pin
30 * @param pin Pin
31 * @param gpio_mode GPIO Mode
32 */
33 void set_gpio_mode(size_t pin, GpioMode gpio_mode) {
34 auto this_class = reinterpret_cast<tof_tui_camera_t>(this->ptr_);
35 return tof_tui_camera_set_gpio_mode(this_class, pin, static_cast<tof_gpio_mode>(gpio_mode), TOF_ERROR_HANDLER{});
36 }
37
38 /** Set trigger mode
39 * @param trigger_mode Trigger mode
40 */
41 void set_trigger_mode(TriggerMode trigger_mode) {
42 auto this_class = reinterpret_cast<tof_tui_camera_t>(this->ptr_);
43 return tof_tui_camera_set_trigger_mode(this_class, static_cast<tof_trigger_mode>(trigger_mode), TOF_ERROR_HANDLER{});
44 }
45
46};
47
48/** Construct a tui camera using the gige interface. This could be useful in two
49 * cases. The first is when the camera is connected with both usb and ethernet
50 * but you want to use ethernet. The second is when for some reason the default
51 * maximum packet size is too large.
52 * @param serial The serial number of the camera to connect to. If an empty
53 * string is supplied the camera will connect to the first gige camera that
54 * replies (this reply time is random, so you might connect to a different
55 * camera each time if you've got multiple cameras connected to your network).
56 * @param packet_size The packet size to use for communication over ethernet
57 * @return A tui camera
58 */
59inline TuiCamera create_tui_camera_gige(StringView serial, uint16_t packet_size = 1472) {
60 TuiCamera new_tui_camera(static_cast<tof_tui_camera_t>(nullptr));
61 auto ptr = reinterpret_cast<tof_tui_camera_t*>(&new_tui_camera);
62 *ptr = tof_create_tui_camera_gige(serial, packet_size, TOF_ERROR_HANDLER{});
63 return new_tui_camera;
64}
65
66} // tof
67} // chronoptics
68
69#endif
Functions shared across all live cameras.
Definition: camera.hpp:375
The main interface to the tui camera.
Definition: tui_camera.hpp:14
void set_trigger_mode(TriggerMode trigger_mode)
Set trigger mode.
Definition: tui_camera.hpp:41
TuiCamera(StringView serial)
Construct the tui camera.
Definition: tui_camera.hpp:27
void set_gpio_mode(size_t pin, GpioMode gpio_mode)
Set GPIO mode for a certain pin.
Definition: tui_camera.hpp:33
TuiCamera(tof_tui_camera_t ptr=nullptr)
Construct from pointer.
Definition: tui_camera.hpp:17