ImageMessage.h
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 = 1;
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 
68  :
69 #ifdef SENSORDPOD_FIRMWARE
70  id(ID),
71  version(VERSION),
72 #endif // SENSORPOD_FIRMWARE
73  source(0),
74  bitsPerPixel(0),
75  frameId(0),
76  width(0),
77  height(0) {};
78 };
79 
80 #ifndef SENSORPOD_FIRMWARE
81 
82 class Image : public ImageHeader {
83 public:
84 
85  void *dataP;
86 
87  //
88  // Constructors
89 
91  Image() : dataP(NULL) {};
92 
93  //
94  // Serialization routine
95 
96  template<class Archive>
97  void serialize(Archive& message,
98  const VersionType version)
99  {
100  (void) version;
101  message & source;
102  message & bitsPerPixel;
103  message & frameId;
104  message & width;
105  message & height;
106 
107  const uint32_t imageSize = static_cast<uint32_t> (std::ceil(((double) bitsPerPixel / 8.0) * width * height));
108 
109  if (typeid(Archive) == typeid(utility::BufferStreamWriter)) {
110 
111  message.write(dataP, imageSize);
112 
113  } else {
114 
115  dataP = message.peek();
116  message.seek(message.tell() + imageSize);
117  }
118  }
119 };
120 
121 #endif // !SENSORPOD_FIRMWARE
122 
123 }}}} // namespaces
124 
125 #endif
static CRL_CONSTEXPR IdType ID_DATA_IMAGE
Definition: Protocol.h:205
std::string * frameId(M &m)
void serialize(Stream &stream, const T &t)
Definition: channel.cc:56
#define WIRE_HEADER_ATTRIBS_
Definition: Protocol.h:64
void serialize(Archive &message, const VersionType version)
Definition: ImageMessage.h:97
#define CRL_CONSTEXPR
Definition: Portability.hh:51
Image(utility::BufferStreamReader &r, VersionType v)
Definition: ImageMessage.h:90


multisense_lib
Author(s):
autogenerated on Sun Mar 14 2021 02:34:50