DI_CH08_1_1.cpp
Go to the documentation of this file.
1 #include "DI_CH08_1_1.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_1 (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 != 19036) || (sizeof(ifm_o3m_AlgoIFOutput_DIA1_1_1) != 19036) )
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] == 1 ) ) )
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_1.
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 != 19036) || (sizeof(ifm_o3m_AlgoIFOutput_DIA1_1_1) != 19036) )
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] == 1 ) ) )
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  /* calibrationResult.commonCalibrationResult.calibValid */
171  IFM_SWAP32(&buf[18636]);
172  /* calibrationResult.commonCalibrationResult.calibrationStableCounter */
173  IFM_SWAP32(&buf[18640]);
174  /* calibrationResult.commonCalibrationResult.calibResult.transX */
175  IFM_SWAP32(&buf[18644]);
176  /* calibrationResult.commonCalibrationResult.calibResult.transY */
177  IFM_SWAP32(&buf[18648]);
178  /* calibrationResult.commonCalibrationResult.calibResult.transZ */
179  IFM_SWAP32(&buf[18652]);
180  /* calibrationResult.commonCalibrationResult.calibResult.rotX */
181  IFM_SWAP32(&buf[18656]);
182  /* calibrationResult.commonCalibrationResult.calibResult.rotY */
183  IFM_SWAP32(&buf[18660]);
184  /* calibrationResult.commonCalibrationResult.calibResult.rotZ */
185  IFM_SWAP32(&buf[18664]);
186  /* calibrationResult.pacCalibrationResult.triangleDetections.score */
187  for(i = 0; i < 8; i++)
188  {
189  IFM_SWAP32(&buf[(i*40)+18672]);
190  }
191  /* calibrationResult.pacCalibrationResult.triangleDetections.pos3D */
192  for(i = 0; i < 3; i++)
193  {
194  IFM_SWAP32(&buf[(i*4)+18676]);
195  }
196  for(i = 0; i < 3; i++)
197  {
198  IFM_SWAP32(&buf[(i*4)+18716]);
199  }
200  for(i = 0; i < 3; i++)
201  {
202  IFM_SWAP32(&buf[(i*4)+18756]);
203  }
204  for(i = 0; i < 3; i++)
205  {
206  IFM_SWAP32(&buf[(i*4)+18796]);
207  }
208  for(i = 0; i < 3; i++)
209  {
210  IFM_SWAP32(&buf[(i*4)+18836]);
211  }
212  for(i = 0; i < 3; i++)
213  {
214  IFM_SWAP32(&buf[(i*4)+18876]);
215  }
216  for(i = 0; i < 3; i++)
217  {
218  IFM_SWAP32(&buf[(i*4)+18916]);
219  }
220  for(i = 0; i < 3; i++)
221  {
222  IFM_SWAP32(&buf[(i*4)+18956]);
223  }
224  /* calibrationResult.pacCalibrationResult.triangleDetections.corners */
225  for(i = 0; i < 6; i++)
226  {
227  IFM_SWAP32(&buf[(i*4)+18688]);
228  }
229  for(i = 0; i < 6; i++)
230  {
231  IFM_SWAP32(&buf[(i*4)+18728]);
232  }
233  for(i = 0; i < 6; i++)
234  {
235  IFM_SWAP32(&buf[(i*4)+18768]);
236  }
237  for(i = 0; i < 6; i++)
238  {
239  IFM_SWAP32(&buf[(i*4)+18808]);
240  }
241  for(i = 0; i < 6; i++)
242  {
243  IFM_SWAP32(&buf[(i*4)+18848]);
244  }
245  for(i = 0; i < 6; i++)
246  {
247  IFM_SWAP32(&buf[(i*4)+18888]);
248  }
249  for(i = 0; i < 6; i++)
250  {
251  IFM_SWAP32(&buf[(i*4)+18928]);
252  }
253  for(i = 0; i < 6; i++)
254  {
255  IFM_SWAP32(&buf[(i*4)+18968]);
256  }
257  /* calibrationResult.pacCalibrationResult.frameValid */
258  IFM_SWAP32(&buf[18992]);
259  /* calibrationResult.pacCalibrationResult.frameReprojectError */
260  IFM_SWAP32(&buf[18996]);
261  /* calibrationResult.streetCalibrationResult.planeValid */
262  IFM_SWAP32(&buf[19000]);
263  /* calibrationResult.streetCalibrationResult.planeEstimation.pitchAngle */
264  IFM_SWAP32(&buf[19004]);
265  /* calibrationResult.streetCalibrationResult.planeEstimation.rollAngle */
266  IFM_SWAP32(&buf[19008]);
267  /* calibrationResult.streetCalibrationResult.planeEstimation.camHeight */
268  IFM_SWAP32(&buf[19012]);
269  /* calibrationResult.streetCalibrationResult.planeEstimation.normalx */
270  IFM_SWAP32(&buf[19016]);
271  /* calibrationResult.streetCalibrationResult.planeEstimation.normaly */
272  IFM_SWAP32(&buf[19020]);
273  /* calibrationResult.streetCalibrationResult.planeEstimation.normalz */
274  IFM_SWAP32(&buf[19024]);
275  /* calibrationResult.streetCalibrationResult.plausibility */
276  IFM_SWAP32(&buf[19028]);
277  /* calibrationResult.streetCalibrationResult.distanceDeviation */
278  IFM_SWAP32(&buf[19032]);
279 
280  return res;
281 }
ifm_o3m_AlgoIFOutput_DIA1_1_1 * ifm_o3m_ConvertBufferToBigEndian_DIA1_1_1(void *buffer, ifm_o3m_uint32_t bufferSize)
Definition: DI_CH08_1_1.cpp:34
unsigned int ifm_o3m_uint32_t
Definition: ifm_types.h:7
#define IFM_SWAP16(b)
Definition: DI_CH08_1_1.cpp:4
ifm_o3m_sint8_t struct_id[4]
Definition: DI_CH08_1_1.h:19
ifm_o3m_uint8_t version[2]
Definition: DI_CH08_1_1.h:20
#define IFM_SWAP32(b)
Definition: DI_CH08_1_1.cpp:5
ifm_o3m_sint8_t magic_no[4]
Definition: DI_CH08_1_1.h:18
unsigned char ifm_o3m_uint8_t
Definition: ifm_types.h:1
ifm_o3m_AlgoIFOutput_DIA1_1_1 * ifm_o3m_ConvertBufferToLittleEndian_DIA1_1_1(void *buffer, ifm_o3m_uint32_t bufferSize)
Definition: DI_CH08_1_1.cpp:12


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