ParticleFilterRobotHandLocalisation.h
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 */
24#pragma once
25
26
31#include "Polygon.h"
32
33// IVT
34#include <cmath>
35#include <cstdlib>
36
37#include "Calibration/StereoCalibration.h"
38#include "Helpers/helpers.h"
39#include "Image/ByteImage.h"
40#include "Math/Math3d.h"
41
42#define NUMBER_OF_CUES 7
43
44namespace visionx
45{
46
48 {
49 // config that was evaluated
51
52 // number of found correct pixels
54
57
60
61 // results of edge detection
65
66 // rating
68 double dRating;
70 };
71
73 {
74 public:
75 // constructor
77 int nDimension,
78 int nNumParallelThreads,
79 CStereoCalibration* pCalibration,
80 std::string sHandModelFileName);
81
82 // destructor
84
85
86 // public methods
87
88 void SetImages(CByteImage* pRegionImageLeft,
89 CByteImage* pRegionImageRight,
90 CByteImage* pSobelImageLeft,
91 CByteImage* pSobelImageRight,
92 CByteImage* pSobelXImageLeft,
93 CByteImage* pSobelXImageRight,
94 CByteImage* pSobelYImageLeft,
95 CByteImage* pSobelYImageRight);
96
97 void UpdateModel(int nParticleIndex, int nModelIndex) override;
98
99 void
100 UpdateModel(int nParticleIndex) override
101 {
102 UpdateModel(nParticleIndex, 0);
103 }
104
105 void PredictNewBases(double dSigmaFactor) override;
106 double CalculateProbability(int nParticleIndex, int nModelIndex) override;
107
108 double
109 CalculateProbability(bool bSeparateCall = true) override
110 {
111 return CalculateProbability(0, 0);
112 }
113
114 void CalculateFinalProbabilities() override;
115
116 // set the configuration of the particles
117 void SetParticleConfig(double* pConfig);
118 // set the configuration of the first half of the particles, the rest is not changed
119 void SetParticleConfigHalf(double* pConfig);
120 // set the configuration of ten percent of the particles, the rest is not changed
121 void SetConfigOfATenthOfTheParticles(int nTenthIndex, double* pConfig);
122 // set the array containing the sensor values
123 void SetSensorConfig(double* sconfig);
124 // set the allowed deviation of the particle configs from the sensor values
125 void SetAllowedDeviation(double* adeviation);
126
127 // get a detailed rating for a config
128 void GetDetailedRating(double* pConf, DetailedPFRating* pRating);
129
130 // calc distance between two configs
131 double DistanceBetweenConfigs(double* pOldConf, double* pNewConf);
132
133 // set the tracking ball position and size
134 void SetTrackingBallPositions(double* dPosX,
135 double* dPosY,
136 double* dRadius,
137 int nNumTrBallRegions,
138 bool bLeftCamImage);
139
140 private:
141 public: //TODO: make private again
142 // private methods
143
144 void CalculateRegionCue(int& region_sum,
145 int& region_length,
146 int nModelIndex,
147 bool bLeftCamImage);
148 void CalculateEdgeCue(int& edge_sum,
149 int& edge_length,
150 double& angle_diffs,
151 int nModelIndex,
152 bool bLeftCamImage);
153
154 // sum up all pixel values of camImage that are inside the polygon pol, and count the number
155 // of pixels inside the polygon
157 int& region_sum,
158 int& region_length,
159 bool bLeftCamImage);
160
161 inline void CalculatePixelSumOnLineSequence(Vec3d linePoints[],
162 int nPoints,
163 int& edge_sum,
164 int& edge_length,
165 double& angle_diffs,
166 bool bLeftCamImage);
167
168 // calculate error distance to tracking ball
169 void CalculateTrackingBallCue(double& dDistanceXY, double& dDistanceZ, int nModelIndex);
170
171
172 // private attributes
173
178
181
182
184 //int m_nParticleIndex; // index of the particle which is to be handled next
185
191
194
195 //float m_fFocalLengthX;
196 //float m_fFocalLengthY;
197 //float m_fPrincipalPointX;
198 //float m_fPrincipalPointY;
199
204 };
205
206
207} // namespace visionx
#define DSHT_NUM_PARAMETERS
#define DSHT_NUM_FINGERS
CParticleFilterFrameworkParallelized(int nParticles, int nDimension, int nNumParallelThreads=1)
void SetImages(CByteImage *pRegionImageLeft, CByteImage *pRegionImageRight, CByteImage *pSobelImageLeft, CByteImage *pSobelImageRight, CByteImage *pSobelXImageLeft, CByteImage *pSobelXImageRight, CByteImage *pSobelYImageLeft, CByteImage *pSobelYImageRight)
void SetConfigOfATenthOfTheParticles(int nTenthIndex, double *pConfig)
void CalculatePixelSumInPolygon(ConvexPolygonCalculations::Polygon *pol, int &region_sum, int &region_length, bool bLeftCamImage)
double CalculateProbability(int nParticleIndex, int nModelIndex) override
double DistanceBetweenConfigs(double *pOldConf, double *pNewConf)
CParticleFilterRobotHandLocalisation(int nParticles, int nDimension, int nNumParallelThreads, CStereoCalibration *pCalibration, std::string sHandModelFileName)
void SetTrackingBallPositions(double *dPosX, double *dPosY, double *dRadius, int nNumTrBallRegions, bool bLeftCamImage)
void CalculateTrackingBallCue(double &dDistanceXY, double &dDistanceZ, int nModelIndex)
void CalculateRegionCue(int &region_sum, int &region_length, int nModelIndex, bool bLeftCamImage)
void CalculatePixelSumOnLineSequence(Vec3d linePoints[], int nPoints, int &edge_sum, int &edge_length, double &angle_diffs, bool bLeftCamImage)
void UpdateModel(int nParticleIndex, int nModelIndex) override
void GetDetailedRating(double *pConf, DetailedPFRating *pRating)
double CalculateProbability(bool bSeparateCall=true) override
void CalculateEdgeCue(int &edge_sum, int &edge_length, double &angle_diffs, int nModelIndex, bool bLeftCamImage)
ArmarX headers.
double dFoundPercentageOfExpectedPixelsOfFinger[DSHT_NUM_FINGERS]