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