Time-of-Flight Library(ToF) 3.13.4
 
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/camera.hpp>
9#include <chronoptics/tof/data.hpp>
10#include <chronoptics/tof/csf_reader.hpp>
11#include <chronoptics/tof/gige_interface.hpp>
12#include <chronoptics/tof/usb_interface.hpp>
13
14namespace chronoptics {
15namespace 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*/
24class 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 /** Construct the csf writer from a camera
42 * @param file_location Path to where the csf file should be created
43 * @param camera The camera to get the camera config and calibration file from
44 */
45 CsfWriter(StringView file_location, Camera &camera) {
46 this->ptr_ = tof_csf_writer_new_from_camera(file_location, *reinterpret_cast<tof_camera_t*>(&camera), TOF_ERROR_HANDLER{});
47 }
48
49 /** Write frame to csf file
50 * @param frame A data frame
51 */
52 void write_frame(const Data &frame) {
53 return tof_csf_writer_write_frame(this->ptr_, *reinterpret_cast<const tof_data_t*>(&frame), TOF_ERROR_HANDLER{});
54 }
55
56};
57
58/** Create csf writer from csf reader
59 * @param file_location Path to where the csf file should be created
60 * @param reader A csf reader
61 * @return csf writer
62 */
63inline CsfWriter create_csf_writer_reader(StringView file_location, const CsfReader &reader) {
64 CsfWriter new_csf_writer(static_cast<tof_csf_writer_t>(nullptr));
65 auto ptr = reinterpret_cast<tof_csf_writer_t*>(&new_csf_writer);
66 *ptr = tof_create_csf_writer_reader(file_location, *reinterpret_cast<const tof_csf_reader_t*>(&reader), TOF_ERROR_HANDLER{});
67 return new_csf_writer;
68}
69
70/** Create csf writer from camera
71 * @param file_location Path to where the csf file should be created
72 * @param camera A camera
73 * @return csf writer
74 */
75inline CsfWriter create_csf_writer_camera(StringView file_location, const Camera &camera) {
76 CsfWriter new_csf_writer(static_cast<tof_csf_writer_t>(nullptr));
77 auto ptr = reinterpret_cast<tof_csf_writer_t*>(&new_csf_writer);
78 *ptr = tof_create_csf_writer_camera(file_location, *reinterpret_cast<const tof_camera_t*>(&camera), TOF_ERROR_HANDLER{});
79 return new_csf_writer;
80}
81
82/** Create csf writer from the GigE interface
83 * @param file_location Path to where the csf file should be created
84 * @param gige_interface A GigE interface
85 * @return csf writer
86 */
87inline CsfWriter create_csf_writer_gige_interface(StringView file_location, const GigeInterface &gige_interface) {
88 CsfWriter new_csf_writer(static_cast<tof_csf_writer_t>(nullptr));
89 auto ptr = reinterpret_cast<tof_csf_writer_t*>(&new_csf_writer);
90 *ptr = tof_create_csf_writer_gige_interface(file_location, *reinterpret_cast<const tof_gige_interface_t*>(&gige_interface), TOF_ERROR_HANDLER{});
91 return new_csf_writer;
92}
93
94/** Create csf writer from the USB interface
95 * @param file_location Path to where the csf file should be created
96 * @param usb_interface A USB interface
97 * @return csf writer
98 */
99inline CsfWriter create_csf_writer_usb_interface(StringView file_location, const UsbInterface &usb_interface) {
100 CsfWriter new_csf_writer(static_cast<tof_csf_writer_t>(nullptr));
101 auto ptr = reinterpret_cast<tof_csf_writer_t*>(&new_csf_writer);
102 *ptr = tof_create_csf_writer_usb_interface(file_location, *reinterpret_cast<const tof_usb_interface_t*>(&usb_interface), TOF_ERROR_HANDLER{});
103 return new_csf_writer;
104}
105
106} // tof
107} // chronoptics
108
109#endif
This class contains all the calibration information.
Definition: calibration.hpp:38
This class allows you to view/edit the camera settings.
The main interface to the depth cameras.
Definition: camera.hpp:17
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:52
CsfWriter(StringView file_location, Camera &camera)
Construct the csf writer from a camera.
Definition: csf_writer.hpp:45
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