ParticleFilterRobotHandLocalisation.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of ArmarX.
3  *
4  * Copyright (C) 2011-2016, High Performance Humanoid Technologies (H2T), Karlsruhe Institute of Technology (KIT), all rights reserved.
5  *
6  * ArmarX is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation.
9  *
10  * ArmarX is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  *
18  * @package
19  * @author
20  * @date
21  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
22  * GNU General Public License
23  */
25 
26 
27 #include <cfloat>
28 
29 
30 namespace visionx
31 {
32  //******************************************************************************************************************
33  // Constructor and destructor
34  //******************************************************************************************************************
35 
36  // constructor
37  CParticleFilterRobotHandLocalisation::CParticleFilterRobotHandLocalisation(int nParticles, int nDimension, int nNumParallelThreads, CStereoCalibration* pCalibration, std::string sHandModelFileName) :
38  CParticleFilterFrameworkParallelized(nParticles, nDimension, nNumParallelThreads)
39  {
40  // set hand model
42  for (int i = 0; i < m_nNumParallelThreads; i++)
43  {
44 #ifdef DSHT_USE_ICUB
45  m_pHandModels[i] = new HandModeliCub(sHandModelFileName, pCalibration);
46 #else
47  m_pHandModels[i] = new CHandModelV2(sHandModelFileName, pCalibration);
48 #endif
49  }
50 
51  // init array for the sensor values and the allowed deviation
52  sensor_config = new double[nDimension];
53  allowed_deviation = new double[nDimension];
54 
55 
57 
58 
59  // init array of preliminary probabilities
60  m_ppProbabilities = new double*[NUMBER_OF_CUES];
61  for (int i = 0; i < NUMBER_OF_CUES; i++)
62  {
63  m_ppProbabilities[i] = new double[m_nParticles];
64  }
65 
66 
67 
68  c_total = 1; // c_total is sum of all pi. c[i] is the sum of all p[j] with j<=i.
69  // It is used to pick the random samples for the recalculation of the particles
70 
71 
72 
73  // init spaces for temporary stuff
79  for (int i = 0; i < m_nNumParallelThreads; i++)
80  {
86  }
87  }
88 
89 
90 
91 
92  // Destructor
94  {
95  for (int i = 0; i < NUMBER_OF_CUES; i++)
96  {
97  delete [] m_ppProbabilities[i];
98  }
99  delete [] m_ppProbabilities;
100 
101  for (int i = 0; i < m_nNumParallelThreads; i++)
102  {
103  delete m_pTempIntersectionPolygons[i];
104  delete m_pTempVecArrays[i];
105  delete m_pTempClockwiseHullPolys1[i];
106  delete m_pTempClockwiseHullPolys2[i];
107  delete m_pTempBoolArrays[i];
108  }
110  delete[] m_pTempVecArrays;
113  delete[] m_pTempBoolArrays;
114 
115  delete[] sensor_config;
116  delete[] allowed_deviation;
117  }
118 
119 
120 
121 
122 
123 
124  //******************************************************************************************************************
125  // Set and change configurations of the particle filter
126  //******************************************************************************************************************
127 
128 
129  void CParticleFilterRobotHandLocalisation::SetImages(CByteImage* pRegionImageLeft, CByteImage* pRegionImageRight, CByteImage* pSobelImageLeft, CByteImage* pSobelImageRight,
130  CByteImage* pSobelXImageLeft, CByteImage* pSobelXImageRight, CByteImage* pSobelYImageLeft, CByteImage* pSobelYImageRight)
131  {
132  // set images
133  m_pRegionImageLeft = pRegionImageLeft;
134  m_pRegionImageRight = pRegionImageRight;
135  m_pSobelImageLeft = pSobelImageLeft;
136  m_pSobelImageRight = pSobelImageRight;
137  m_pSobelXImageLeft = pSobelXImageLeft;
138  m_pSobelXImageRight = pSobelXImageRight;
139  m_pSobelYImageLeft = pSobelYImageLeft;
140  m_pSobelYImageRight = pSobelYImageRight;
141  }
142 
143 
144  // set the configuration of the particles
146  {
147  for (int i = 0; i < m_nParticles; i++)
148  for (int j = 0; j < m_nDimension; j++)
149  {
150  s[i][j] = pConfig[j];
151  }
152  }
153 
154 
155 
156  // set the configuration of the first half of the particles, the rest is not changed
158  {
159  for (int i = 0; i < m_nParticles / 2; i++)
160  for (int j = 0; j < m_nDimension; j++)
161  {
162  s[i][j] = pConfig[j];
163  }
164  }
165 
166 
167 
168  // set the configuration of ten percent of the particles, the rest is not changed
170  {
171  if (nTenthIndex >= 0 && nTenthIndex <= 9)
172  {
173  for (int i = m_nParticles / 10 * nTenthIndex; i < m_nParticles / 10 * (nTenthIndex + 1); i++)
174  for (int j = 0; j < m_nDimension; j++)
175  {
176  s[i][j] = pConfig[j];
177  }
178  }
179  }
180 
181 
182  // set the array containing the sensor values
184  {
185  for (int i = 0; i < m_nDimension; i++)
186  {
187  sensor_config[i] = sconfig[i];
188  lower_limit[i] = sensor_config[i] - allowed_deviation[i];
189  upper_limit[i] = sensor_config[i] + allowed_deviation[i];
190  }
191 
192  }
193 
194 
195 
196 
197  // set the allowed deviation of the particle configs from the sensor values
199  {
200  for (int i = 0; i < m_nDimension; i++)
201  {
202  allowed_deviation[i] = adeviation[i];
203  sigma[i] = allowed_deviation[i] / 2;
204  }
205  }
206 
207 
208 
209 
210 
211  // set the tracking ball position and size
212  void CParticleFilterRobotHandLocalisation::SetTrackingBallPositions(double* dPosX, double* dPosY, double* dRadius, int nNumTrBallRegions, bool bLeftCamImage)
213  {
214  if (bLeftCamImage)
215  {
216  m_pdTrackingBallPosXLeft = dPosX;
217  m_pdTrackingBallPosYLeft = dPosY;
218  m_pdTrackingBallRadiusLeft = dRadius;
219  m_nNumTrackingBallRegionsLeft = nNumTrBallRegions;
220  }
221  else
222  {
225  m_pdTrackingBallRadiusRight = dRadius;
226  m_nNumTrackingBallRegionsRight = nNumTrBallRegions;
227  }
228  }
229 
230 
231 
232 
233 
234  //******************************************************************************************************************
235  // Update the hand model according to the configuration nParticleIndex
236  //******************************************************************************************************************
237 
238  void CParticleFilterRobotHandLocalisation::UpdateModel(int nParticleIndex, int nModelIndex)
239  {
240  //printf("UpdateModel(%d)\n", nParticleIndex);
241  m_pHandModels[nModelIndex]->UpdateHand(s[nParticleIndex]);
242  }
243 
244 
245 
246 
247 
248 
249  //******************************************************************************************************************
250  // Predict new bases from the old ones. dSigmaFactor will be multiplied with all sigma[i] values
251  //******************************************************************************************************************
252 
254  {
255  //printf("PredictNewBases\n");
256 
257  #pragma omp parallel for
258  for (int nNewIndex = 0; nNewIndex < m_nParticles; nNewIndex++)
259  {
260  int nOldIndex = PickBaseSample();
261 
262  for (int i = 0; i < m_nDimension; i++)
263  {
264  double dNewValue = s[nOldIndex][i] + dSigmaFactor * sigma[i] * gaussian_random();
265  s_temp[nNewIndex][i] = (dNewValue >= lower_limit[i] && dNewValue <= upper_limit[i]) ? dNewValue : (0.7 * 0.5 * (lower_limit[i] + upper_limit[i]) + 0.3 * s[nOldIndex][i] + 0.5 * dSigmaFactor * sigma[i] * gaussian_random());
266 
267  }
268  }
269 
270  // switch old/new
271  double** temp = s_temp;
272  s_temp = s;
273  s = temp;
274 
275  }
276 
277 
278 
279 
280 
281 
282  //******************************************************************************************************************
283  // Functions for the region cue
284  //******************************************************************************************************************
285 
286  // sum up all pixel values of m_pRegionImageLeft that are inside the polygon pol, and count the number
287  // of pixels inside the polygon
288  inline void CParticleFilterRobotHandLocalisation::CalculatePixelSumInPolygon(ConvexPolygonCalculations::Polygon* pol, int& region_sum, int& region_length, bool bLeftCamImage)
289  {
290  CByteImage* pImage = (bLeftCamImage) ? m_pRegionImageLeft : m_pRegionImageRight;
291  const int width = pImage->width;
292 
293  int leftBorderInt, rightBorderInt, up, down, indexLeft, indexRight, indexMain, nTempOffset;
294  float leftBorder = 0, rightBorder = 0, leftOffset = 0, rightOffset = 0;
295 
296  region_sum = 0;
297  region_length = 0;
298 
299  indexLeft = 1;
300  indexRight = 1;
301  for (indexMain = 0; indexMain < pol->nCorners - 1; indexMain++)
302  {
303  if (pol->hull[indexMain].z != 2) // if this is not a right border point, we have
304  {
305  // to change left border and offset
306  leftBorder = pol->hullLeft[indexLeft].x;
307  leftOffset = (pol->hullLeft[indexLeft + 1].x - pol->hullLeft[indexLeft].x) / (pol->hullLeft[indexLeft + 1].y - pol->hullLeft[indexLeft].y);
308  }
309 
310  if (pol->hull[indexMain].z != 1) // if this is not a left border point, we have
311  {
312  // to change right border and offset
313  rightBorder = pol->hullRight[indexRight].x;
314  rightOffset = (pol->hullRight[indexRight + 1].x - pol->hullRight[indexRight].x) / (pol->hullRight[indexRight + 1].y - pol->hullRight[indexRight].y);
315  }
316 
317  up = (int) pol->hull[indexMain].y;
318  down = (int) pol->hull[indexMain + 1].y;
319 
320  if (pol->hull[indexMain + 1].z != 2)
321  {
322  indexLeft ++;
323  }
324  if (pol->hull[indexMain + 1].z != 1)
325  {
326  indexRight ++;
327  }
328 
329  if ((down > DSHT_IMAGE_HEIGHT - 1) || (up < 0))
330  {
331  goto skip_updown; // not in the image
332  }
333 
334  // stay inside image
335  if (down < 0)
336  {
337  down = 0;
338  }
339  if (up > DSHT_IMAGE_HEIGHT - 1)
340  {
341  up = DSHT_IMAGE_HEIGHT - 1;
342  }
343 
344  for (int j = up; j > down; j--, leftBorder -= leftOffset, rightBorder -= rightOffset)
345  {
346  // optim: width/2 sofort dazuaddieren
347  leftBorderInt = (int)leftBorder;
348  rightBorderInt = (int)rightBorder;
349 
350  // stay inside image
351  if ((leftBorderInt > DSHT_IMAGE_WIDTH - 1) || (rightBorderInt < 0))
352  {
353  goto skip_leftright;
354  }
355 
356  if (leftBorderInt < 0)
357  {
358  leftBorderInt = 0;
359  }
360  if (rightBorderInt > DSHT_IMAGE_WIDTH - 1)
361  {
362  rightBorderInt = DSHT_IMAGE_WIDTH - 1;
363  }
364 
365  nTempOffset = j * width;
366 
367  for (int k = leftBorderInt; k < rightBorderInt; k++)
368  {
369  region_sum += pImage->pixels[nTempOffset + k];
370  region_length++;
371  }
372 skip_leftright:
373  ;
374  }
375 skip_updown:
376  ;
377  }
378 
379  }
380 
381 
382 
383 
384 
385 
386  // calculate the region cue
387  void CParticleFilterRobotHandLocalisation::CalculateRegionCue(int& region_sum, int& region_length, int nModelIndex, bool bLeftCamImage)
388  {
389  const int num_polygons = 5;
390  ConvexPolygonCalculations::Polygon* polygons[num_polygons];
391 
392  if (bLeftCamImage)
393  {
394  for (int i = 0; i < num_polygons; i++)
395  {
396  polygons[i] = &m_pHandModels[nModelIndex]->m_aFingerTipPolygonsLeftCam.at(i);
397  }
398  }
399  else
400  {
401  for (int i = 0; i < num_polygons; i++)
402  {
403  polygons[i] = &m_pHandModels[nModelIndex]->m_aFingerTipPolygonsRightCam.at(i);
404  }
405  }
406 
407  region_sum = 0;
408  region_length = 0;
409 
410  int polygon_interior_sum, polygon_interior_size;
411 
412 
413  // sum up the pixels of correct color inside the fingertip polygons
414 
415  for (int i = 0; i < num_polygons; i++)
416  {
417  CalculatePixelSumInPolygon(polygons[i], polygon_interior_sum, polygon_interior_size, bLeftCamImage);
418  region_sum += polygon_interior_sum;
419  region_length += polygon_interior_size;
420  }
421 
422 
423  // subtract intersection regions which may have been counted two times
424 
425  for (int i = 1; i < num_polygons; i++) // thumb with all other fingers
426  {
427  if (PolygonsMightIntersect(polygons[0], polygons[i]))
428  {
429  ConvexPolygonCalculations::GetPolygonIntersection(polygons[0], polygons[i], m_pTempIntersectionPolygons[nModelIndex], m_pTempVecArrays[nModelIndex], m_pTempBoolArrays[nModelIndex], m_pTempClockwiseHullPolys1[nModelIndex], m_pTempClockwiseHullPolys2[nModelIndex]);
430  CalculatePixelSumInPolygon(m_pTempIntersectionPolygons[nModelIndex], polygon_interior_sum, polygon_interior_size, bLeftCamImage);
431  region_sum -= polygon_interior_sum;
432  region_length -= polygon_interior_size;
433  }
434  }
435 
436  for (int i = 1; i < num_polygons - 1; i++) // every other fingers only with its direct neighbour, to reduce
437  {
438  // multiple subtraction of overlapping intersection regions
439  if (PolygonsMightIntersect(polygons[i], polygons[i + 1]))
440  {
441  ConvexPolygonCalculations::GetPolygonIntersection(polygons[i], polygons[i + 1], m_pTempIntersectionPolygons[nModelIndex], m_pTempVecArrays[nModelIndex], m_pTempBoolArrays[nModelIndex], m_pTempClockwiseHullPolys1[nModelIndex], m_pTempClockwiseHullPolys2[nModelIndex]);
442  CalculatePixelSumInPolygon(m_pTempIntersectionPolygons[nModelIndex], polygon_interior_sum, polygon_interior_size, bLeftCamImage);
443  region_sum -= polygon_interior_sum;
444  region_length -= polygon_interior_size;
445  }
446  }
447 
448  // keep index and ringfinger from fusioning
449  if (PolygonsMightIntersect(polygons[1], polygons[3]))
450  {
451  ConvexPolygonCalculations::GetPolygonIntersection(polygons[1], polygons[3], m_pTempIntersectionPolygons[nModelIndex], m_pTempVecArrays[nModelIndex], m_pTempBoolArrays[nModelIndex], m_pTempClockwiseHullPolys1[nModelIndex], m_pTempClockwiseHullPolys2[nModelIndex]);
452  CalculatePixelSumInPolygon(m_pTempIntersectionPolygons[nModelIndex], polygon_interior_sum, polygon_interior_size, bLeftCamImage);
453  region_sum -= polygon_interior_sum;
454  region_length -= polygon_interior_size;
455  }
456 
457  }
458 
459 
460 
461 
462 
463 
464  //******************************************************************************************************************
465  // Functions for the edge cue
466  //******************************************************************************************************************
467 
468  // sum up the pixel values on a sequence of lines
469  inline void CParticleFilterRobotHandLocalisation::CalculatePixelSumOnLineSequence(Vec3d linePoints[], int nPoints, int& edge_sum, int& edge_length, double& angle_diffs, bool bLeftCamImage)
470  {
471  int up, down, left, right, lineSum;
472  double xOffset, xDiff, yOffset, yDiff, lineLength;
473 
474 #ifdef DSHT_USE_EDGE_DIRECTION
475  int absVal;
476  double angleSum, normalX, normalY;
477 #endif // DSHT_USE_EDGE_DIRECTION
478 
479  edge_sum = 0;
480  edge_length = 0;
481  angle_diffs = 0;
482 
483  CByteImage* pImage = (bLeftCamImage) ? m_pSobelImageLeft : m_pSobelImageRight;
484  const int width = pImage->width;
485 
486  for (int i = 0; i < nPoints - 1; i++)
487  {
488  lineSum = 0;
489 
490  lineLength = sqrt((linePoints[i + 1].x - linePoints[i].x) * (linePoints[i + 1].x - linePoints[i].x) + (linePoints[i + 1].y - linePoints[i].y) * (linePoints[i + 1].y - linePoints[i].y));
491 
492 #ifdef DSHT_USE_EDGE_DIRECTION
493  angleSum = 0;
494  normalX = (linePoints[i + 1].y - linePoints[i].y); // / lineLength is not done, because at the end the sum
495  normalY = -(linePoints[i + 1].x - linePoints[i].x); // has to be multiplied with lineLength
496 #endif // DSHT_USE_EDGE_DIRECTION
497 
498  if (linePoints[i].y > linePoints[i + 1].y)
499  {
500  up = (int)linePoints[i].y;
501  down = (int)linePoints[i + 1].y;
502  xOffset = linePoints[i + 1].x;
503  }
504  else
505  {
506  up = (int)linePoints[i + 1].y;
507  down = (int)linePoints[i].y;
508  xOffset = linePoints[i].x;
509  }
510 
511  if (linePoints[i].x > linePoints[i + 1].x)
512  {
513  right = (int)linePoints[i].x;
514  left = (int)linePoints[i + 1].x;
515  yOffset = linePoints[i + 1].y;
516  }
517  else
518  {
519  right = (int)linePoints[i + 1].x;
520  left = (int)linePoints[i].x;
521  yOffset = linePoints[i].y;
522  }
523 
524  if (up < DSHT_IMAGE_HEIGHT && down >= 0 && left >= 0 && right < DSHT_IMAGE_WIDTH)
525  {
526  xDiff = (linePoints[i + 1].x - linePoints[i].x) / (linePoints[i + 1].y - linePoints[i].y);
527  yDiff = (linePoints[i + 1].y - linePoints[i].y) / (linePoints[i + 1].x - linePoints[i].x);
528 
529 #ifdef DSHT_USE_EDGE_DIRECTION
530  for (int j = down; j < up; j++, xOffset += xDiff)
531  {
532  absVal = pImage->pixels[j * width + (int)xOffset];
533  lineSum += absVal;
534  angleSum += abs(((double)pImage->pixels[j * width + (int)xOffset] * normalX + (double)pImage->pixels[j * width + (int)xOffset] * normalY) / ((double)absVal + 0.001));
535  }
536 
537 
538  for (int j = left; j < right; j++, yOffset += yDiff)
539  {
540  absVal = pImage->pixels[((int)yOffset) * width + j];
541  lineSum += absVal;
542  angleSum += abs(((double)pImage->pixels[((int)yOffset) * width + j] * normalX + (double)pImage->pixels[((int)yOffset) * width + j] * normalY) / ((double)absVal + 0.001));
543  }
544 
545  edge_length += (int)lineLength;
546  // set weight congruent to line length
547  edge_sum += (int)((double)lineSum * lineLength / ((double)(up - down + right - left) + 0.001));
548  angle_diffs += angleSum / ((double)(up - down + right - left) + 0.001); // no *lineLength, because no
549  // /linelength done at normal calculation
550 #else
551  for (int j = down; j < up; j++, xOffset += xDiff)
552  {
553  lineSum += pImage->pixels[j * width + (int)xOffset];
554  }
555 
556  for (int j = left; j < right; j++, yOffset += yDiff)
557  {
558  lineSum += pImage->pixels[((int)yOffset) * width + j];
559  }
560 
561  edge_length += (int)lineLength;
562  // set weight congruent to line length
563  edge_sum += (int)((double)lineSum * lineLength / ((double)(up - down + right - left) + 0.001));
564 #endif // DSHT_USE_EDGE_DIRECTION (else)
565  }
566 
567  }
568 
569  }
570 
571 
572 
573 
574  // calculate the edge cue
575  void CParticleFilterRobotHandLocalisation::CalculateEdgeCue(int& edge_sum, int& edge_length, double& angle_diffs, int nModelIndex, bool bLeftCamImage)
576  {
577  const int num_polygons = 5;
578  ConvexPolygonCalculations::Polygon* polygons[num_polygons];
579 
580  if (bLeftCamImage)
581  {
582  for (int i = 0; i < num_polygons; i++)
583  {
584  polygons[i] = &m_pHandModels[nModelIndex]->m_aFingerTipPolygonsLeftCam.at(i);
585  }
586  }
587  else
588  {
589  for (int i = 0; i < num_polygons; i++)
590  {
591  polygons[i] = &m_pHandModels[nModelIndex]->m_aFingerTipPolygonsRightCam.at(i);
592  }
593  }
594 
595  int temp_edge_sum, temp_edge_length;
596  double temp_angle_diffs;
597  edge_sum = 0;
598  edge_length = 0;
599  angle_diffs = 0;
600 
601  for (int i = 0; i < num_polygons; i++)
602  {
603  CalculatePixelSumOnLineSequence(polygons[i]->hullCircle, polygons[i]->nCorners + 1, temp_edge_sum, temp_edge_length, temp_angle_diffs, bLeftCamImage);
604  edge_sum += temp_edge_sum;
605  edge_length += temp_edge_length;
606  angle_diffs += temp_angle_diffs;
607  }
608 
609  }
610 
611 
612 
613 
614 
615 
616  //******************************************************************************************************************
617  // Calculate error distance to tracking ball
618  //******************************************************************************************************************
619 
620 
621  // calculate error distance to tracking ball
622  void CParticleFilterRobotHandLocalisation::CalculateTrackingBallCue(double& dDistanceXY, double& dDistanceZ, int nModelIndex)
623  {
624  double dPosX, dPosY, dRadius;
625 
626  double dMinDistance;
627  int nMinIndex;
628  double dTempDist;
629 
630 
631  // left image
632 
633  dPosX = m_pHandModels[nModelIndex]->m_vTrackingBallPosLeftCam.x;
634  dPosY = m_pHandModels[nModelIndex]->m_vTrackingBallPosLeftCam.y;
635  dRadius = m_pHandModels[nModelIndex]->m_fTrackingBallRadiusLeftCam;
636 
637  nMinIndex = 0;
638  dMinDistance = 1000000000;
639 
640  for (int i = 0; i < m_nNumTrackingBallRegionsLeft; i++)
641  {
642  dTempDist = (m_pdTrackingBallPosXLeft[i] - dPosX) * (m_pdTrackingBallPosXLeft[i] - dPosX)
643  + (m_pdTrackingBallPosYLeft[i] - dPosY) * (m_pdTrackingBallPosYLeft[i] - dPosY)
644  ;
645  if (dTempDist < dMinDistance)
646  {
647  dMinDistance = dTempDist;
648  nMinIndex = i;
649  }
650  }
651 
652  dDistanceXY = sqrt((m_pdTrackingBallPosXLeft[nMinIndex] - dPosX) * (m_pdTrackingBallPosXLeft[nMinIndex] - dPosX)
653  + (m_pdTrackingBallPosYLeft[nMinIndex] - dPosY) * (m_pdTrackingBallPosYLeft[nMinIndex] - dPosY)
654  );
655 
656  dDistanceZ = fabs(1 / m_pdTrackingBallRadiusLeft[nMinIndex] - 1 / dRadius);
657  if (std::isnan(dDistanceZ))
658  {
659  dDistanceZ = FLT_MAX;
660  }
661 
662 
663 
664  // right image
665 
666  dPosX = m_pHandModels[nModelIndex]->m_vTrackingBallPosRightCam.x;
667  dPosY = m_pHandModels[nModelIndex]->m_vTrackingBallPosRightCam.y;
668  dRadius = m_pHandModels[nModelIndex]->m_fTrackingBallRadiusRightCam;
669 
670  nMinIndex = 0;
671  dMinDistance = 1000000000;
672 
673  for (int i = 0; i < m_nNumTrackingBallRegionsRight; i++)
674  {
675  dTempDist = (m_pdTrackingBallPosXRight[i] - dPosX) * (m_pdTrackingBallPosXRight[i] - dPosX)
676  + (m_pdTrackingBallPosYRight[i] - dPosY) * (m_pdTrackingBallPosYRight[i] - dPosY)
677  ;
678  if (dTempDist < dMinDistance)
679  {
680  dMinDistance = dTempDist;
681  nMinIndex = i;
682  }
683  }
684 
685  // dDistanceXY += sqrt ( (m_pdTrackingBallPosXRight[nMinIndex]-dPosX)*(m_pdTrackingBallPosXRight[nMinIndex]-dPosX)
686  // + (m_pdTrackingBallPosYRight[nMinIndex]-dPosY)*(m_pdTrackingBallPosYRight[nMinIndex]-dPosY)
687  // );
688 
689  // dDistanceZ += fabs(1/m_pdTrackingBallRadiusRight[nMinIndex]-1/dRadius);
690 
691  }
692 
693 
694 
695 
696 
697 
698  //******************************************************************************************************************
699  // Evaluation and rating of the particles
700  //******************************************************************************************************************
701 
702 
703  // calculate the preliminary probabilities for the different cues
704  double CParticleFilterRobotHandLocalisation::CalculateProbability(int nParticleIndex, int nModelIndex)
705  {
706  //printf("CalculateProbability 1\n");
707 
708  int nRegionSumLeftImg, nRegionLengthLeftImg, nEdgeSumLeftImg, nEdgeLengthLeftImg;
709  int nRegionSumRightImg, nRegionLengthRightImg, nEdgeSumRightImg, nEdgeLengthRightImg;
710  double fAngleDiffsLeftImg, fAngleDiffsRightImg;
711 
712  CalculateRegionCue(nRegionSumLeftImg, nRegionLengthLeftImg, nModelIndex, true);
713  CalculateRegionCue(nRegionSumRightImg, nRegionLengthRightImg, nModelIndex, false);
714 
715  //printf("CalculateProbability 2\n");
716 
717  CalculateEdgeCue(nEdgeSumLeftImg, nEdgeLengthLeftImg, fAngleDiffsLeftImg, nModelIndex, true);
718  CalculateEdgeCue(nEdgeSumRightImg, nEdgeLengthRightImg, fAngleDiffsRightImg, nModelIndex, false);
719 
720  double dTrBallDistXY, dTrBallDistZ;
721  CalculateTrackingBallCue(dTrBallDistXY, dTrBallDistZ, nModelIndex);
722 
723  //printf("CalculateProbability 3\n");
724 
725  m_ppProbabilities[0][nParticleIndex] = 0.5 * (nRegionSumLeftImg + nRegionSumRightImg);
726  m_ppProbabilities[1][nParticleIndex] = (double)(nRegionSumLeftImg + nRegionSumRightImg) / ((double)(nRegionLengthLeftImg + nRegionLengthRightImg) + 0.001);
727 
728  m_ppProbabilities[2][nParticleIndex] = 0.5 * (nEdgeSumLeftImg + nEdgeSumRightImg);
729  m_ppProbabilities[3][nParticleIndex] = (double)(nEdgeSumLeftImg + nEdgeSumRightImg) / ((double)(nEdgeLengthLeftImg + nEdgeLengthRightImg) + 0.001);
730 #ifdef DSHT_USE_EDGE_DIRECTION
731  m_ppProbabilities[4][nParticleIndex] = -(fAngleDiffsLeftImg + fAngleDiffsRightImg) / ((double)(nEdgeLengthLeftImg + nEdgeLengthRightImg) + 0.001); // TODO: find out if sign is correct
732 #else
733  m_ppProbabilities[4][nParticleIndex] = 0;
734 #endif // DSHT_USE_EDGE_DIRECTION
735 
736  m_ppProbabilities[5][nParticleIndex] = - dTrBallDistXY;
737  m_ppProbabilities[6][nParticleIndex] = 0; //- dTrBallDistZ;
738 
739  return (double)(nRegionSumLeftImg / 255) + ((double)nRegionSumLeftImg / ((double)(nRegionLengthLeftImg * 255) + 0.001));
740 
741  }
742 
743 
744 
745 
746  // calculate the real probabilities for the particles by normalizing the preliminary ones and giving
747  // specific weights to the different cues
749  {
750  //printf("CalculateFinalProbabilities 1\n");
751 
752  // normalisation of the probabilities to the interval [0,1]
753  for (int i = 0; i < NUMBER_OF_CUES; i++)
754  {
755  double min = 99999999;
756  double max = -99999999;
757 
758  for (int j = 0; j < m_nParticles; j++)
759  {
760  if (m_ppProbabilities[i][j] != m_ppProbabilities[i][j])
761  {
762  m_ppProbabilities[i][j] = 0;
763  }
764 
765  if (m_ppProbabilities[i][j] < min)
766  {
767  min = m_ppProbabilities[i][j];
768  }
769 
770  if (m_ppProbabilities[i][j] > max)
771  {
772  max = m_ppProbabilities[i][j];
773  }
774  }
775 
776  if (max != min)
777  {
778  for (int j = 0; j < m_nParticles; j++)
779  {
780  m_ppProbabilities[i][j] = (m_ppProbabilities[i][j] - min) / (max - min);
781  }
782  }
783 
784  m_pProbMin[i] = min;
785  m_pProbMax[i] = max;
786  }
787 
788 
789  //debug
790  //double xSum=0, ySum=0, fDistSum=0;
791 
792  // weightet influence of the different cues on the final probability
793  #pragma omp parallel for
794  for (int j = 0; j < m_nParticles; j++)
795  {
796 #ifdef DSHT_USE_EDGE_DIRECTION
797  pi[j] = exp(15.0 / 31.0 * (
798  6 * m_ppProbabilities[0][j]
799  + 6 * m_ppProbabilities[1][j]
800  + 1 * m_ppProbabilities[2][j]
801  + 1 * m_ppProbabilities[3][j]
802  + 2 * m_ppProbabilities[4][j]
803  + 10 * m_ppProbabilities[5][j]
804  + 5 * m_ppProbabilities[6][j]
805  )
806  ) - 0.95;
807 #else
808  pi[j] = exp(15.0 / 31.0 * (
809  6 * m_ppProbabilities[0][j]
810  + 6 * m_ppProbabilities[1][j]
811  + 2 * m_ppProbabilities[2][j]
812  + 2 * m_ppProbabilities[3][j]
813  + 10 * m_ppProbabilities[5][j]
814  + 5 * m_ppProbabilities[6][j]
815  )
816  ) - 0.95;
817 
818 #endif // DSHT_USE_EDGE_DIRECTION
819 
820  // pi[j] = exp( 15.0/29.0 * (
821  // 5 * m_ppProbabilities[0][j]
822  // + 5 * m_ppProbabilities[1][j]
823  // + 2 * m_ppProbabilities[2][j]
824  // + 2 * m_ppProbabilities[3][j]
825  // + 2 * m_ppProbabilities[4][j]
826  // + 10 * m_ppProbabilities[5][j]
827  // + 5 * m_ppProbabilities[6][j]
828  // )
829  // ) - 0.95;
830 
831  // m_pHandModels[0]->UpdateHand(s[j]);
832  // double x,y,r;
833  // m_pHandModels[0]->GetTrackingBallPositionLeftCam(x, y, r);
834  // //printf("Particle %d: (%.1f, %.1f) %.3f\n", j, x, y, pi[j]);
835  // xSum += x;
836  // ySum += y;
837  // fDistSum += sqrt((x-m_pdTrackingBallPosXLeft[0])*(x-m_pdTrackingBallPosXLeft[0]) + (y-m_pdTrackingBallPosYLeft[0])*(y-m_pdTrackingBallPosYLeft[0]));
838 
839  if (pi[j] != pi[j])
840  {
841  if (j % 100 == 0) printf("pi[i] is nan! m_ppProbabilities[0][j] = %f, m_ppProbabilities[1][j] = %f, m_ppProbabilities[2][j] = %f, m_ppProbabilities[3][j] = %f, m_ppProbabilities[4][j] = %f, m_ppProbabilities[5][j] = %f, m_ppProbabilities[6][j] = %f\n",
843  }
844  }
845 
846  // debug
847  //printf("TrBallPos: (%.1f, %.1f)\n", m_pdTrackingBallPosXLeft[0], m_pdTrackingBallPosYLeft[0]);
848  //printf("Avg: (%.1f, %.1f) Dist: %.1f\n", xSum/m_nParticles, ySum/m_nParticles, fDistSum/m_nParticles);
849  }
850 
851 
852 
853 
855  {
856  //printf("GetDetailedRating 1\n");
857  int i;
858 
859  // copy config
860  for (i = 0; i < m_nDimension; i++)
861  {
862  pRating->dResultConfig[i] = pConf[i];
863  }
864 
865  // count number of white pixels in color segmented image
866  pRating->nNumberOfWhitePixelsInImage = 0;
867  for (i = 0; i < DSHT_IMAGE_WIDTH * DSHT_IMAGE_HEIGHT; i++)
868  {
869  pRating->nNumberOfWhitePixelsInImage += m_pRegionImageLeft->pixels[i] == 255;
870  }
871 
872  // calculate the rating for the config
873  //ISO C++ forbids variable length array [-Werror=vla] => use a vector (the array will be on the heap anyways)
874  std::vector<double> temp(m_nDimension);
875  for (i = 0; i < m_nDimension; i++)
876  {
877  temp[i] = s[0][i];
878  s[0][i] = pConf[i];
879  }
880 
881  UpdateModel(0);
882 
883  for (i = 0; i < m_nDimension; i++)
884  {
885  s[0][i] = temp[i];
886  }
887 
888  // color regions
889  int nRegionSum = 0;
890  int nRegionLength = 0;
891  CalculateRegionCue(nRegionSum, nRegionLength, 0, true);
892  pRating->nOverallNumberOfFoundPixels = nRegionSum / 255;
893  pRating->dOverallFoundPercentageOfExpectedPixels = (double)nRegionSum / ((double)(nRegionLength * 255) + 0.001);
894 
895  for (i = 0; i < DSHT_NUM_FINGERS; i++)
896  {
897  nRegionSum = 0;
898  nRegionLength = 0;
899  CalculatePixelSumInPolygon(&(m_pHandModels[0]->m_aFingerTipPolygonsLeftCam.at(i)), nRegionSum, nRegionLength, true);
900  pRating->nNumberOfFoundPixelsOfFinger[i] = nRegionSum / 255;
901  pRating->dFoundPercentageOfExpectedPixelsOfFinger[i] = (double)nRegionSum / ((double)(nRegionLength * 255) + 0.001);
902  }
903 
904  // edges
905  nRegionSum = 0;
906  nRegionLength = 0;
907  double dAngleDiffs = 0;
908  CalculateEdgeCue(nRegionSum, nRegionLength, dAngleDiffs, 0, true);
909  pRating->nEdgeSum = nRegionSum;
910  pRating->dEdgePercentage = (double)nRegionSum / ((double)nRegionLength + 0.001);
911  pRating->dEdgeDirection = dAngleDiffs / ((double)nRegionLength + 0.001);
912 
913  // PF cue rating
915  for (i = 0; i < NUMBER_OF_CUES; i++)
916  {
917  if (m_pProbMax[i] != m_pProbMin[i])
918  {
919  m_ppProbabilities[i][0] = (m_ppProbabilities[i][0] - m_pProbMin[i]) / (m_pProbMax[i] - m_pProbMin[i]);
920  }
921  }
922 #ifdef DSHT_USE_EDGE_DIRECTION
923  pRating->dPFCueRating = 1.0 / 29.0 * (
924  5 * m_ppProbabilities[0][0]
925  + 5 * m_ppProbabilities[1][0]
926  + 1 * m_ppProbabilities[2][0]
927  + 1 * m_ppProbabilities[3][0]
928  + 2 * m_ppProbabilities[4][0]
929  + 10 * m_ppProbabilities[5][0]
930  + 5 * m_ppProbabilities[6][0]
931  );
932 #else
933  pRating->dPFCueRating = 1.0 / 29.0 * (
934  5 * m_ppProbabilities[0][0]
935  + 5 * m_ppProbabilities[1][0]
936  + 2 * m_ppProbabilities[2][0]
937  + 2 * m_ppProbabilities[3][0]
938  + 10 * m_ppProbabilities[5][0]
939  + 5 * m_ppProbabilities[6][0]
940  );
941 #endif // DSHT_USE_EDGE_DIRECTION
942 
943  // final rating
944 
945  UpdateModel(0);
946 
947  // index is closer than pinky
948  if (m_pHandModels[0]->m_aFingerTipPolygonsLeftCam.at(1).center3d.z < m_pHandModels[0]->m_aFingerTipPolygonsLeftCam.at(4).center3d.z)
949  {
950  // thumb and index should be visible
951  if (abs(m_pHandModels[0]->m_aFingerTipPolygonsLeftCam.at(0).center3d.z - m_pHandModels[0]->m_aFingerTipPolygonsLeftCam.at(1).center3d.z) <= 30)
952  {
953  pRating->dRating = 0.3 * pRating->dFoundPercentageOfExpectedPixelsOfFinger[0]
954  + 0.3 * pRating->dFoundPercentageOfExpectedPixelsOfFinger[1]
956  + 0.1 * 1.0;
957  }
958  // thumb is in front
959  else if (m_pHandModels[0]->m_aFingerTipPolygonsLeftCam.at(0).center3d.z < m_pHandModels[0]->m_aFingerTipPolygonsLeftCam.at(1).center3d.z + 30)
960  {
961  pRating->dRating = 0.4 * pRating->dFoundPercentageOfExpectedPixelsOfFinger[0]
963  + 0.1 * 0.0;
964  }
965  else // other fingers are in front
966  {
967  pRating->dRating = 0.2 * pRating->dFoundPercentageOfExpectedPixelsOfFinger[1]
969  + 0.1 * 0.0;
970  }
971  }
972  else // pinky is closer than index
973  {
974  // thumb is in front
975  if (m_pHandModels[0]->m_aFingerTipPolygonsLeftCam.at(0).center3d.z < m_pHandModels[0]->m_aFingerTipPolygonsLeftCam.at(4).center3d.z + 30)
976  {
977  pRating->dRating = 0.4 * pRating->dFoundPercentageOfExpectedPixelsOfFinger[0]
979  + 0.1 * 0.0;
980  }
981  else// other fingers are in front
982  {
983  pRating->dRating = 0.8 * pRating->dOverallFoundPercentageOfExpectedPixels
984  + 0.2 * 0.0;
985  }
986  }
987 
988 
989  // enough pixels found for a good estimation? -> confidence of the rating
990  if (pRating->nNumberOfWhitePixelsInImage > 400)
991  {
992  pRating->dConfidenceOfRating = (double)pRating->nOverallNumberOfFoundPixels / (double)pRating->nNumberOfWhitePixelsInImage;
993  if (pRating->nNumberOfWhitePixelsInImage < 1200)
994  {
995  pRating->dConfidenceOfRating *= (double)pRating->nNumberOfWhitePixelsInImage / 1200.0;
996  }
997  }
998  else
999  {
1000  pRating->dConfidenceOfRating = 0;
1001  }
1002 
1003 
1004  }
1005 
1006  double CParticleFilterRobotHandLocalisation::DistanceBetweenConfigs(double* pOldConf, double* pNewConf)
1007  {
1008  double result = 0;
1009  for (int i = 0; i < 6; i++)
1010  {
1011  result += (pNewConf[i] - pOldConf[i]) * (pNewConf[i] - pOldConf[i]) / (allowed_deviation[i] * allowed_deviation[i]);
1012  }
1013  for (int i = 6; i < m_nDimension; i++)
1014  {
1015  result += 0.1 * (pNewConf[i] - pOldConf[i]) * (pNewConf[i] - pOldConf[i]) / (allowed_deviation[i] * allowed_deviation[i]);
1016  }
1017  return sqrt(result);
1018  }
1019 }
visionx::CParticleFilterRobotHandLocalisation::m_pTempBoolArrays
bool ** m_pTempBoolArrays
Definition: ParticleFilterRobotHandLocalisation.h:159
visionx::DSHT_default_allowed_deviation
const double DSHT_default_allowed_deviation[12]
Definition: HandLocalisationConstants.h:131
visionx::CParticleFilterRobotHandLocalisation::PredictNewBases
void PredictNewBases(double dSigmaFactor) override
Definition: ParticleFilterRobotHandLocalisation.cpp:253
GfxTL::sqrt
VectorXD< D, T > sqrt(const VectorXD< D, T > &a)
Definition: VectorXD.h:662
visionx::CParticleFilterRobotHandLocalisation::m_pdTrackingBallPosYRight
double * m_pdTrackingBallPosYRight
Definition: ParticleFilterRobotHandLocalisation.h:170
DSHT_MAX_POLYGON_CORNERS
#define DSHT_MAX_POLYGON_CORNERS
Definition: HandLocalisationConstants.h:46
visionx::CHandModelV2
Definition: HandModelV2.h:40
visionx::DetailedPFRating::dConfidenceOfRating
double dConfidenceOfRating
Definition: ParticleFilterRobotHandLocalisation.h:71
visionx::CParticleFilterRobotHandLocalisation::m_nNumTrackingBallRegionsRight
int m_nNumTrackingBallRegionsRight
Definition: ParticleFilterRobotHandLocalisation.h:172
visionx::CParticleFilterRobotHandLocalisation::m_pTempIntersectionPolygons
ConvexPolygonCalculations::Polygon ** m_pTempIntersectionPolygons
Definition: ParticleFilterRobotHandLocalisation.h:155
visionx
ArmarX headers.
Definition: OpenPoseStressTest.h:38
visionx::CParticleFilterRobotHandLocalisation::m_pProbMax
double m_pProbMax[NUMBER_OF_CUES]
Definition: ParticleFilterRobotHandLocalisation.h:162
visionx::ConvexPolygonCalculations::Polygon::hullLeft
Vec3d hullLeft[2 *DSHT_MAX_POLYGON_CORNERS+1]
Definition: Polygon.h:48
visionx::HandModeliCub
Definition: HandModeliCub.h:31
visionx::DetailedPFRating::dResultConfig
double dResultConfig[DSHT_NUM_PARAMETERS]
Definition: ParticleFilterRobotHandLocalisation.h:52
visionx::CParticleFilterRobotHandLocalisation::m_pRegionImageRight
CByteImage * m_pRegionImageRight
Definition: ParticleFilterRobotHandLocalisation.h:145
visionx::DetailedPFRating::dEdgePercentage
double dEdgePercentage
Definition: ParticleFilterRobotHandLocalisation.h:65
visionx::DetailedPFRating::dEdgeDirection
double dEdgeDirection
Definition: ParticleFilterRobotHandLocalisation.h:66
DSHT_IMAGE_WIDTH
#define DSHT_IMAGE_WIDTH
Definition: HandLocalisationConstants.h:66
visionx::CParticleFilterRobotHandLocalisation::SetTrackingBallPositions
void SetTrackingBallPositions(double *dPosX, double *dPosY, double *dRadius, int nNumTrBallRegions, bool bLeftCamImage)
Definition: ParticleFilterRobotHandLocalisation.cpp:212
visionx::CParticleFilterRobotHandLocalisation::SetAllowedDeviation
void SetAllowedDeviation(double *adeviation)
Definition: ParticleFilterRobotHandLocalisation.cpp:198
visionx::CParticleFilterRobotHandLocalisation::DistanceBetweenConfigs
double DistanceBetweenConfigs(double *pOldConf, double *pNewConf)
Definition: ParticleFilterRobotHandLocalisation.cpp:1006
visionx::ConvexPolygonCalculations::GetPolygonIntersection
void GetPolygonIntersection(Polygon *p1, Polygon *p2, Polygon *pInter, Vec3d *pointAccu, bool *boolTable, Vec3d *clockwiseHullPoly1, Vec3d *clockwiseHullPoly2)
Definition: Polygon.cpp:423
visionx::CParticleFilterRobotHandLocalisation::m_pSobelImageRight
CByteImage * m_pSobelImageRight
Definition: ParticleFilterRobotHandLocalisation.h:145
visionx::CParticleFilterRobotHandLocalisation::GetDetailedRating
void GetDetailedRating(double *pConf, DetailedPFRating *pRating)
Definition: ParticleFilterRobotHandLocalisation.cpp:854
visionx::CParticleFilterRobotHandLocalisation::CalculateTrackingBallCue
void CalculateTrackingBallCue(double &dDistanceXY, double &dDistanceZ, int nModelIndex)
Definition: ParticleFilterRobotHandLocalisation.cpp:622
visionx::ConvexPolygonCalculations::Polygon::nCorners
int nCorners
Definition: Polygon.h:36
visionx::ConvexPolygonCalculations::Polygon
Definition: Polygon.h:34
visionx::CParticleFilterRobotHandLocalisation::sensor_config
double * sensor_config
Definition: ParticleFilterRobotHandLocalisation.h:148
visionx::CParticleFilterRobotHandLocalisation::m_pdTrackingBallPosYLeft
double * m_pdTrackingBallPosYLeft
Definition: ParticleFilterRobotHandLocalisation.h:170
visionx::CParticleFilterRobotHandLocalisation::m_pSobelImageLeft
CByteImage * m_pSobelImageLeft
Definition: ParticleFilterRobotHandLocalisation.h:145
visionx::CParticleFilterRobotHandLocalisation::~CParticleFilterRobotHandLocalisation
virtual ~CParticleFilterRobotHandLocalisation()
Definition: ParticleFilterRobotHandLocalisation.cpp:93
visionx::CHandModelV2::m_aFingerTipPolygonsRightCam
std::vector< ConvexPolygonCalculations::Polygon > m_aFingerTipPolygonsRightCam
Definition: HandModelV2.h:71
visionx::CParticleFilterRobotHandLocalisation::m_pRegionImageLeft
CByteImage * m_pRegionImageLeft
Definition: ParticleFilterRobotHandLocalisation.h:145
visionx::CParticleFilterRobotHandLocalisation::CalculateProbability
double CalculateProbability(int nParticleIndex, int nModelIndex) override
Definition: ParticleFilterRobotHandLocalisation.cpp:704
visionx::CParticleFilterRobotHandLocalisation::m_pdTrackingBallPosXLeft
double * m_pdTrackingBallPosXLeft
Definition: ParticleFilterRobotHandLocalisation.h:169
visionx::ConvexPolygonCalculations::Polygon::hullRight
Vec3d hullRight[2 *DSHT_MAX_POLYGON_CORNERS+1]
Definition: Polygon.h:51
visionx::CHandModelV2::m_vTrackingBallPosRightCam
Vec2d m_vTrackingBallPosRightCam
Definition: HandModelV2.h:73
visionx::CParticleFilterFrameworkParallelized
Definition: ParticleFilterFrameworkParallelized.h:33
pi
#define pi
Definition: Transition.cpp:37
visionx::ConvexPolygonCalculations::PolygonsMightIntersect
bool PolygonsMightIntersect(Polygon *pol1, Polygon *pol2)
Definition: Polygon.cpp:115
visionx::CParticleFilterRobotHandLocalisation::CalculateFinalProbabilities
void CalculateFinalProbabilities() override
Definition: ParticleFilterRobotHandLocalisation.cpp:748
visionx::DetailedPFRating
Definition: ParticleFilterRobotHandLocalisation.h:49
visionx::CParticleFilterRobotHandLocalisation::CalculateEdgeCue
void CalculateEdgeCue(int &edge_sum, int &edge_length, double &angle_diffs, int nModelIndex, bool bLeftCamImage)
Definition: ParticleFilterRobotHandLocalisation.cpp:575
visionx::CParticleFilterRobotHandLocalisation::m_pProbMin
double m_pProbMin[NUMBER_OF_CUES]
Definition: ParticleFilterRobotHandLocalisation.h:161
armarx::abs
std::vector< T > abs(const std::vector< T > &v)
Definition: VectorHelpers.h:253
visionx::CParticleFilterRobotHandLocalisation::CalculatePixelSumInPolygon
void CalculatePixelSumInPolygon(ConvexPolygonCalculations::Polygon *pol, int &region_sum, int &region_length, bool bLeftCamImage)
Definition: ParticleFilterRobotHandLocalisation.cpp:288
visionx::CParticleFilterRobotHandLocalisation::SetParticleConfigHalf
void SetParticleConfigHalf(double *pConfig)
Definition: ParticleFilterRobotHandLocalisation.cpp:157
visionx::DetailedPFRating::nEdgeSum
int nEdgeSum
Definition: ParticleFilterRobotHandLocalisation.h:64
visionx::CParticleFilterRobotHandLocalisation::m_pdTrackingBallRadiusLeft
double * m_pdTrackingBallRadiusLeft
Definition: ParticleFilterRobotHandLocalisation.h:171
GfxTL::Vec3d
VectorXD< 3, double > Vec3d
Definition: VectorXD.h:695
visionx::CParticleFilterRobotHandLocalisation::m_pHandModels
CHandModelV2 ** m_pHandModels
Definition: ParticleFilterRobotHandLocalisation.h:144
visionx::CParticleFilterRobotHandLocalisation::m_pSobelYImageRight
CByteImage * m_pSobelYImageRight
Definition: ParticleFilterRobotHandLocalisation.h:146
visionx::CParticleFilterRobotHandLocalisation::m_pTempVecArrays
Vec3d ** m_pTempVecArrays
Definition: ParticleFilterRobotHandLocalisation.h:156
visionx::DetailedPFRating::nOverallNumberOfFoundPixels
int nOverallNumberOfFoundPixels
Definition: ParticleFilterRobotHandLocalisation.h:57
visionx::DetailedPFRating::dFoundPercentageOfExpectedPixelsOfFinger
double dFoundPercentageOfExpectedPixelsOfFinger[DSHT_NUM_FINGERS]
Definition: ParticleFilterRobotHandLocalisation.h:61
visionx::CParticleFilterRobotHandLocalisation::m_pSobelXImageLeft
CByteImage * m_pSobelXImageLeft
Definition: ParticleFilterRobotHandLocalisation.h:146
visionx::CParticleFilterRobotHandLocalisation::SetImages
void SetImages(CByteImage *pRegionImageLeft, CByteImage *pRegionImageRight, CByteImage *pSobelImageLeft, CByteImage *pSobelImageRight, CByteImage *pSobelXImageLeft, CByteImage *pSobelXImageRight, CByteImage *pSobelYImageLeft, CByteImage *pSobelYImageRight)
Definition: ParticleFilterRobotHandLocalisation.cpp:129
visionx::CParticleFilterRobotHandLocalisation::allowed_deviation
double * allowed_deviation
Definition: ParticleFilterRobotHandLocalisation.h:149
max
T max(T t1, T t2)
Definition: gdiam.h:48
ParticleFilterRobotHandLocalisation.h
visionx::CParticleFilterRobotHandLocalisation::m_pSobelYImageLeft
CByteImage * m_pSobelYImageLeft
Definition: ParticleFilterRobotHandLocalisation.h:146
visionx::CHandModelV2::m_vTrackingBallPosLeftCam
Vec2d m_vTrackingBallPosLeftCam
Definition: HandModelV2.h:73
visionx::ConvexPolygonCalculations::Polygon::hull
Vec3d hull[2 *DSHT_MAX_POLYGON_CORNERS]
Definition: Polygon.h:37
visionx::CParticleFilterRobotHandLocalisation::UpdateModel
void UpdateModel(int nParticleIndex, int nModelIndex) override
Definition: ParticleFilterRobotHandLocalisation.cpp:238
visionx::DetailedPFRating::dPFCueRating
double dPFCueRating
Definition: ParticleFilterRobotHandLocalisation.h:69
visionx::DetailedPFRating::dRating
double dRating
Definition: ParticleFilterRobotHandLocalisation.h:70
visionx::CHandModelV2::m_fTrackingBallRadiusLeftCam
float m_fTrackingBallRadiusLeftCam
Definition: HandModelV2.h:74
visionx::CParticleFilterRobotHandLocalisation::CalculatePixelSumOnLineSequence
void CalculatePixelSumOnLineSequence(Vec3d linePoints[], int nPoints, int &edge_sum, int &edge_length, double &angle_diffs, bool bLeftCamImage)
Definition: ParticleFilterRobotHandLocalisation.cpp:469
visionx::CParticleFilterRobotHandLocalisation::m_pdTrackingBallRadiusRight
double * m_pdTrackingBallRadiusRight
Definition: ParticleFilterRobotHandLocalisation.h:171
visionx::CParticleFilterRobotHandLocalisation::SetParticleConfig
void SetParticleConfig(double *pConfig)
Definition: ParticleFilterRobotHandLocalisation.cpp:145
visionx::CParticleFilterRobotHandLocalisation::m_nNumTrackingBallRegionsLeft
int m_nNumTrackingBallRegionsLeft
Definition: ParticleFilterRobotHandLocalisation.h:172
visionx::CParticleFilterRobotHandLocalisation::CParticleFilterRobotHandLocalisation
CParticleFilterRobotHandLocalisation(int nParticles, int nDimension, int nNumParallelThreads, CStereoCalibration *pCalibration, std::string sHandModelFileName)
Definition: ParticleFilterRobotHandLocalisation.cpp:37
visionx::DetailedPFRating::nNumberOfFoundPixelsOfFinger
int nNumberOfFoundPixelsOfFinger[DSHT_NUM_FINGERS]
Definition: ParticleFilterRobotHandLocalisation.h:60
visionx::CParticleFilterRobotHandLocalisation::m_pSobelXImageRight
CByteImage * m_pSobelXImageRight
Definition: ParticleFilterRobotHandLocalisation.h:146
DSHT_NUM_FINGERS
#define DSHT_NUM_FINGERS
Definition: HandLocalisationConstants.h:39
visionx::CParticleFilterRobotHandLocalisation::m_ppProbabilities
double ** m_ppProbabilities
Definition: ParticleFilterRobotHandLocalisation.h:152
visionx::CHandModelV2::m_fTrackingBallRadiusRightCam
float m_fTrackingBallRadiusRightCam
Definition: HandModelV2.h:74
visionx::CParticleFilterRobotHandLocalisation::SetConfigOfATenthOfTheParticles
void SetConfigOfATenthOfTheParticles(int nTenthIndex, double *pConfig)
Definition: ParticleFilterRobotHandLocalisation.cpp:169
visionx::CParticleFilterFrameworkParallelized::m_nNumParallelThreads
int m_nNumParallelThreads
Definition: ParticleFilterFrameworkParallelized.h:50
visionx::DetailedPFRating::dOverallFoundPercentageOfExpectedPixels
double dOverallFoundPercentageOfExpectedPixels
Definition: ParticleFilterRobotHandLocalisation.h:58
visionx::DetailedPFRating::nNumberOfWhitePixelsInImage
int nNumberOfWhitePixelsInImage
Definition: ParticleFilterRobotHandLocalisation.h:55
min
T min(T t1, T t2)
Definition: gdiam.h:42
NUMBER_OF_CUES
#define NUMBER_OF_CUES
Definition: ParticleFilterRobotHandLocalisation.h:42
visionx::CParticleFilterRobotHandLocalisation::m_pTempClockwiseHullPolys1
Vec3d ** m_pTempClockwiseHullPolys1
Definition: ParticleFilterRobotHandLocalisation.h:157
visionx::CParticleFilterRobotHandLocalisation::m_pTempClockwiseHullPolys2
Vec3d ** m_pTempClockwiseHullPolys2
Definition: ParticleFilterRobotHandLocalisation.h:158
visionx::CParticleFilterRobotHandLocalisation::SetSensorConfig
void SetSensorConfig(double *sconfig)
Definition: ParticleFilterRobotHandLocalisation.cpp:183
DSHT_IMAGE_HEIGHT
#define DSHT_IMAGE_HEIGHT
Definition: HandLocalisationConstants.h:67
visionx::CParticleFilterRobotHandLocalisation::CalculateRegionCue
void CalculateRegionCue(int &region_sum, int &region_length, int nModelIndex, bool bLeftCamImage)
Definition: ParticleFilterRobotHandLocalisation.cpp:387
armarx::ctrlutil::s
double s(double t, double s0, double v0, double a0, double j)
Definition: CtrlUtil.h:33
visionx::CHandModelV2::UpdateHand
virtual void UpdateHand(double *pConfig)
Definition: HandModelV2.cpp:358
visionx::CHandModelV2::m_aFingerTipPolygonsLeftCam
std::vector< ConvexPolygonCalculations::Polygon > m_aFingerTipPolygonsLeftCam
Definition: HandModelV2.h:71
visionx::CParticleFilterRobotHandLocalisation::m_pdTrackingBallPosXRight
double * m_pdTrackingBallPosXRight
Definition: ParticleFilterRobotHandLocalisation.h:169