LibMultiSense
LibMultiSense Documentation
Loading...
Searching...
No Matches
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
45namespace crl {
46namespace multisense {
47namespace details {
48namespace wire {
49
51public:
52
53static CRL_CONSTEXPR IdType ID = ID_DATA_IMAGE;
54static CRL_CONSTEXPR VersionType VERSION = 3;
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;
69
71 :
72#ifdef SENSORPOD_FIRMWARE
73 id(ID),
74 version(VERSION),
75#endif // SENSORPOD_FIRMWARE
76 source(0),
77 bitsPerPixel(0),
78 frameId(0),
79 width(0),
80 height(0),
81 exposure(0),
82 gain(0.0),
83 sourceExtended(0)
84 {};
85};
86
87#ifndef SENSORPOD_FIRMWARE
88
89class Image : public ImageHeader {
90public:
91
92 void *dataP;
93
94 //
95 // Constructors
96
98 Image() : dataP(NULL) {};
99
100 //
101 // Serialization routine
102
103 template<class Archive>
104 void serialize(Archive& message,
105 const VersionType version)
106 {
107 message & source;
108 message & bitsPerPixel;
109 message & frameId;
110 message & width;
111 message & height;
112
113 const uint32_t imageSize = static_cast<uint32_t> (std::ceil(((double) bitsPerPixel / 8.0) * width * height));
114
115 if (typeid(Archive) == typeid(utility::BufferStreamWriter)) {
116
117 message.write(dataP, imageSize);
118
119 } else {
120
121 dataP = message.peek();
122 message.seek(message.tell() + imageSize);
123 }
124
125 if (version >= 2)
126 {
127 message & exposure;
128 message & gain;
129 }
130 else
131 {
132 exposure = 0;
134 }
135
136 if (version >= 3)
137 {
138 message & sourceExtended;
139 }
140 else
141 {
142 sourceExtended = 0;
143 }
144 }
145};
146
147#endif // !SENSORPOD_FIRMWARE
148
149}}}} // namespaces
150
151#endif
Macros and symbols to help portability between different compiler versions.
#define CRL_CONSTEXPR
#define WIRE_HEADER_ATTRIBS_
Definition Protocol.hh:65
Image(utility::BufferStreamReader &r, VersionType v)
void serialize(Archive &message, const VersionType version)
static CRL_CONSTEXPR float Default_Gain
Definition Protocol.hh:335