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 "Math/Math3d.h"
56 #include "Image/ImageProcessor.h"
57 #include "ObjectFinder/ObjectFinder.h"
58 
59 // Eigen
60 #include <Eigen/Eigen>
61 
62 #include <mutex>
63 
64 // **************************************************************
65 // Class definition
66 // **************************************************************
67 
68 
69 
70 namespace visionx
71 {
73  {
74  // public methods
75  public:
76  CHandLocalisation(int nNumParticles, int nNumAnnealingRuns, int nPredictionMode, CStereoCalibration* pCalibration, std::string sHandModelFileName);
78 
79  void LocaliseHand(const CByteImage* pNewCamImageLeft, const CByteImage* pNewCamImageRight, const double* pSensorConfig, double* pEstimatedConfig, double& dConfidenceRating);
80  void LocaliseHand(const CByteImage* pNewCamImageLeft, const CByteImage* pNewCamImageRight, const Vec3d vPositionFromSensors, const Mat3d mOrientationFromSensors,
81  const double* pSensorConfigFingers, double* pEstimatedConfig, double& dConfidenceRating);
82 
84  std::vector<Vec3d> GetFingertipPositions(); // ordering: thumb, index, middle, ring, pinky
85 
86  // modify the variance for the random noise during particle re-drawing
87  void SetParticleVarianceFactor(double dNewFactor = 1.0)
88  {
89  m_dVarianceFactor = dNewFactor;
90  }
91 
94  CByteImage* m_pSobelImageLeft;
95  CByteImage* m_pSobelImageRight;
98 
99  double* GetResultConfig();
100  void SetResultConfig(const Vec3d vPosition, const Mat3d mOrientation, const double* pConfigFingers);
101  double* GetSensorConfig();
102  void SetSensorConfig(const Vec3d vPosition, const Mat3d mOrientation, const double* pConfigFingers);
103 
104  private:
105 
106  bool m_bFirstRun;
107 
108  // images
109  CByteImage* m_pCamImageLeft, *m_pCamImageRight;
110 
111  CByteImage* m_pHSVImageLeft, *m_pHSVImageRight;
112  CByteImage* m_pSobelXImageLeft, *m_pSobelXImageRight;
113  CByteImage* m_pSobelYImageLeft, *m_pSobelYImageRight;
114 
115  CByteImage* m_pTempGrayImage1, *m_pTempGrayImage2, *m_pTempGrayImage3, *m_pTempGrayImage4, *m_pTempGrayImage5, *m_pTempGrayImage6;
116 
117 
118  // configs & ratings
119  double* m_pFinalConf;
120  double* m_pOldFinalConf;
121  double* m_pSensorConf;
122  double* m_pOldSensorConf;
123  double* m_pPFConf;
124  double* m_pOldPFConf;
125  double* m_pPredictedConf;
126  std::mutex configMutex;
127 
128  double m_dRating;
129  double m_dOldRating;
130  DetailedPFRating m_PFRating;
131 
132 
133  // settings
134  int m_nNumParticles;
135  int m_nNumAnnealingRuns;
136  int m_nPredictionMode;
137  float m_dVarianceFactor;
138 
139 
140  // particle filter
141  CParticleFilterRobotHandLocalisation* m_pParticleFilter;
142 
143 
144  // ObjectFinder for the tracking ball
145  CObjectFinder* m_pObjectFinderLeft, *m_pObjectFinderRight;
146  static const int m_nMaxTrBallRegions = 30;
147  double* m_pdTrBallPosXLeft, *m_pdTrBallPosXRight;
148  double* m_pdTrBallPosYLeft, *m_pdTrBallPosYRight;
149  double* m_pdTrBallRadiusLeft, *m_pdTrBallRadiusRight;
150 
151  // for returning the fingertip poses
152  CHandModelV2* m_pHandModel;
153  };
154 }
155 
visionx::CHandLocalisation::m_pColorFilteredImageLeft
CByteImage * m_pColorFilteredImageLeft
Definition: HandLocalisation.h:92
visionx::CHandModelV2
Definition: HandModelV2.h:40
visionx
ArmarX headers.
Definition: OpenPoseStressTest.h:38
HandLocalisationConstants.h
visionx::CHandLocalisation::m_pTrackingBallImageRight
CByteImage * m_pTrackingBallImageRight
Definition: HandLocalisation.h:97
visionx::CHandLocalisation::GetFingertipPositions
std::vector< Vec3d > GetFingertipPositions()
Definition: HandLocalisation.cpp:240
visionx::DetailedPFRating
Definition: ParticleFilterRobotHandLocalisation.h:49
visionx::CParticleFilterRobotHandLocalisation
Definition: ParticleFilterRobotHandLocalisation.h:76
GfxTL::Vec3d
VectorXD< 3, double > Vec3d
Definition: VectorXD.h:695
visionx::CHandLocalisation::m_pTrackingBallImageLeft
CByteImage * m_pTrackingBallImageLeft
Definition: HandLocalisation.h:96
visionx::CHandLocalisation::LocaliseHand
void LocaliseHand(const CByteImage *pNewCamImageLeft, const CByteImage *pNewCamImageRight, const double *pSensorConfig, double *pEstimatedConfig, double &dConfidenceRating)
Definition: HandLocalisation.cpp:333
ParticleFilterRobotHandLocalisation.h
visionx::CHandLocalisation::m_pSobelImageLeft
CByteImage * m_pSobelImageLeft
Definition: HandLocalisation.h:94
visionx::CHandLocalisation
Definition: HandLocalisation.h:72
visionx::CHandLocalisation::GetHandPose
Eigen::Matrix4f GetHandPose()
Definition: HandLocalisation.cpp:205
visionx::CHandLocalisation::CHandLocalisation
CHandLocalisation(int nNumParticles, int nNumAnnealingRuns, int nPredictionMode, CStereoCalibration *pCalibration, std::string sHandModelFileName)
Definition: HandLocalisation.cpp:56
GfxTL::Matrix4f
MatrixXX< 4, 4, float > Matrix4f
Definition: MatrixXX.h:601
visionx::CHandLocalisation::SetResultConfig
void SetResultConfig(const Vec3d vPosition, const Mat3d mOrientation, const double *pConfigFingers)
Definition: HandLocalisation.cpp:279
visionx::CHandLocalisation::SetParticleVarianceFactor
void SetParticleVarianceFactor(double dNewFactor=1.0)
Definition: HandLocalisation.h:87
visionx::CHandLocalisation::~CHandLocalisation
~CHandLocalisation()
Definition: HandLocalisation.cpp:128
visionx::CHandLocalisation::GetResultConfig
double * GetResultConfig()
Definition: HandLocalisation.cpp:265
visionx::CHandLocalisation::m_pColorFilteredImageRight
CByteImage * m_pColorFilteredImageRight
Definition: HandLocalisation.h:93
visionx::CHandLocalisation::SetSensorConfig
void SetSensorConfig(const Vec3d vPosition, const Mat3d mOrientation, const double *pConfigFingers)
Definition: HandLocalisation.cpp:313
visionx::CHandLocalisation::GetSensorConfig
double * GetSensorConfig()
Definition: HandLocalisation.cpp:299
visionx::CHandLocalisation::m_pSobelImageRight
CByteImage * m_pSobelImageRight
Definition: HandLocalisation.h:95