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/frame_grabber_export.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 
198  // clang-format on
199  };
200  using TimePointT = std::chrono::time_point<std::chrono::system_clock,
201  std::chrono::nanoseconds>;
202 
203  using BufferList = std::vector<Buffer>;
204  using BufferDataListMap = std::map<ifm3d::buffer_id, BufferList>;
205 
210  class IFM3D_FRAME_GRABBER_EXPORT Frame
211  {
212  public:
213  using Ptr = std::shared_ptr<Frame>;
214 
215  Frame(const BufferDataListMap& images,
216  const std::vector<TimePointT> timestamps,
217  uint64_t frame_count);
218  ~Frame();
219 
220  Frame(const Frame& t);
221  Frame& operator=(const Frame& t);
222 
223  Frame(Frame&& t);
224  Frame& operator=(Frame&& t);
225 
231  std::vector<TimePointT> TimeStamps();
232 
240  bool HasBuffer(buffer_id id);
241 
250  Buffer& GetBuffer(buffer_id id,
251  std::optional<size_t> index = std::nullopt);
252 
256  size_t GetBufferCount(buffer_id id);
257 
261  uint32_t FrameCount();
262 
269  std::vector<buffer_id> GetBuffers();
270 
271  decltype(std::declval<std::map<buffer_id, BufferList>>().begin())
272  begin() noexcept;
273  decltype(std::declval<const std::map<buffer_id, BufferList>>().begin())
274  begin() const noexcept;
275  decltype(std::declval<std::map<buffer_id, BufferList>>().end())
276  end() noexcept;
277  decltype(std::declval<const std::map<buffer_id, BufferList>>().end()) end()
278  const noexcept;
279 
280  private:
281  class Impl;
282  std::unique_ptr<Impl> pImpl;
283  }; // end: class Organizer
284 
285 } // end: namespace ifm3d
286 
287 #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:210
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