ImageMessage.hh
Go to the documentation of this file.
1 
37 #ifndef LibMultiSense_ImageMessage
38 #define LibMultiSense_ImageMessage
39 
40 #include <typeinfo>
41 #include <cmath>
42 
44 
45 namespace crl {
46 namespace multisense {
47 namespace details {
48 namespace wire {
49 
51 public:
52 
54 static CRL_CONSTEXPR VersionType VERSION = 2;
55 
56 #ifdef SENSORPOD_FIRMWARE
57  IdType id;
58  VersionType version;
59 #endif // SENSORPOD_FIRMWARE
60 
61  uint32_t source;
62  uint32_t bitsPerPixel;
63  int64_t frameId;
64  uint16_t width;
65  uint16_t height;
66  uint32_t exposure;
67  float gain;
68 
70  :
71 #ifdef SENSORDPOD_FIRMWARE
72  id(ID),
73  version(VERSION),
74 #endif // SENSORPOD_FIRMWARE
75  source(0),
76  bitsPerPixel(0),
77  frameId(0),
78  width(0),
79  height(0),
80  exposure(0),
81  gain(0.0)
82  {};
83 };
84 
85 #ifndef SENSORPOD_FIRMWARE
86 
87 class Image : public ImageHeader {
88 public:
89 
90  void *dataP;
91 
92  //
93  // Constructors
94 
96  Image() : dataP(NULL) {};
97 
98  //
99  // Serialization routine
100 
101  template<class Archive>
102  void serialize(Archive& message,
103  const VersionType version)
104  {
105  (void) version;
106  message & source;
107  message & bitsPerPixel;
108  message & frameId;
109  message & width;
110  message & height;
111 
112  const uint32_t imageSize = static_cast<uint32_t> (std::ceil(((double) bitsPerPixel / 8.0) * width * height));
113 
114  if (typeid(Archive) == typeid(utility::BufferStreamWriter)) {
115 
116  message.write(dataP, imageSize);
117 
118  } else {
119 
120  dataP = message.peek();
121  message.seek(message.tell() + imageSize);
122  }
123 
124  if (version >= 2)
125  {
126  message & exposure;
127  message & gain;
128  }
129  else
130  {
131  exposure = 0;
132  gain = Default_Gain;
133  }
134  }
135 };
136 
137 #endif // !SENSORPOD_FIRMWARE
138 
139 }}}} // namespaces
140 
141 #endif
static CRL_CONSTEXPR IdType ID_DATA_IMAGE
Definition: Protocol.hh:209
std::string * frameId(M &m)
void serialize(Stream &stream, const T &t)
Definition: channel.cc:58
void serialize(Archive &message, const VersionType version)
#define WIRE_HEADER_ATTRIBS_
Definition: Protocol.hh:64
static CRL_CONSTEXPR float Default_Gain
Definition: Protocol.hh:307
#define CRL_CONSTEXPR
Definition: Portability.hh:49
Image(utility::BufferStreamReader &r, VersionType v)
Definition: ImageMessage.hh:95


multisense_lib
Author(s):
autogenerated on Sat Jun 24 2023 03:01:21