Time-of-Flight Library(ToF) 4.0.1
 
csf_camera.hpp
1#ifndef _CHRONOPTICS_TOF_CSF_CAMERA_HPP_
2#define _CHRONOPTICS_TOF_CSF_CAMERA_HPP_
3
4#include <chronoptics/tof/csf_camera.h>
5
6#include <chronoptics/tof/camera.hpp>
7#include <chronoptics/tof/processing_config.hpp>
8#include <chronoptics/tof/data.hpp>
9
10namespace chronoptics {
11namespace tof {
12
13/** The csf camera class contains all the logic to generate a stream of depth
14 * data from a csf file
15*/
16class CsfCamera : public Camera {
17 public:
18 /** Construct from pointer */
19 CsfCamera(tof_csf_camera_t ptr = nullptr) : Camera(reinterpret_cast<tof_camera_t>(ptr)) {}
20
21 /** Construct a csf camera from a csf file
22 * @param file_location File location of the csf file
23 * @param processing_config A processing config
24 */
25 CsfCamera(StringView file_location, const ProcessingConfig &processing_config) : CsfCamera(tof_csf_camera_new(file_location, *reinterpret_cast<const tof_processing_config_t*>(&processing_config), TOF_ERROR_HANDLER{})) {}
26
27 /** Construct a csf camera from a csf file with a processing config generated
28 * by default_processing from the camera config
29 * @param file_location File location of the csf file
30 */
31 CsfCamera(StringView file_location) : CsfCamera(tof_csf_camera_new_simple(file_location, TOF_ERROR_HANDLER{})) {}
32
33 /** Get frames at the specified position
34 * @param frame_nr Which set of frames to process
35 * @return Data frames
36 */
37 std::vector<Data> get_frames_at(size_t frame_nr) {
38 auto this_class = reinterpret_cast<tof_csf_camera_t>(this->ptr_);
39 size_t size = tof_csf_camera_get_frames_at(this_class, frame_nr, nullptr, 0, TOF_ERROR_HANDLER{});
40 std::vector<Data> vec;
41 vec.reserve(size);
42 for (size_t i = 0; i < size; i++)
43 vec.emplace_back(static_cast<tof_data_t>(nullptr));
44 auto data = reinterpret_cast<tof_data_t*>(vec.data());
45 size = tof_csf_camera_get_frames_at(this_class, frame_nr, data, vec.size(), TOF_ERROR_HANDLER{});
46 return vec;
47 }
48
49 /** Get the location (count) of the current frame
50 * @return The currenc frame location
51 */
52 size_t get_current_frame() const {
53 auto this_class = reinterpret_cast<tof_csf_camera_t>(this->ptr_);
54 return tof_csf_camera_get_current_frame(this_class, TOF_ERROR_HANDLER{});
55 }
56
57 /** Get the amount of frame lists this csf file can open/generate
58 * @return The number of frames in the csf file
59 */
60 size_t get_frame_number() const {
61 auto this_class = reinterpret_cast<tof_csf_camera_t>(this->ptr_);
62 return tof_csf_camera_get_frame_number(this_class, TOF_ERROR_HANDLER{});
63 }
64
65 /** Get the FPS If the FPS is greater than 0 the time between subsequent
66 * function calls to get_frames or get_frames_at will be limited to the FPS
67 * This is done by sleeping on the next call to get_frames() if the time
68 * between calls is smaller than the time duration dictated by the fps.
69
70 * @return The frames per second
71 */
72 size_t get_fps() const {
73 auto this_class = reinterpret_cast<tof_csf_camera_t>(this->ptr_);
74 return tof_csf_camera_get_fps(this_class, TOF_ERROR_HANDLER{});
75 }
76
77 /** Set the FPS If the FPS is greater than 0 the time between subsequent
78 * function calls to get_frames or get_frames_at will be limited to the FPS
79 * This is done by sleeping on the next call to get_frames() if the time
80 * between calls is smaller than the time duration dictated by the fps.
81
82 * @param fps The frames per second
83 */
84 void set_fps(size_t fps) {
85 auto this_class = reinterpret_cast<tof_csf_camera_t>(this->ptr_);
86 return tof_csf_camera_set_fps(this_class, fps, TOF_ERROR_HANDLER{});
87 }
88
89 /** the processing config of the camera
90 * @param config The processing config
91 */
93 auto this_class = reinterpret_cast<tof_csf_camera_t>(this->ptr_);
94 return tof_csf_camera_set_process_config(this_class, *reinterpret_cast<const tof_processing_config_t*>(&config), TOF_ERROR_HANDLER{});
95 }
96
97};
98
99} // tof
100} // chronoptics
101
102#endif
The main interface to the depth cameras.
Definition: camera.hpp:17
The csf camera class contains all the logic to generate a stream of depth data from a csf file.
Definition: csf_camera.hpp:16
size_t get_current_frame() const
Get the location (count) of the current frame.
Definition: csf_camera.hpp:52
size_t get_frame_number() const
Get the amount of frame lists this csf file can open/generate.
Definition: csf_camera.hpp:60
size_t get_fps() const
Get the FPS If the FPS is greater than 0 the time between subsequent function calls to get_frames or ...
Definition: csf_camera.hpp:72
CsfCamera(tof_csf_camera_t ptr=nullptr)
Construct from pointer.
Definition: csf_camera.hpp:19
void set_process_config(const ProcessingConfig &config)
the processing config of the camera
Definition: csf_camera.hpp:92
CsfCamera(StringView file_location, const ProcessingConfig &processing_config)
Construct a csf camera from a csf file.
Definition: csf_camera.hpp:25
std::vector< Data > get_frames_at(size_t frame_nr)
Get frames at the specified position.
Definition: csf_camera.hpp:37
void set_fps(size_t fps)
Set the FPS If the FPS is greater than 0 the time between subsequent function calls to get_frames or ...
Definition: csf_camera.hpp:84
CsfCamera(StringView file_location)
Construct a csf camera from a csf file with a processing config generated by default_processing from ...
Definition: csf_camera.hpp:31
Processing that can be done.