ifm3d
frame.h
1 /*
2  * Copyright 2022-present ifm electronic, gmbh
3  * SPDX-License-Identifier: Apache-2.0
4  */
5 
6 #ifndef IFM3D_FG_FRAME_H
7 #define IFM3D_FG_FRAME_H
8 
9 #include <chrono>
10 #include <cstdint>
11 #include <memory>
12 #include <type_traits>
13 #include <vector>
14 #include <ifm3d/device/device.h>
15 #include <ifm3d/fg/buffer.h>
16 #include <ifm3d/fg/module_frame_grabber.h>
17 
18 namespace ifm3d
19 {
24  enum class buffer_id : uint64_t
25  {
26  // clang-format off
27 
31  RADIAL_DISTANCE_IMAGE = static_cast<uint64_t>(ifm3d::image_chunk::RADIAL_DISTANCE_IMAGE),
32 
36  NORM_AMPLITUDE_IMAGE = static_cast<uint64_t>(ifm3d::image_chunk::NORM_AMPLITUDE_IMAGE),
37 
41  AMPLITUDE_IMAGE = static_cast<uint64_t>(ifm3d::image_chunk::AMPLITUDE_IMAGE),
42 
46  GRAYSCALE_IMAGE = static_cast<uint64_t>(ifm3d::image_chunk::GRAYSCALE_IMAGE),
47 
51  RADIAL_DISTANCE_NOISE = static_cast<uint64_t>(ifm3d::image_chunk::RADIAL_DISTANCE_NOISE),
52 
56  REFLECTIVITY = static_cast<uint64_t>(ifm3d::image_chunk::REFLECTIVITY),
57 
61  CARTESIAN_X_COMPONENT = static_cast<uint64_t>(ifm3d::image_chunk::CARTESIAN_X_COMPONENT),
62 
66  CARTESIAN_Y_COMPONENT = static_cast<uint64_t>(ifm3d::image_chunk::CARTESIAN_Y_COMPONENT),
67 
71  CARTESIAN_Z_COMPONENT = static_cast<uint64_t>(ifm3d::image_chunk::CARTESIAN_Z_COMPONENT),
72 
76  CARTESIAN_ALL = static_cast<uint64_t>(ifm3d::image_chunk::CARTESIAN_ALL),
77 
81  UNIT_VECTOR_ALL = static_cast<uint64_t>(ifm3d::image_chunk::UNIT_VECTOR_ALL),
82 
86  MONOCHROM_2D_12BIT = static_cast<uint64_t>(ifm3d::image_chunk::MONOCHROM_2D_12BIT),
87 
91  MONOCHROM_2D = static_cast<uint64_t>(ifm3d::image_chunk::MONOCHROM_2D),
92 
96  JPEG_IMAGE = static_cast<uint64_t>(ifm3d::image_chunk::JPEG_IMAGE),
97 
101  CONFIDENCE_IMAGE = static_cast<uint64_t>(ifm3d::image_chunk::CONFIDENCE_IMAGE),
102 
106  DIAGNOSTIC = static_cast<uint64_t>(ifm3d::image_chunk::DIAGNOSTIC),
107 
111  JSON_DIAGNOSTIC = static_cast<uint64_t>(ifm3d::image_chunk::JSON_DIAGNOSTIC),
112 
116  EXTRINSIC_CALIB = static_cast<uint64_t>(ifm3d::image_chunk::EXTRINSIC_CALIB),
117 
121  INTRINSIC_CALIB = static_cast<uint64_t>(ifm3d::image_chunk::INTRINSIC_CALIB),
122 
126  INVERSE_INTRINSIC_CALIBRATION = static_cast<uint64_t>(ifm3d::image_chunk::INVERSE_INTRINSIC_CALIBRATION),
127 
128 
129  O3R_DISTANCE_IMAGE_INFO [[deprecated]] = static_cast<uint64_t>(ifm3d::image_chunk::TOF_INFO),
130  O3R_RGB_IMAGE_INFO [[deprecated]] = static_cast<uint64_t>(ifm3d::image_chunk::RGB_INFO),
131 
135  TOF_INFO = static_cast<uint64_t>(ifm3d::image_chunk::TOF_INFO),
136 
140  RGB_INFO = static_cast<uint64_t>(ifm3d::image_chunk::RGB_INFO),
141 
145  JSON_MODEL = static_cast<uint64_t>(ifm3d::image_chunk::JSON_MODEL),
146 
150  ALGO_DEBUG = static_cast<uint64_t>(ifm3d::image_chunk::ALGO_DEBUG),
151 
155  O3R_ODS_OCCUPANCY_GRID = static_cast<uint64_t>(ifm3d::image_chunk::O3R_ODS_OCCUPANCY_GRID),
156 
160  O3R_ODS_INFO = static_cast<uint64_t>(ifm3d::image_chunk::O3R_ODS_INFO),
161 
165  O3R_RESULT_JSON = static_cast<uint64_t>(ifm3d::image_chunk::O3R_RESULT_JSON),
166 
170  O3R_RESULT_ARRAY2D = static_cast<uint64_t>(ifm3d::image_chunk::O3R_RESULT_ARRAY2D),
171 
175  O3R_RESULT_IMU = static_cast<uint64_t>(ifm3d::image_chunk::O3R_RESULT_IMU),
176 
177 
181  XYZ = (std::numeric_limits<std::uint32_t>::max)(),
182 
187 
192 
193  O3R_ODS_FLAGS,
194  O3R_MCC_LIVE_IMAGE,
195  O3R_MCC_MOTION_IMAGE,
196  O3R_MCC_STATIC_IMAGE,
197  O3R_ODS_RENDERED_ZONES,
198 
199  // clang-format on
200  };
201  using TimePointT = std::chrono::time_point<std::chrono::system_clock,
202  std::chrono::nanoseconds>;
203 
204  using BufferList = std::vector<Buffer>;
205  using BufferDataListMap = std::map<ifm3d::buffer_id, BufferList>;
206 
211  class IFM3D_EXPORT Frame
212  {
213  public:
214  using Ptr = std::shared_ptr<Frame>;
215 
216  Frame(const BufferDataListMap& images,
217  const std::vector<TimePointT> timestamps,
218  uint64_t frame_count);
219  ~Frame();
220 
221  Frame(const Frame& t);
222  Frame& operator=(const Frame& t);
223 
224  Frame(Frame&& t);
225  Frame& operator=(Frame&& t);
226 
232  std::vector<TimePointT> TimeStamps();
233 
241  bool HasBuffer(buffer_id id);
242 
251  Buffer& GetBuffer(buffer_id id,
252  std::optional<size_t> index = std::nullopt);
253 
257  size_t GetBufferCount(buffer_id id);
258 
262  uint32_t FrameCount();
263 
270  std::vector<buffer_id> GetBuffers();
271 
272  decltype(std::declval<std::map<buffer_id, BufferList>>().begin())
273  begin() noexcept;
274  decltype(std::declval<const std::map<buffer_id, BufferList>>().begin())
275  begin() const noexcept;
276  decltype(std::declval<std::map<buffer_id, BufferList>>().end())
277  end() noexcept;
278  decltype(std::declval<const std::map<buffer_id, BufferList>>().end()) end()
279  const noexcept;
280 
281  private:
282  class Impl;
283  std::unique_ptr<Impl> pImpl;
284  }; // end: class Organizer
285 
286 } // end: namespace ifm3d
287 
288 #endif // IFM3D_FG_FRAME_H
ifm3d::buffer_id::CARTESIAN_X_COMPONENT
@ CARTESIAN_X_COMPONENT
ifm3d::buffer_id::ILLUMINATION_TEMP
@ ILLUMINATION_TEMP
ifm3d::buffer_id::DIAGNOSTIC
@ DIAGNOSTIC
ifm3d::buffer_id::JPEG_IMAGE
@ JPEG_IMAGE
ifm3d::buffer_id::JSON_MODEL
@ JSON_MODEL
ifm3d::buffer_id::RADIAL_DISTANCE_IMAGE
@ RADIAL_DISTANCE_IMAGE
ifm3d::buffer_id::O3R_RESULT_ARRAY2D
@ O3R_RESULT_ARRAY2D
ifm3d::O3R_RESULT_ARRAY2D
ifm3d::Buffer
The class Buffer represent a STL container to store data from the ifm devices in 2 dimension and supp...
Definition: buffer.h:98
ifm3d::buffer_id::O3R_ODS_INFO
@ O3R_ODS_INFO
ifm3d::ODSInfoV1
ifm3d::buffer_id
buffer_id
Definition: frame.h:24
ifm3d::buffer_id::MONOCHROM_2D
@ MONOCHROM_2D
ifm3d::buffer_id::RGB_INFO
@ RGB_INFO
ifm3d::RGBInfoV1
ifm3d::buffer_id::INVERSE_INTRINSIC_CALIBRATION
@ INVERSE_INTRINSIC_CALIBRATION
ifm3d::buffer_id::CARTESIAN_Y_COMPONENT
@ CARTESIAN_Y_COMPONENT
ifm3d::buffer_id::RADIAL_DISTANCE_NOISE
@ RADIAL_DISTANCE_NOISE
ifm3d::buffer_id::CARTESIAN_ALL
@ CARTESIAN_ALL
ifm3d::buffer_id::EXTRINSIC_CALIB
@ EXTRINSIC_CALIB
ifm3d::buffer_id::TOF_INFO
@ TOF_INFO
ifm3d::TOFInfoV3 / ifm3d::TOFInfoV4
ifm3d::buffer_id::REFLECTIVITY
@ REFLECTIVITY
ifm3d::buffer_id::AMPLITUDE_IMAGE
@ AMPLITUDE_IMAGE
ifm3d::buffer_id::CONFIDENCE_IMAGE
@ CONFIDENCE_IMAGE
ifm3d::Frame
Definition: frame.h:211
ifm3d::buffer_id::O3R_ODS_OCCUPANCY_GRID
@ O3R_ODS_OCCUPANCY_GRID
ifm3d::ODSOccupancyGridV1
ifm3d::buffer_id::NORM_AMPLITUDE_IMAGE
@ NORM_AMPLITUDE_IMAGE
ifm3d::buffer_id::ALGO_DEBUG
@ ALGO_DEBUG
ifm3d::buffer_id::MONOCHROM_2D_12BIT
@ MONOCHROM_2D_12BIT
ifm3d::buffer_id::XYZ
@ XYZ
The point cloud encoded as a 3 channel XYZ image.
ifm3d::buffer_id::UNIT_VECTOR_ALL
@ UNIT_VECTOR_ALL
ifm3d::buffer_id::GRAYSCALE_IMAGE
@ GRAYSCALE_IMAGE
ifm3d::buffer_id::INTRINSIC_CALIB
@ INTRINSIC_CALIB
ifm3d::buffer_id::EXPOSURE_TIME
@ EXPOSURE_TIME
ifm3d::buffer_id::O3R_RESULT_IMU
@ O3R_RESULT_IMU
ifm3d::O3R_RESULT_IMU
ifm3d::buffer_id::CARTESIAN_Z_COMPONENT
@ CARTESIAN_Z_COMPONENT
ifm3d::buffer_id::O3R_RESULT_JSON
@ O3R_RESULT_JSON
ifm3d::O3R_RESULT_JSON
ifm3d::buffer_id::JSON_DIAGNOSTIC
@ JSON_DIAGNOSTIC