DI_CH08_1_2.cpp
Go to the documentation of this file.
1 #include "DI_CH08_1_2.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_2 (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 != 19044) || (sizeof(ifm_o3m_AlgoIFOutput_DIA1_1_2) != 19044) )
16  {
17  return 0;
18  }
19  if ( ! ( (res->magic_no[0] == 'O' ) && (res->magic_no[1] == '3' ) && (res->magic_no[2] == 'M' ) && (res->magic_no[3] == '!') &&
20  (res->struct_id[0] == 'D') && (res->struct_id[1] == 'I') && (res->struct_id[2] == 'A') && (res->struct_id[3] == '1') &&
21  (res->version[0] == 1) && (res->version[1] == 2 ) ) )
22  {
23  return 0;
24  }
25 
26  return res;
27 }
28 
29 /* Converts the endianess of the buffer to native form and returns a pointer to ifm_o3m_AlgoIFOutput_DIA1_1_2.
30  Note: The original buffer is modified in place.
31  Use this function on big Endian systems.
32 
33  Returns NULL in case of errors. */
35 {
37  ifm_o3m_uint8_t *buf = (ifm_o3m_uint8_t *)buffer;
39  if( (!buffer) || (bufferSize != 19044) || (sizeof(ifm_o3m_AlgoIFOutput_DIA1_1_2) != 19044) )
40  {
41  return 0;
42  }
43  if ( ! ( (res->magic_no[0] == 'O' ) && (res->magic_no[1] == '3' ) && (res->magic_no[2] == 'M' ) && (res->magic_no[3] == '!') &&
44  (res->struct_id[0] == 'D') && (res->struct_id[1] == 'I') && (res->struct_id[2] == 'A') && (res->struct_id[3] == '1') &&
45  (res->version[0] == 1) && (res->version[1] == 2 ) ) )
46  {
47  return 0;
48  }
49 
50  /* distanceImageResult.sensorWidth */
51  IFM_SWAP16(&buf[12]);
52  /* distanceImageResult.sensorHeight */
53  IFM_SWAP16(&buf[14]);
54  /* distanceImageResult.distanceData */
55  for(i = 0; i < 1024; i++)
56  {
57  IFM_SWAP16(&buf[(i*2)+16]);
58  }
59  /* distanceImageResult.X */
60  for(i = 0; i < 1024; i++)
61  {
62  IFM_SWAP32(&buf[(i*4)+2064]);
63  }
64  /* distanceImageResult.Y */
65  for(i = 0; i < 1024; i++)
66  {
67  IFM_SWAP32(&buf[(i*4)+6160]);
68  }
69  /* distanceImageResult.Z */
70  for(i = 0; i < 1024; i++)
71  {
72  IFM_SWAP32(&buf[(i*4)+10256]);
73  }
74  /* distanceImageResult.confidence */
75  for(i = 0; i < 1024; i++)
76  {
77  IFM_SWAP16(&buf[(i*2)+14352]);
78  }
79  /* distanceImageResult.amplitude */
80  for(i = 0; i < 1024; i++)
81  {
82  IFM_SWAP16(&buf[(i*2)+16400]);
83  }
84  /* distanceImageResult.amplitude_normalization */
85  for(i = 0; i < 4; i++)
86  {
87  IFM_SWAP32(&buf[(i*4)+18448]);
88  }
89  /* distanceImageResult.masterclockTimestamp */
90  IFM_SWAP32(&buf[18464]);
91  /* distanceImageResult.frameCounter */
92  IFM_SWAP32(&buf[18468]);
93  /* distanceImageResult.available */
94  IFM_SWAP32(&buf[18472]);
95  /* distanceImageResult.cameraCalibration.transX */
96  IFM_SWAP32(&buf[18476]);
97  /* distanceImageResult.cameraCalibration.transY */
98  IFM_SWAP32(&buf[18480]);
99  /* distanceImageResult.cameraCalibration.transZ */
100  IFM_SWAP32(&buf[18484]);
101  /* distanceImageResult.cameraCalibration.rotX */
102  IFM_SWAP32(&buf[18488]);
103  /* distanceImageResult.cameraCalibration.rotY */
104  IFM_SWAP32(&buf[18492]);
105  /* distanceImageResult.cameraCalibration.rotZ */
106  IFM_SWAP32(&buf[18496]);
107  /* distanceImageResult.fieldOfView.upperLeft */
108  for(i = 0; i < 3; i++)
109  {
110  IFM_SWAP32(&buf[(i*4)+18500]);
111  }
112  /* distanceImageResult.fieldOfView.upperRight */
113  for(i = 0; i < 3; i++)
114  {
115  IFM_SWAP32(&buf[(i*4)+18512]);
116  }
117  /* distanceImageResult.fieldOfView.lowerLeft */
118  for(i = 0; i < 3; i++)
119  {
120  IFM_SWAP32(&buf[(i*4)+18524]);
121  }
122  /* distanceImageResult.fieldOfView.lowerRight */
123  for(i = 0; i < 3; i++)
124  {
125  IFM_SWAP32(&buf[(i*4)+18536]);
126  }
127  /* distanceImageResult.intrExtrCalib_2d.intrCalib_2D_fx */
128  IFM_SWAP32(&buf[18548]);
129  /* distanceImageResult.intrExtrCalib_2d.intrCalib_2D_fy */
130  IFM_SWAP32(&buf[18552]);
131  /* distanceImageResult.intrExtrCalib_2d.intrCalib_2D_mx */
132  IFM_SWAP32(&buf[18556]);
133  /* distanceImageResult.intrExtrCalib_2d.intrCalib_2D_my */
134  IFM_SWAP32(&buf[18560]);
135  /* distanceImageResult.intrExtrCalib_2d.intrCalib_alpha */
136  IFM_SWAP32(&buf[18564]);
137  /* distanceImageResult.intrExtrCalib_2d.intrCalib_k1 */
138  IFM_SWAP32(&buf[18568]);
139  /* distanceImageResult.intrExtrCalib_2d.intrCalib_k2 */
140  IFM_SWAP32(&buf[18572]);
141  /* distanceImageResult.intrExtrCalib_2d.intrCalib_k5 */
142  IFM_SWAP32(&buf[18576]);
143  /* distanceImageResult.intrExtrCalib_2d.intrCalib_k3 */
144  IFM_SWAP32(&buf[18580]);
145  /* distanceImageResult.intrExtrCalib_2d.intrCalib_k4 */
146  IFM_SWAP32(&buf[18584]);
147  /* distanceImageResult.intrExtrCalib_2d.extrCalib_center_tx */
148  IFM_SWAP32(&buf[18588]);
149  /* distanceImageResult.intrExtrCalib_2d.extrCalib_center_ty */
150  IFM_SWAP32(&buf[18592]);
151  /* distanceImageResult.intrExtrCalib_2d.extrCalib_center_tz */
152  IFM_SWAP32(&buf[18596]);
153  /* distanceImageResult.intrExtrCalib_2d.extrCalib_delta_tx */
154  IFM_SWAP32(&buf[18600]);
155  /* distanceImageResult.intrExtrCalib_2d.extrCalib_delta_ty */
156  IFM_SWAP32(&buf[18604]);
157  /* distanceImageResult.intrExtrCalib_2d.extrCalib_delta_tz */
158  IFM_SWAP32(&buf[18608]);
159  /* distanceImageResult.intrExtrCalib_2d.extrCalib_rot_x */
160  IFM_SWAP32(&buf[18612]);
161  /* distanceImageResult.intrExtrCalib_2d.extrCalib_rot_y */
162  IFM_SWAP32(&buf[18616]);
163  /* distanceImageResult.intrExtrCalib_2d.extrCalib_rot_z */
164  IFM_SWAP32(&buf[18620]);
165  /* distanceImageResult.illuPosition */
166  for(i = 0; i < 3; i++)
167  {
168  IFM_SWAP32(&buf[(i*4)+18624]);
169  }
170  /* distanceImageResult.blockageRatio */
171  IFM_SWAP32(&buf[18636]);
172  /* calibrationResult.commonCalibrationResult.calibValid */
173  IFM_SWAP32(&buf[18644]);
174  /* calibrationResult.commonCalibrationResult.calibrationStableCounter */
175  IFM_SWAP32(&buf[18648]);
176  /* calibrationResult.commonCalibrationResult.calibResult.transX */
177  IFM_SWAP32(&buf[18652]);
178  /* calibrationResult.commonCalibrationResult.calibResult.transY */
179  IFM_SWAP32(&buf[18656]);
180  /* calibrationResult.commonCalibrationResult.calibResult.transZ */
181  IFM_SWAP32(&buf[18660]);
182  /* calibrationResult.commonCalibrationResult.calibResult.rotX */
183  IFM_SWAP32(&buf[18664]);
184  /* calibrationResult.commonCalibrationResult.calibResult.rotY */
185  IFM_SWAP32(&buf[18668]);
186  /* calibrationResult.commonCalibrationResult.calibResult.rotZ */
187  IFM_SWAP32(&buf[18672]);
188  /* calibrationResult.pacCalibrationResult.triangleDetections.score */
189  for(i = 0; i < 8; i++)
190  {
191  IFM_SWAP32(&buf[(i*40)+18680]);
192  }
193  /* calibrationResult.pacCalibrationResult.triangleDetections.pos3D */
194  for(i = 0; i < 3; i++)
195  {
196  IFM_SWAP32(&buf[(i*4)+18684]);
197  }
198  for(i = 0; i < 3; i++)
199  {
200  IFM_SWAP32(&buf[(i*4)+18724]);
201  }
202  for(i = 0; i < 3; i++)
203  {
204  IFM_SWAP32(&buf[(i*4)+18764]);
205  }
206  for(i = 0; i < 3; i++)
207  {
208  IFM_SWAP32(&buf[(i*4)+18804]);
209  }
210  for(i = 0; i < 3; i++)
211  {
212  IFM_SWAP32(&buf[(i*4)+18844]);
213  }
214  for(i = 0; i < 3; i++)
215  {
216  IFM_SWAP32(&buf[(i*4)+18884]);
217  }
218  for(i = 0; i < 3; i++)
219  {
220  IFM_SWAP32(&buf[(i*4)+18924]);
221  }
222  for(i = 0; i < 3; i++)
223  {
224  IFM_SWAP32(&buf[(i*4)+18964]);
225  }
226  /* calibrationResult.pacCalibrationResult.triangleDetections.corners */
227  for(i = 0; i < 6; i++)
228  {
229  IFM_SWAP32(&buf[(i*4)+18696]);
230  }
231  for(i = 0; i < 6; i++)
232  {
233  IFM_SWAP32(&buf[(i*4)+18736]);
234  }
235  for(i = 0; i < 6; i++)
236  {
237  IFM_SWAP32(&buf[(i*4)+18776]);
238  }
239  for(i = 0; i < 6; i++)
240  {
241  IFM_SWAP32(&buf[(i*4)+18816]);
242  }
243  for(i = 0; i < 6; i++)
244  {
245  IFM_SWAP32(&buf[(i*4)+18856]);
246  }
247  for(i = 0; i < 6; i++)
248  {
249  IFM_SWAP32(&buf[(i*4)+18896]);
250  }
251  for(i = 0; i < 6; i++)
252  {
253  IFM_SWAP32(&buf[(i*4)+18936]);
254  }
255  for(i = 0; i < 6; i++)
256  {
257  IFM_SWAP32(&buf[(i*4)+18976]);
258  }
259  /* calibrationResult.pacCalibrationResult.frameValid */
260  IFM_SWAP32(&buf[19000]);
261  /* calibrationResult.pacCalibrationResult.frameReprojectError */
262  IFM_SWAP32(&buf[19004]);
263  /* calibrationResult.streetCalibrationResult.planeValid */
264  IFM_SWAP32(&buf[19008]);
265  /* calibrationResult.streetCalibrationResult.planeEstimation.pitchAngle */
266  IFM_SWAP32(&buf[19012]);
267  /* calibrationResult.streetCalibrationResult.planeEstimation.rollAngle */
268  IFM_SWAP32(&buf[19016]);
269  /* calibrationResult.streetCalibrationResult.planeEstimation.camHeight */
270  IFM_SWAP32(&buf[19020]);
271  /* calibrationResult.streetCalibrationResult.planeEstimation.normalx */
272  IFM_SWAP32(&buf[19024]);
273  /* calibrationResult.streetCalibrationResult.planeEstimation.normaly */
274  IFM_SWAP32(&buf[19028]);
275  /* calibrationResult.streetCalibrationResult.planeEstimation.normalz */
276  IFM_SWAP32(&buf[19032]);
277  /* calibrationResult.streetCalibrationResult.plausibility */
278  IFM_SWAP32(&buf[19036]);
279  /* calibrationResult.streetCalibrationResult.distanceDeviation */
280  IFM_SWAP32(&buf[19040]);
281 
282  return res;
283 }
unsigned int ifm_o3m_uint32_t
Definition: ifm_types.h:7
ifm_o3m_AlgoIFOutput_DIA1_1_2 * ifm_o3m_ConvertBufferToBigEndian_DIA1_1_2(void *buffer, ifm_o3m_uint32_t bufferSize)
Definition: DI_CH08_1_2.cpp:34
ifm_o3m_sint8_t struct_id[4]
Definition: DI_CH08_1_2.h:19
#define IFM_SWAP16(b)
Definition: DI_CH08_1_2.cpp:4
ifm_o3m_uint8_t version[2]
Definition: DI_CH08_1_2.h:20
#define IFM_SWAP32(b)
Definition: DI_CH08_1_2.cpp:5
ifm_o3m_sint8_t magic_no[4]
Definition: DI_CH08_1_2.h:18
unsigned char ifm_o3m_uint8_t
Definition: ifm_types.h:1
ifm_o3m_AlgoIFOutput_DIA1_1_2 * ifm_o3m_ConvertBufferToLittleEndian_DIA1_1_2(void *buffer, ifm_o3m_uint32_t bufferSize)
Definition: DI_CH08_1_2.cpp:12


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