HandLocalisation.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 // *****************************************************************
25 // -----------------------------------------------------------------
26 // HandLocalisation.h
27 // Declaration of class CHandLocalisation
28 // -----------------------------------------------------------------
29 // *****************************************************************
30 
31 // *****************************************************************
32 // Author: David Schiebener
33 // Date: 11.12.2009
34 // *****************************************************************
35 
36 
37 // *****************************************************************
38 // double-include protection
39 // *****************************************************************
40 
41 #pragma once
42 
43 
44 // *****************************************************************
45 // includes
46 // *****************************************************************
47 
48 // Hand localisation
51 
52 // IVT
53 #include "Calibration/StereoCalibration.h"
54 #include "Image/ByteImage.h"
55 #include "Image/ImageProcessor.h"
56 #include "Math/Math3d.h"
57 #include "ObjectFinder/ObjectFinder.h"
58 
59 // Eigen
60 #include <mutex>
61 
62 #include <Eigen/Eigen>
63 
64 // **************************************************************
65 // Class definition
66 // **************************************************************
67 
68 
69 namespace visionx
70 {
72  {
73  // public methods
74  public:
75  CHandLocalisation(int nNumParticles,
76  int nNumAnnealingRuns,
77  int nPredictionMode,
78  CStereoCalibration* pCalibration,
79  std::string sHandModelFileName);
81 
82  void LocaliseHand(const CByteImage* pNewCamImageLeft,
83  const CByteImage* pNewCamImageRight,
84  const double* pSensorConfig,
85  double* pEstimatedConfig,
86  double& dConfidenceRating);
87  void LocaliseHand(const CByteImage* pNewCamImageLeft,
88  const CByteImage* pNewCamImageRight,
89  const Vec3d vPositionFromSensors,
90  const Mat3d mOrientationFromSensors,
91  const double* pSensorConfigFingers,
92  double* pEstimatedConfig,
93  double& dConfidenceRating);
94 
96  std::vector<Vec3d> GetFingertipPositions(); // ordering: thumb, index, middle, ring, pinky
97 
98  // modify the variance for the random noise during particle re-drawing
99  void
100  SetParticleVarianceFactor(double dNewFactor = 1.0)
101  {
102  m_dVarianceFactor = dNewFactor;
103  }
104 
107  CByteImage* m_pSobelImageLeft;
108  CByteImage* m_pSobelImageRight;
111 
112  double* GetResultConfig();
113  void SetResultConfig(const Vec3d vPosition,
114  const Mat3d mOrientation,
115  const double* pConfigFingers);
116  double* GetSensorConfig();
117  void SetSensorConfig(const Vec3d vPosition,
118  const Mat3d mOrientation,
119  const double* pConfigFingers);
120 
121  private:
122  bool m_bFirstRun;
123 
124  // images
125  CByteImage *m_pCamImageLeft, *m_pCamImageRight;
126 
127  CByteImage *m_pHSVImageLeft, *m_pHSVImageRight;
128  CByteImage *m_pSobelXImageLeft, *m_pSobelXImageRight;
129  CByteImage *m_pSobelYImageLeft, *m_pSobelYImageRight;
130 
131  CByteImage *m_pTempGrayImage1, *m_pTempGrayImage2, *m_pTempGrayImage3, *m_pTempGrayImage4,
132  *m_pTempGrayImage5, *m_pTempGrayImage6;
133 
134 
135  // configs & ratings
136  double* m_pFinalConf;
137  double* m_pOldFinalConf;
138  double* m_pSensorConf;
139  double* m_pOldSensorConf;
140  double* m_pPFConf;
141  double* m_pOldPFConf;
142  double* m_pPredictedConf;
143  std::mutex configMutex;
144 
145  double m_dRating;
146  double m_dOldRating;
147  DetailedPFRating m_PFRating;
148 
149 
150  // settings
151  int m_nNumParticles;
152  int m_nNumAnnealingRuns;
153  int m_nPredictionMode;
154  float m_dVarianceFactor;
155 
156 
157  // particle filter
158  CParticleFilterRobotHandLocalisation* m_pParticleFilter;
159 
160 
161  // ObjectFinder for the tracking ball
162  CObjectFinder *m_pObjectFinderLeft, *m_pObjectFinderRight;
163  static const int m_nMaxTrBallRegions = 30;
164  double *m_pdTrBallPosXLeft, *m_pdTrBallPosXRight;
165  double *m_pdTrBallPosYLeft, *m_pdTrBallPosYRight;
166  double *m_pdTrBallRadiusLeft, *m_pdTrBallRadiusRight;
167 
168  // for returning the fingertip poses
169  CHandModelV2* m_pHandModel;
170  };
171 } // namespace visionx
visionx::CHandLocalisation::m_pColorFilteredImageLeft
CByteImage * m_pColorFilteredImageLeft
Definition: HandLocalisation.h:105
visionx::CHandModelV2
Definition: HandModelV2.h:36
GfxTL::Vec3d
VectorXD< 3, double > Vec3d
Definition: VectorXD.h:737
visionx
ArmarX headers.
Definition: OpenPoseStressTest.h:38
GfxTL::Matrix4f
MatrixXX< 4, 4, float > Matrix4f
Definition: MatrixXX.h:650
HandLocalisationConstants.h
visionx::CHandLocalisation::m_pTrackingBallImageRight
CByteImage * m_pTrackingBallImageRight
Definition: HandLocalisation.h:110
visionx::CHandLocalisation::GetFingertipPositions
std::vector< Vec3d > GetFingertipPositions()
Definition: HandLocalisation.cpp:267
visionx::DetailedPFRating
Definition: ParticleFilterRobotHandLocalisation.h:47
visionx::CParticleFilterRobotHandLocalisation
Definition: ParticleFilterRobotHandLocalisation.h:72
visionx::CHandLocalisation::m_pTrackingBallImageLeft
CByteImage * m_pTrackingBallImageLeft
Definition: HandLocalisation.h:109
visionx::CHandLocalisation::LocaliseHand
void LocaliseHand(const CByteImage *pNewCamImageLeft, const CByteImage *pNewCamImageRight, const double *pSensorConfig, double *pEstimatedConfig, double &dConfidenceRating)
Definition: HandLocalisation.cpp:362
ParticleFilterRobotHandLocalisation.h
visionx::CHandLocalisation::m_pSobelImageLeft
CByteImage * m_pSobelImageLeft
Definition: HandLocalisation.h:107
visionx::CHandLocalisation
Definition: HandLocalisation.h:71
visionx::CHandLocalisation::GetHandPose
Eigen::Matrix4f GetHandPose()
Definition: HandLocalisation.cpp:233
visionx::CHandLocalisation::CHandLocalisation
CHandLocalisation(int nNumParticles, int nNumAnnealingRuns, int nPredictionMode, CStereoCalibration *pCalibration, std::string sHandModelFileName)
Definition: HandLocalisation.cpp:55
visionx::CHandLocalisation::SetResultConfig
void SetResultConfig(const Vec3d vPosition, const Mat3d mOrientation, const double *pConfigFingers)
Definition: HandLocalisation.cpp:307
visionx::CHandLocalisation::SetParticleVarianceFactor
void SetParticleVarianceFactor(double dNewFactor=1.0)
Definition: HandLocalisation.h:100
visionx::CHandLocalisation::~CHandLocalisation
~CHandLocalisation()
Definition: HandLocalisation.cpp:151
visionx::CHandLocalisation::GetResultConfig
double * GetResultConfig()
Definition: HandLocalisation.cpp:294
visionx::CHandLocalisation::m_pColorFilteredImageRight
CByteImage * m_pColorFilteredImageRight
Definition: HandLocalisation.h:106
visionx::CHandLocalisation::SetSensorConfig
void SetSensorConfig(const Vec3d vPosition, const Mat3d mOrientation, const double *pConfigFingers)
Definition: HandLocalisation.cpp:341
visionx::CHandLocalisation::GetSensorConfig
double * GetSensorConfig()
Definition: HandLocalisation.cpp:328
visionx::CHandLocalisation::m_pSobelImageRight
CByteImage * m_pSobelImageRight
Definition: HandLocalisation.h:108