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
69namespace 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
95 Eigen::Matrix4f GetHandPose();
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;
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
std::vector< Vec3d > GetFingertipPositions()
void SetSensorConfig(const Vec3d vPosition, const Mat3d mOrientation, const double *pConfigFingers)
void LocaliseHand(const CByteImage *pNewCamImageLeft, const CByteImage *pNewCamImageRight, const double *pSensorConfig, double *pEstimatedConfig, double &dConfidenceRating)
void SetResultConfig(const Vec3d vPosition, const Mat3d mOrientation, const double *pConfigFingers)
void SetParticleVarianceFactor(double dNewFactor=1.0)
CHandLocalisation(int nNumParticles, int nNumAnnealingRuns, int nPredictionMode, CStereoCalibration *pCalibration, std::string sHandModelFileName)
ArmarX headers.