Time-of-Flight Library(ToF)  3.2.2
csf_writer.hpp
1 #ifndef _CHRONOPTICS_TOF_CSF_WRITER_HPP_
2 #define _CHRONOPTICS_TOF_CSF_WRITER_HPP_
3 
4 #include <chronoptics/tof/csf_writer.h>
5 
6 #include <chronoptics/tof/camera_config.hpp>
7 #include <chronoptics/tof/calibration.hpp>
8 #include <chronoptics/tof/data.hpp>
9 #include <chronoptics/tof/csf_reader.hpp>
10 #include <chronoptics/tof/camera.hpp>
11 #include <chronoptics/tof/gige_interface.hpp>
12 #include <chronoptics/tof/usb_interface.hpp>
13 
14 namespace chronoptics {
15 namespace tof {
16 
17 /** The csf writer class takes care of writing depth frames to disk. The class
18  * has to be created from either a Camera or csf reader, because it needs
19  * information about the camera that was used to record the depth frames.
20  * Therefore you should only write depth frames coming from one camera into the
21  * same writer
22 
23 */
24 class CsfWriter : public detail::Base<tof_csf_writer, tof_csf_writer_delete> {
25  public:
26  /** Construct from pointer */
27  CsfWriter(tof_csf_writer_t ptr = nullptr) {
28  this->ptr_ = ptr;
29  }
30 
31  /** Construct csf writer from calibration and configuration
32  * @param file_location Path to where the csf file should be created
33  * @param camera_config Camera configuration
34  * @param calibration Calibration
35  * @param serial Serial number of camera
36  */
37  CsfWriter(StringView file_location, const CameraConfig &camera_config, const Calibration &calibration, StringView serial) {
38  this->ptr_ = tof_csf_writer_new(file_location, *reinterpret_cast<const tof_camera_config_t*>(&camera_config), *reinterpret_cast<const tof_calibration_t*>(&calibration), serial, TOF_ERROR_HANDLER{});
39  }
40 
41  /** Write frame to csf file
42  * @param frame A data frame
43  */
44  void write_frame(const Data &frame) {
45  return tof_csf_writer_write_frame(this->ptr_, *reinterpret_cast<const tof_data_t*>(&frame), TOF_ERROR_HANDLER{});
46  }
47 
48 };
49 
50 /** Create csf writer from csf reader
51  * @param file_location Path to where the csf file should be created
52  * @param reader A csf reader
53  * @return csf writer
54  */
55 inline CsfWriter create_csf_writer_reader(StringView file_location, const CsfReader &reader) {
56  CsfWriter new_csf_writer(static_cast<tof_csf_writer_t>(nullptr));
57  auto ptr = reinterpret_cast<tof_csf_writer_t*>(&new_csf_writer);
58  *ptr = tof_create_csf_writer_reader(file_location, *reinterpret_cast<const tof_csf_reader_t*>(&reader), TOF_ERROR_HANDLER{});
59  return new_csf_writer;
60 }
61 
62 /** Create csf writer from camera
63  * @param file_location Path to where the csf file should be created
64  * @param camera A camera
65  * @return csf writer
66  */
67 inline CsfWriter create_csf_writer_camera(StringView file_location, const Camera &camera) {
68  CsfWriter new_csf_writer(static_cast<tof_csf_writer_t>(nullptr));
69  auto ptr = reinterpret_cast<tof_csf_writer_t*>(&new_csf_writer);
70  *ptr = tof_create_csf_writer_camera(file_location, *reinterpret_cast<const tof_camera_t*>(&camera), TOF_ERROR_HANDLER{});
71  return new_csf_writer;
72 }
73 
74 /** Create csf writer from the GigE interface
75  * @param file_location Path to where the csf file should be created
76  * @param gige_interface A GigE interface
77  * @return csf writer
78  */
79 inline CsfWriter create_csf_writer_gige_interface(StringView file_location, const GigeInterface &gige_interface) {
80  CsfWriter new_csf_writer(static_cast<tof_csf_writer_t>(nullptr));
81  auto ptr = reinterpret_cast<tof_csf_writer_t*>(&new_csf_writer);
82  *ptr = tof_create_csf_writer_gige_interface(file_location, *reinterpret_cast<const tof_gige_interface_t*>(&gige_interface), TOF_ERROR_HANDLER{});
83  return new_csf_writer;
84 }
85 
86 /** Create csf writer from the USB interface
87  * @param file_location Path to where the csf file should be created
88  * @param usb_interface A USB interface
89  * @return csf writer
90  */
91 inline CsfWriter create_csf_writer_usb_interface(StringView file_location, const UsbInterface &usb_interface) {
92  CsfWriter new_csf_writer(static_cast<tof_csf_writer_t>(nullptr));
93  auto ptr = reinterpret_cast<tof_csf_writer_t*>(&new_csf_writer);
94  *ptr = tof_create_csf_writer_usb_interface(file_location, *reinterpret_cast<const tof_usb_interface_t*>(&usb_interface), TOF_ERROR_HANDLER{});
95  return new_csf_writer;
96 }
97 
98 } // tof
99 } // chronoptics
100 
101 #endif
This class contains all the calibration information.
Definition: calibration.hpp:13
This class allows you to view/edit the camera settings.
The csf writer class takes care of writing depth frames to disk.
Definition: csf_writer.hpp:24
CsfWriter(tof_csf_writer_t ptr=nullptr)
Construct from pointer.
Definition: csf_writer.hpp:27
void write_frame(const Data &frame)
Write frame to csf file.
Definition: csf_writer.hpp:44
CsfWriter(StringView file_location, const CameraConfig &camera_config, const Calibration &calibration, StringView serial)
Construct csf writer from calibration and configuration.
Definition: csf_writer.hpp:37
This is the class that contains depth or image data.
Definition: data.hpp:31