forked from qualisys/qualisys_cpp_sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
RTPacket.h
332 lines (288 loc) · 13.3 KB
/
RTPacket.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
#ifndef RTPACKET_H
#define RTPACKET_H
#include <vector>
#ifdef _WIN32
#pragma warning (disable : 4251)
#endif
#ifdef EXPORT_DLL
#define DLL_EXPORT __declspec(dllexport)
#else
#define DLL_EXPORT
#endif
#define MAJOR_VERSION 1
#define MINOR_VERSION 23
class DLL_EXPORT CRTPacket
{
public:
enum EPacketType
{
PacketError = 0,
PacketCommand = 1,
PacketXML = 2,
PacketData = 3,
PacketNoMoreData = 4,
PacketC3DFile = 5,
PacketEvent = 6,
PacketDiscover = 7,
PacketQTMFile = 8,
PacketNone = 9
};
enum EComponentType
{
Component3d = 1,
Component3dNoLabels = 2,
ComponentAnalog = 3,
ComponentForce = 4,
Component6d = 5,
Component6dEuler = 6,
Component2d = 7,
Component2dLin = 8,
Component3dRes = 9,
Component3dNoLabelsRes = 10,
Component6dRes = 11,
Component6dEulerRes = 12,
ComponentAnalogSingle = 13,
ComponentImage = 14,
ComponentForceSingle = 15,
ComponentGazeVector = 16,
ComponentTimecode = 17,
ComponentSkeleton = 18,
ComponentEyeTracker = 19,
ComponentNone = 20
};
enum EImageFormat
{
FormatRawGrayscale = 0,
FormatRawBGR = 1,
FormatJPG = 2,
FormatPNG = 3
};
enum EEvent
{
EventConnected = 1,
EventConnectionClosed = 2,
EventCaptureStarted = 3,
EventCaptureStopped = 4,
EventCaptureFetchingFinished = 5, // Not used in version 1.10 and later
EventCalibrationStarted = 6,
EventCalibrationStopped = 7,
EventRTfromFileStarted = 8,
EventRTfromFileStopped = 9,
EventWaitingForTrigger = 10,
EventCameraSettingsChanged = 11,
EventQTMShuttingDown = 12,
EventCaptureSaved = 13,
EventReprocessingStarted = 14,
EventReprocessingStopped = 15,
EventTrigger = 16,
EventNone = 17 // Must be the last. Not actually an event. Just used to cont number of events.
};
enum ETimecodeType
{
TimecodeSMPTE = 0,
TimecodeIRIG = 1,
TimecodeCamerTime = 2
};
struct SForce
{
float fForceX;
float fForceY;
float fForceZ;
float fMomentX;
float fMomentY;
float fMomentZ;
float fApplicationPointX;
float fApplicationPointY;
float fApplicationPointZ;
};
struct SGazeVector
{
float fX;
float fY;
float fZ;
float fPosX;
float fPosY;
float fPosZ;
};
struct SEyeTracker
{
float leftPupilDiameter;
float rightPupilDiameter;
};
struct SPosition
{
float x;
float y;
float z;
};
struct SRotation
{
float x;
float y;
float z;
float w;
};
struct SSkeletonSegment
{
unsigned int id;
float positionX;
float positionY;
float positionZ;
float rotationX;
float rotationY;
float rotationZ;
float rotationW;
};
public:
CRTPacket(int nMajorVersion = MAJOR_VERSION, int nMinorVersion = MINOR_VERSION, bool bBigEndian = false);
void GetVersion(unsigned int &nMajorVersion, unsigned int &nMinorVersion);
void SetVersion(unsigned int nMajorVersion, unsigned int nMinorVersion);
bool GetEndianness();
void SetEndianness(bool bBigEndian);
void ClearData();
void SetData(char* ptr);
void GetData(char* &ptr, unsigned int &nSize);
unsigned int GetSize();
EPacketType GetType();
unsigned long long GetTimeStamp();
unsigned int GetFrameNumber();
static unsigned int GetSize(char* pData, bool bBigEndian = false);
static EPacketType GetType(char* pData, bool bBigEndian = false);
static unsigned long long GetTimeStamp(char* pData, bool bBigEndian = false);
static unsigned int GetFrameNumber(char* pData, bool bBigEndian = false);
unsigned int GetComponentCount();
unsigned int GetComponentSize(EComponentType eComponent);
char* GetErrorString();
char* GetCommandString();
static char* GetCommandString(char* pData, bool bBigEndian = false);
char* GetXMLString();
bool GetEvent(EEvent &eEvent);
static bool GetEvent(EEvent &eEvent, char* pData, bool bBigEndian = false);
short GetDiscoverResponseBasePort();
static short GetDiscoverResponseBasePort(char* pData, bool bBigEndian = false);
unsigned short GetDropRate();
unsigned short GetOutOfSyncRate();
unsigned int Get2DCameraCount();
unsigned int Get2DMarkerCount(unsigned int nCameraIndex);
unsigned char Get2DStatusFlags(unsigned int nCameraIndex);
bool Get2DMarker(unsigned int nCameraIndex, unsigned int nMarkerIndex, unsigned int &nX,
unsigned int &nY, unsigned short &nXDiameter, unsigned short & nYDiameter);
unsigned int Get2DLinCameraCount();
unsigned int Get2DLinMarkerCount(unsigned int nCameraIndex);
unsigned char Get2DLinStatusFlags(unsigned int nCameraIndex);
bool Get2DLinMarker(unsigned int nCameraIndex, unsigned int nMarkerIndex, unsigned int &nX,
unsigned int &nY, unsigned short &nXDiameter, unsigned short & nYDiameter);
unsigned int Get3DMarkerCount();
bool Get3DMarker(unsigned int nMarkerIndex, float &fX, float &fY, float &fZ);
unsigned int Get3DResidualMarkerCount();
bool Get3DResidualMarker(unsigned int nMarkerIndex, float &fX, float &fY, float &fZ,
float &fResidual);
unsigned int Get3DNoLabelsMarkerCount();
bool Get3DNoLabelsMarker(unsigned int nMarkerIndex, float &fX, float &fY, float &fZ,
unsigned int &nId);
unsigned int Get3DNoLabelsResidualMarkerCount();
bool Get3DNoLabelsResidualMarker(unsigned int nMarkerIndex, float &fX, float &fY, float &fZ,
unsigned int &nId, float &fResidual);
unsigned int Get6DOFBodyCount();
bool Get6DOFBody(unsigned int nBodyIndex, float &fX, float &fY, float &fZ, float afRotMatrix[9]);
unsigned int Get6DOFResidualBodyCount();
bool Get6DOFResidualBody(unsigned int nBodyIndex, float &fX, float &fY, float &fZ,
float afRotMatrix[9], float &fResidual);
unsigned int Get6DOFEulerBodyCount();
bool Get6DOFEulerBody(unsigned int nBodyIndex, float &fX, float &fY, float &fZ,
float &fAng1, float &fAng2, float &fAng3);
unsigned int Get6DOFEulerResidualBodyCount();
bool Get6DOFEulerResidualBody(unsigned int nBodyIndex, float &fX, float &fY, float &fZ,
float &fAng1, float &fAng2, float &fAng3, float &fResidual);
unsigned int GetGazeVectorCount();
unsigned int GetGazeVectorSampleCount(unsigned int nVectorIndex);
unsigned int GetGazeVectorSampleNumber(unsigned int nVectorIndex); // Returns 0 if no sample was found.
bool GetGazeVector(unsigned int nVectorIndex, unsigned int nSampleIndex, SGazeVector &nGazeVector);
bool GetGazeVector(unsigned int nVectorIndex, SGazeVector* pGazeVectorBuf, unsigned int nBufSize);
unsigned int GetEyeTrackerCount();
unsigned int GetEyeTrackerSampleCount(unsigned int eyeTrackerIndex);
unsigned int GetEyeTrackerSampleNumber(unsigned int eyeTrackerIndex); // Returns 0 if no sample was found.
bool GetEyeTrackerData(unsigned int eyeTrackerIndex, unsigned int nSampleIndex, SEyeTracker &nEyeTracker);
bool GetEyeTrackerData(unsigned int eyeTrackerIndex, SEyeTracker* pEyeTrackerBuf, unsigned int nBufSize);
bool IsTimeCodeAvailable() const;
bool GetTimecodeType(CRTPacket::ETimecodeType &timecodeType);
bool GetTimecodeSMPTE(int &hours, int &minutes, int &seconds, int &frames);
bool GetTimecodeIRIG(int &years, int &days, int &hours, int &minutes, int &seconds, int &tenths);
bool GetTimecodeCameraTime(unsigned long long &cameraTime);
unsigned int GetImageCameraCount();
unsigned int GetImageCameraId(unsigned int nCameraIndex);
bool GetImageFormat(unsigned int nCameraIndex, EImageFormat &eImageFormat);
bool GetImageSize(unsigned int nCameraIndex, unsigned int &nWidth, unsigned int &nHeight);
bool GetImageCrop(unsigned int nCameraIndex, float &fCropLeft, float &fCropTop,
float &fCropRight, float &fCropBottom);
unsigned int GetImageSize(unsigned int nCameraIndex);
unsigned int GetImage(unsigned int nCameraIndex, char* pDataBuf, unsigned int nBufSize);
unsigned int GetAnalogDeviceCount();
unsigned int GetAnalogDeviceId(unsigned int nDeviceIndex);
unsigned int GetAnalogChannelCount(unsigned int nDeviceIndex);
unsigned int GetAnalogSampleCount(unsigned int nDeviceIndex);
unsigned int GetAnalogSampleNumber(unsigned int nDeviceIndex); // Returns 0 if no sample was found.
unsigned int GetAnalogData(unsigned int nDeviceIndex, float* pDataBuf, unsigned int nBufSize);
unsigned int GetAnalogData(unsigned int nDeviceIndex, unsigned int nChannelIndex, float* pDataBuf, unsigned int nBufSize);
bool GetAnalogData(unsigned int nDeviceIndex, unsigned int nChannelIndex,
unsigned int nSampleIndex, float &fAnalogValue);
unsigned int GetAnalogSingleDeviceCount();
unsigned int GetAnalogSingleDeviceId(unsigned int nDeviceIndex);
unsigned int GetAnalogSingleChannelCount(unsigned int nDeviceIndex);
unsigned int GetAnalogSingleData(unsigned int nDeviceIndex, float* pDataBuf, unsigned int nBufSize);
bool GetAnalogSingleData(unsigned int nDeviceIndex, unsigned int nChannelIndex, float &fValue);
unsigned int GetForcePlateCount();
unsigned int GetForcePlateId(unsigned int nPlateIndex);
unsigned int GetForceCount(unsigned int nPlateIndex);
unsigned int GetForceNumber(unsigned int nPlateIndex);// Returns 0 if no force was found.
unsigned int GetForceData(unsigned int nPlateIndex, SForce* pForceBuf, unsigned int nBufSize);
bool GetForceData(unsigned int nPlateIndex, unsigned int nForceIndex, SForce &sForce);
unsigned int GetForceSinglePlateCount();
unsigned int GetForceSinglePlateId(unsigned int nPlateIndex);
bool GetForceSingleData(unsigned int nPlateIndex, SForce &pForce);
unsigned int GetSkeletonCount();
unsigned int GetSkeletonSegmentCount(unsigned int nSkeletonIndex);
bool GetSkeletonSegments(unsigned int nSkeletonIndex, SSkeletonSegment* segmentBuf, unsigned int nBufSize);
bool GetSkeletonSegment(unsigned int nSkeletonIndex, unsigned segmentIndex, SSkeletonSegment &segment);
private:
float SetByteOrder(float* pfData);
double SetByteOrder(double* pfData);
short SetByteOrder(short* pnData);
unsigned short SetByteOrder(unsigned short* pnData);
long SetByteOrder(long* pnData);
int SetByteOrder(int* pnData);
unsigned int SetByteOrder(unsigned int* pnData);
long long SetByteOrder(long long* pnData);
unsigned long long SetByteOrder(unsigned long long* pnData);
private:
char* mpData;
std::vector<char*> mpComponentData;
std::vector<char*> mp2DData;
std::vector<char*> mp2DLinData;
std::vector<char*> mpImageData;
std::vector<char*> mpAnalogData;
std::vector<char*> mpAnalogSingleData;
std::vector<char*> mpForceData;
std::vector<char*> mpForceSingleData;
std::vector<char*> mpGazeVectorData;
std::vector<char*> mpEyeTrackerData;
std::vector<char*> mpTimecodeData;
std::vector<char*> mpSkeletonData;
unsigned int mnComponentCount;
EComponentType meComponentType;
unsigned int mn2DCameraCount;
unsigned int mn2DLinCameraCount;
unsigned int mnImageCameraCount;
unsigned int mnAnalogDeviceCount;
unsigned int mnAnalogSingleDeviceCount;
unsigned int mnForcePlateCount;
unsigned int mnForceSinglePlateCount;
unsigned int mnGazeVectorCount;
unsigned int mnEyeTrackerCount;
unsigned int mnTimecodeCount;
unsigned int mSkeletonCount;
int mnMajorVersion;
int mnMinorVersion;
bool mbBigEndian;
}; // RTPacket
#endif // RTPACKET_H