DI_CH08_1_0.cpp
Go to the documentation of this file.
1 #include "DI_CH08_1_0.h"
2 
3 /* Macros are used for performing endianess corrections; these might be replaced with compiler- or machine-dependent equivalents */
4 #define IFM_SWAP16(b) {ifm_o3m_uint8_t tmp = (b)[0]; (b)[0] = (b)[1]; (b)[1] = tmp; }
5 #define IFM_SWAP32(b) {ifm_o3m_uint8_t tmp = (b)[0]; (b)[0] = (b)[3]; (b)[3] = tmp; tmp = (b)[1]; (b)[1] = (b)[2]; (b)[2] = tmp; }
6 #define IFM_SWAP64(b) {ifm_o3m_uint8_t tmp = (b)[0]; (b)[0] = (b)[7]; (b)[7] = tmp; tmp = (b)[1]; (b)[1] = (b)[6]; (b)[6] = tmp; tmp = (b)[2]; (b)[2] = (b)[5]; (b)[5] = tmp; tmp = (b)[3]; (b)[3] = (b)[4]; (b)[4] = tmp; }
7 
8 /* Casts the buffer to ifm_o3m_AlgoIFOutput_DIA1_1_0 (if possible) and returns a pointer to it.
9  Use this function on little Endian systems.
10 
11  Returns NULL in case of errors. */
13 {
15  if( (!buffer) || (bufferSize != 18900) || (sizeof(ifm_o3m_AlgoIFOutput_DIA1_1_0) != 18900) )
16  {
17  return 0;
18  }
19 
20  return res;
21 }
22 
23 /* Converts the endianess of the buffer to native form and returns a pointer to ifm_o3m_AlgoIFOutput_DIA1_1_0.
24  Note: The original buffer is modified in place.
25  Use this function on big Endian systems.
26 
27  Returns NULL in case of errors. */
29 {
31  ifm_o3m_uint8_t *buf = (ifm_o3m_uint8_t *)buffer;
33  if( (!buffer) || (bufferSize != 18900) || (sizeof(ifm_o3m_AlgoIFOutput_DIA1_1_0) != 18900) )
34  {
35  return 0;
36  }
37 
38  /* distanceImageResult.sensorWidth */
39  IFM_SWAP16(&buf[0]);
40  /* distanceImageResult.sensorHeight */
41  IFM_SWAP16(&buf[2]);
42  /* distanceImageResult.distanceData */
43  for(i = 0; i < 1024; i++)
44  {
45  IFM_SWAP16(&buf[(i*2)+4]);
46  }
47  /* distanceImageResult.X */
48  for(i = 0; i < 1024; i++)
49  {
50  IFM_SWAP32(&buf[(i*4)+2052]);
51  }
52  /* distanceImageResult.Y */
53  for(i = 0; i < 1024; i++)
54  {
55  IFM_SWAP32(&buf[(i*4)+6148]);
56  }
57  /* distanceImageResult.Z */
58  for(i = 0; i < 1024; i++)
59  {
60  IFM_SWAP32(&buf[(i*4)+10244]);
61  }
62  /* distanceImageResult.confidence */
63  for(i = 0; i < 1024; i++)
64  {
65  IFM_SWAP16(&buf[(i*2)+14340]);
66  }
67  /* distanceImageResult.amplitude */
68  for(i = 0; i < 1024; i++)
69  {
70  IFM_SWAP16(&buf[(i*2)+16388]);
71  }
72  /* distanceImageResult.amplitude_normalization */
73  for(i = 0; i < 4; i++)
74  {
75  IFM_SWAP32(&buf[(i*4)+18436]);
76  }
77  /* distanceImageResult.masterclockTimestamp */
78  IFM_SWAP32(&buf[18452]);
79  /* distanceImageResult.frameCounter */
80  IFM_SWAP32(&buf[18456]);
81  /* distanceImageResult.available */
82  IFM_SWAP32(&buf[18460]);
83  /* distanceImageResult.cameraCalibration.transX */
84  IFM_SWAP32(&buf[18464]);
85  /* distanceImageResult.cameraCalibration.transY */
86  IFM_SWAP32(&buf[18468]);
87  /* distanceImageResult.cameraCalibration.transZ */
88  IFM_SWAP32(&buf[18472]);
89  /* distanceImageResult.cameraCalibration.rotX */
90  IFM_SWAP32(&buf[18476]);
91  /* distanceImageResult.cameraCalibration.rotY */
92  IFM_SWAP32(&buf[18480]);
93  /* distanceImageResult.cameraCalibration.rotZ */
94  IFM_SWAP32(&buf[18484]);
95  /* distanceImageResult.fieldOfView.upperLeft */
96  for(i = 0; i < 3; i++)
97  {
98  IFM_SWAP32(&buf[(i*4)+18488]);
99  }
100  /* distanceImageResult.fieldOfView.upperRight */
101  for(i = 0; i < 3; i++)
102  {
103  IFM_SWAP32(&buf[(i*4)+18500]);
104  }
105  /* distanceImageResult.fieldOfView.lowerLeft */
106  for(i = 0; i < 3; i++)
107  {
108  IFM_SWAP32(&buf[(i*4)+18512]);
109  }
110  /* distanceImageResult.fieldOfView.lowerRight */
111  for(i = 0; i < 3; i++)
112  {
113  IFM_SWAP32(&buf[(i*4)+18524]);
114  }
115  /* calibrationResult.pacValid */
116  IFM_SWAP32(&buf[18536]);
117  /* calibrationResult.pacResult.transX */
118  IFM_SWAP32(&buf[18540]);
119  /* calibrationResult.pacResult.transY */
120  IFM_SWAP32(&buf[18544]);
121  /* calibrationResult.pacResult.transZ */
122  IFM_SWAP32(&buf[18548]);
123  /* calibrationResult.pacResult.rotX */
124  IFM_SWAP32(&buf[18552]);
125  /* calibrationResult.pacResult.rotY */
126  IFM_SWAP32(&buf[18556]);
127  /* calibrationResult.pacResult.rotZ */
128  IFM_SWAP32(&buf[18560]);
129  /* calibrationResult.triangleDetections.score */
130  for(i = 0; i < 8; i++)
131  {
132  IFM_SWAP32(&buf[(i*40)+18568]);
133  }
134  /* calibrationResult.triangleDetections.pos3D */
135  for(i = 0; i < 3; i++)
136  {
137  IFM_SWAP32(&buf[(i*4)+18572]);
138  }
139  for(i = 0; i < 3; i++)
140  {
141  IFM_SWAP32(&buf[(i*4)+18612]);
142  }
143  for(i = 0; i < 3; i++)
144  {
145  IFM_SWAP32(&buf[(i*4)+18652]);
146  }
147  for(i = 0; i < 3; i++)
148  {
149  IFM_SWAP32(&buf[(i*4)+18692]);
150  }
151  for(i = 0; i < 3; i++)
152  {
153  IFM_SWAP32(&buf[(i*4)+18732]);
154  }
155  for(i = 0; i < 3; i++)
156  {
157  IFM_SWAP32(&buf[(i*4)+18772]);
158  }
159  for(i = 0; i < 3; i++)
160  {
161  IFM_SWAP32(&buf[(i*4)+18812]);
162  }
163  for(i = 0; i < 3; i++)
164  {
165  IFM_SWAP32(&buf[(i*4)+18852]);
166  }
167  /* calibrationResult.triangleDetections.corners */
168  for(i = 0; i < 6; i++)
169  {
170  IFM_SWAP32(&buf[(i*4)+18584]);
171  }
172  for(i = 0; i < 6; i++)
173  {
174  IFM_SWAP32(&buf[(i*4)+18624]);
175  }
176  for(i = 0; i < 6; i++)
177  {
178  IFM_SWAP32(&buf[(i*4)+18664]);
179  }
180  for(i = 0; i < 6; i++)
181  {
182  IFM_SWAP32(&buf[(i*4)+18704]);
183  }
184  for(i = 0; i < 6; i++)
185  {
186  IFM_SWAP32(&buf[(i*4)+18744]);
187  }
188  for(i = 0; i < 6; i++)
189  {
190  IFM_SWAP32(&buf[(i*4)+18784]);
191  }
192  for(i = 0; i < 6; i++)
193  {
194  IFM_SWAP32(&buf[(i*4)+18824]);
195  }
196  for(i = 0; i < 6; i++)
197  {
198  IFM_SWAP32(&buf[(i*4)+18864]);
199  }
200  /* calibrationResult.frameValid */
201  IFM_SWAP32(&buf[18888]);
202  /* calibrationResult.frameReprojectError */
203  IFM_SWAP32(&buf[18892]);
204  /* calibrationResult.calibrationStableCounter */
205  IFM_SWAP32(&buf[18896]);
206 
207  return res;
208 }
unsigned int ifm_o3m_uint32_t
Definition: ifm_types.h:7
ifm_o3m_AlgoIFOutput_DIA1_1_0 * ifm_o3m_ConvertBufferToBigEndian_DIA1_1_0(void *buffer, ifm_o3m_uint32_t bufferSize)
Definition: DI_CH08_1_0.cpp:28
#define IFM_SWAP16(b)
Definition: DI_CH08_1_0.cpp:4
ifm_o3m_AlgoIFOutput_DIA1_1_0 * ifm_o3m_ConvertBufferToLittleEndian_DIA1_1_0(void *buffer, ifm_o3m_uint32_t bufferSize)
Definition: DI_CH08_1_0.cpp:12
#define IFM_SWAP32(b)
Definition: DI_CH08_1_0.cpp:5
unsigned char ifm_o3m_uint8_t
Definition: ifm_types.h:1


ifm_o3mxxx
Author(s):
autogenerated on Mon Jun 10 2019 13:34:12