Time-of-Flight Library(ToF)  3.2.4
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 
10 namespace chronoptics {
11 namespace tof {
12 
13 /** The csf camera class contains all the logic to generate a stream of depth
14  * data from a csf file
15 */
16 class 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  /** Get frames at the specified position
30  * @param frame_nr Which set of frames to process
31  * @return Data frames
32  */
33  std::vector<Data> get_frames_at(size_t frame_nr) {
34  auto ptr = reinterpret_cast<tof_csf_camera_t>(this->ptr_);
35  size_t size = tof_csf_camera_get_frames_at(ptr, frame_nr, nullptr, 0, TOF_ERROR_HANDLER{});
36  std::vector<Data> vec;
37  vec.reserve(size);
38  for (size_t i = 0; i < size; i++)
39  vec.emplace_back(static_cast<tof_data_t>(nullptr));
40  auto data = reinterpret_cast<tof_data_t*>(vec.data());
41  size = tof_csf_camera_get_frames_at(ptr, frame_nr, data, vec.size(), TOF_ERROR_HANDLER{});
42  return vec;
43  }
44 
45  /** Get the location (count) of the current frame
46  * @return The currenc frame location
47  */
48  size_t get_current_frame() const {
49  auto ptr = reinterpret_cast<tof_csf_camera_t>(this->ptr_);
50  return tof_csf_camera_get_current_frame(ptr, TOF_ERROR_HANDLER{});
51  }
52 
53  /** Get the amount of frame lists this csf file can open/generate
54  * @return The number of frames in the csf file
55  */
56  size_t get_frame_number() const {
57  auto ptr = reinterpret_cast<tof_csf_camera_t>(this->ptr_);
58  return tof_csf_camera_get_frame_number(ptr, TOF_ERROR_HANDLER{});
59  }
60 
61  /** Get the FPS If the FPS is greater than 0 the time between subsequent
62  * function calls to get_frames or get_frames_at will be limited to the FPS
63  * This is done by sleeping on the next call to get_frames() if the time
64  * between calls is smaller than the time duration dictated by the fps.
65 
66  * @return The frames per second
67  */
68  size_t get_fps() const {
69  auto ptr = reinterpret_cast<tof_csf_camera_t>(this->ptr_);
70  return tof_csf_camera_get_fps(ptr, TOF_ERROR_HANDLER{});
71  }
72 
73  /** Set the FPS If the FPS is greater than 0 the time between subsequent
74  * function calls to get_frames or get_frames_at will be limited to the FPS
75  * This is done by sleeping on the next call to get_frames() if the time
76  * between calls is smaller than the time duration dictated by the fps.
77 
78  * @param fps The frames per second
79  */
80  void set_fps(size_t fps) {
81  auto ptr = reinterpret_cast<tof_csf_camera_t>(this->ptr_);
82  return tof_csf_camera_set_fps(ptr, fps, TOF_ERROR_HANDLER{});
83  }
84 
85 };
86 
87 } // tof
88 } // chronoptics
89 
90 #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:48
size_t get_frame_number() const
Get the amount of frame lists this csf file can open/generate.
Definition: csf_camera.hpp:56
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:68
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:33
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:80
Processing that can be done.