7 #ifndef IFM3D_DESERIALIZE_STRUCT_RGB_INFO_V1_HPP
8 #define IFM3D_DESERIALIZE_STRUCT_RGB_INFO_V1_HPP
10 #include <ifm3d/device/device.h>
11 #include <ifm3d/device/err.h>
12 #include <ifm3d/fg/organizer_utils.h>
13 #include <ifm3d/fg/buffer.h>
14 #include <ifm3d/deserialize/deserialize_utils.hpp>
15 #include <ifm3d/deserialize/struct_calibration.hpp>
21 constexpr
auto RGB_INFO_VERSION_INDEX = 0x0000;
22 constexpr
auto RGB_INFO_FRAME_COUNTER_INDEX = 0x0004;
23 constexpr
auto RGB_INFO_TIMESTAMPS_INDEX = 0x0008;
24 constexpr
auto RGB_INFO_EXPOSURE_TIMES_INDEX = 0x0010;
25 constexpr
auto RGB_INFO_EXTRINSIC_OPTICAL_TO_USER_INDEX = 0x0014;
26 constexpr
auto RGB_INFO_INTRINSIC_CALIBRATION_INDEX = 0x002C;
27 constexpr
auto RGB_INFO_INVERSE_INTRINSIC_CALIBRATION_INDEX = 0x00B0;
35 using Ptr = std::shared_ptr<RGBInfoV1>;
38 IsValid(
const uint8_t* data,
size_t size)
40 uint32_t version = mkval<std::uint32_t>(data + RGB_INFO_VERSION_INDEX);
42 if (size < rgb_info_v1_size || version < 1)
50 Read(
const uint8_t* data,
size_t size)
52 if (!IsValid(data, size))
56 const uint8_t* start_ptr = data;
57 version = mkval<std::uint32_t>(start_ptr + RGB_INFO_VERSION_INDEX);
59 mkval<std::uint32_t>(start_ptr + RGB_INFO_FRAME_COUNTER_INDEX);
61 mkval<std::uint64_t>(start_ptr + RGB_INFO_TIMESTAMPS_INDEX);
62 exposure_time = mkval<float>(start_ptr + RGB_INFO_EXPOSURE_TIMES_INDEX);
63 extrinsic_optic_to_user.Read(start_ptr +
64 RGB_INFO_EXTRINSIC_OPTICAL_TO_USER_INDEX);
65 intrinsic_calibration.Read(start_ptr +
66 RGB_INFO_INTRINSIC_CALIBRATION_INDEX);
67 inverse_intrinsic_calibration.Read(
68 start_ptr + RGB_INFO_INVERSE_INTRINSIC_CALIBRATION_INDEX);
71 std::uint32_t version;
74 std::uint32_t frame_counter;
76 std::uint64_t timestamp_ns;
86 static constexpr
size_t rgb_info_v1_size = 308;
89 Deserialize(
const Buffer& rgb_info_buffer)
93 rgb_info_v1.Read(rgb_info_buffer.
ptr<uint8_t>(0),
94 rgb_info_buffer.
size());
100 #endif // IFM3D_DESERIALIZE_STRUCT_RGB_INFO_V1_HPP