ObjectHypothesis.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 
27 
28 // IVT
29 #include "Math/Math3d.h"
30 #include "Features/SIFTFeatures/SIFTFeatureEntry.h"
31 #include "Structs/Structs.h"
32 #include "DataStructures/DynamicArrayTemplate.h"
33 
34 
36 {
37 public:
39  {
40  pPoints2D = NULL;
41  }
42 
44  {
45  CMSERDescriptor* pRet = new CMSERDescriptor();
46 
47  if (pPoints2D)
48  {
49  pRet->pPoints2D = new std::vector<Vec2d>();
50 
51  for (int i = 0; i < (int)pPoints2D->size(); i++)
52  {
53  pRet->pPoints2D->push_back(pPoints2D->at(i));
54  }
55  }
56 
57  pRet->nSize = nSize;
58 
59  pRet->vMean = vMean;
60 
61  pRet->fEigenvalue1 = fEigenvalue1;
62  pRet->fEigenvalue2 = fEigenvalue2;
63 
64  Math2d::SetVec(pRet->vEigenvector1, vEigenvector1);
65  Math2d::SetVec(pRet->vEigenvector2, vEigenvector2);
66 
67  for (int i = 0; i < OLP_SIZE_MSER_HISTOGRAM; i++)
68  {
71  }
72 
74 
75  return pRet;
76  }
77 
78 
79  std::vector<Vec2d>* pPoints2D;
80 
81  int nSize;
82 
84 
86 
88 
93 };
94 
95 
96 
98 {
99 public:
101  {
102  pRegionLeft = NULL;
103  pRegionRight = NULL;
104  }
105 
107  {
108  if (pRegionLeft)
109  {
110  if (pRegionLeft->pPoints2D)
111  {
112  //pRegionLeft->pPoints2D->clear();
113  delete pRegionLeft->pPoints2D;
114  }
115 
116  delete pRegionLeft;
117  }
118 
119  if (pRegionRight)
120  {
121  if (pRegionRight->pPoints2D)
122  {
123  //pRegionRight->pPoints2D->clear();
124  delete pRegionRight->pPoints2D;
125  }
126 
127  delete pRegionRight;
128  }
129  }
130 
132  {
133  CMSERDescriptor3D* pRet = new CMSERDescriptor3D();
134 
135  if (pRegionLeft)
136  {
137  pRet->pRegionLeft = pRegionLeft->GetCopy();
138  }
139 
140  if (pRegionRight)
141  {
142  pRet->pRegionRight = pRegionRight->GetCopy();
143  }
144 
145  pRet->vPosition = vPosition;
146 
151 
152  return pRet;
153  }
154 
155 
157 
158  Vec3d vPosition; // calculated from stereo correspondence of the central points (i.e. means) of the two 2D regions
159 
160  Vec3d vSigmaPoint1a, vSigmaPoint1b, vSigmaPoint2a, vSigmaPoint2b; // calculated from stereo correspondences of
161  // central points -+ 0.5*sqrt(Eigenvalue)*Eigenvector
162  // of the 2D regions
163 };
164 
165 
166 
167 
168 using CSIFTFeatureArray = CDynamicArrayTemplate<CSIFTFeatureEntry*>;
169 
170 
172 {
173 public:
175  {
176  pFeatureDescriptors = NULL;
177  pMSERDescriptor = NULL;
179  }
180 
182  {
184  {
185  for (int j = 0; j < pFeatureDescriptors->GetSize(); j++)
186  {
187  delete (*pFeatureDescriptors)[j];
188  }
189 
190  //pFeatureDescriptors->Clear();
191  delete pFeatureDescriptors;
192  }
193 
194  if (pMSERDescriptor)
195  {
196  delete pMSERDescriptor;
197  }
198  }
199 
201  {
202  CHypothesisPoint* pRet = new CHypothesisPoint();
203  Math3d::SetVec(pRet->vPosition, vPosition);
204  Math3d::SetVec(pRet->vOldPosition, vOldPosition);
205  pRet->ePointType = ePointType;
206  pRet->fColorR = fColorR;
207  pRet->fColorG = fColorG;
208  pRet->fColorB = fColorB;
209  pRet->fIntensity = fIntensity;
211 
212  if (pMSERDescriptor)
213  {
215  }
216 
218  {
220 
221  for (int i = 0; i < pFeatureDescriptors->GetSize(); i++)
222  {
223  // //pRet->pFeatureDescriptors->AddElement(new CSIFTFeatureEntry(*(*pFeatureDescriptors)[i]));
224  pRet->pFeatureDescriptors->AddElement((CSIFTFeatureEntry*)((*pFeatureDescriptors)[i])->Clone());
225  }
226  }
227 
228  return pRet;
229  }
230 
232  {
236  };
237 
245 };
246 
247 
248 
250 {
251 public:
253  {
254  nHypothesisNumber = -1;
255  fMaxExtent = 0;
256  Math3d::SetVec(vCenter, Math3d::zero_vec);
257  Math3d::SetVec(vLastTranslation, Math3d::zero_vec);
258  Math3d::SetMat(mLastRotation, Math3d::unit_mat);
259  }
260 
262  {
263  for (size_t i = 0; i < aNewPoints.size(); i++)
264  {
265  delete aNewPoints.at(i);
266  }
267 
268  aNewPoints.clear();
269 
270  for (size_t i = 0; i < aConfirmedPoints.size(); i++)
271  {
272  delete aConfirmedPoints.at(i);
273  }
274 
275  aConfirmedPoints.clear();
276 
277  for (size_t i = 0; i < aDoubtablePoints.size(); i++)
278  {
279  delete aDoubtablePoints.at(i);
280  }
281 
282  aDoubtablePoints.clear();
283  }
284 
286 
288 
289  eObjectType eType; // the type of the hypothetical object: plane or cylinder or ...
290 
291  std::vector<CHypothesisPoint*> aNewPoints;
292  std::vector<CHypothesisPoint*> aConfirmedPoints;
293  std::vector<CHypothesisPoint*> aDoubtablePoints;
294  std::vector<CHypothesisPoint*> aVisibleConfirmedPoints;
295 
296  // indicates for each iteration if the hypothesis has moved
297  std::vector<bool> aHypothesisHasMoved;
298 
299  Vec3d vNormal; // if hypothesis is a plane, this is the plane normal.
300  // if it is a cylinder, it is the normal of the cylinder surface pointing
301  // approximately towards the camera.
302 
303  Vec3d vCylinderAxis; // only valid if the object is a cylinder
304 
305  Vec3d vSecondAxis, vThirdAxis; // axes that span an orthonormal coordinate system together
306  // with the plane normal or the cylinder axis
307 
308  Vec3d vCenter; // a central point on the plane or on the cylinder axis or the sphere center
309 
310  float fStdDev1, fStdDev2; // standard deviations along vSecondAxis and vThirdAxis in the case of a plane,
311  // along cylinder axis and vSecondAxis in the case of a cylinder
312 
313  float fRadius; // only valid if the object is a cylinder or a sphere
314 
315  float fMaxExtent; // maximal distance of a point from the center
316 
319 };
320 
321 
322 /*
323 struct CObjectHypothesis2
324 {
325  enum eObjectType {ePlane, eCylinder};
326 
327 
328  eObjectType eType; // the type of the hypothetical object: plane or cylinder
329 
330  CVec3dArray* paPoints3d; // the points that belong to the hypothetical object
331  int* pnCorrespondingPointIndices; // contains the index of the corresponding 3D point
332  // amongst all points that were in the image that
333  // was used to create the hypothesis
334 
335  CVec3dArray* paPointsThatMovedConsistently; // points that on validation moved consistently with
336  // the transformation of the object
337 
338  CSIFTFeatureArray* paFeatureDescriptors; // contains the SIFT descriptors of the points
339 
340  Vec3d vNormal; // if hypothesis is a plane, this is the plane normal.
341  // if it is a cylinder, it is the normal of the cylinder surface pointing
342  // approximately towards the camera.
343 
344  Vec3d vCylinderAxis; // only valid if the object is a cylinder
345 
346  Vec3d vSecondAxis, vThirdAxis; // axes that span an orthonormal coordinate system together
347  // with the plane normal or the cylinder axis
348 
349  Vec3d vCenter; // a point on the plane or on the cylinder axis
350 
351  float fStdDev1, fStdDev2; // standard deviations along vSecondAxis and vThirdAxis in the case of a plane,
352  // along cylinder axis and vSecondAxis in the case of a cylinder
353 
354  float fCylinderRadius; // only valid if the object is a cylinder
355 
356 };
357 */
358 
359 using CObjectHypothesisArray = CDynamicArrayTemplate<CObjectHypothesis*>;
CMSERDescriptor
Definition: ObjectHypothesis.h:35
CHypothesisPoint::eMSER
@ eMSER
Definition: ObjectHypothesis.h:234
CMSERDescriptor::CMSERDescriptor
CMSERDescriptor()
Definition: ObjectHypothesis.h:38
CMSERDescriptor3D::CMSERDescriptor3D
CMSERDescriptor3D()
Definition: ObjectHypothesis.h:100
CObjectHypothesis::eSphere
@ eSphere
Definition: ObjectHypothesis.h:285
CMSERDescriptor3D::vSigmaPoint1a
Vec3d vSigmaPoint1a
Definition: ObjectHypothesis.h:160
CHypothesisPoint::pMSERDescriptor
CMSERDescriptor3D * pMSERDescriptor
Definition: ObjectHypothesis.h:244
CHypothesisPoint::vOldPosition
Vec3d vOldPosition
Definition: ObjectHypothesis.h:239
CSIFTFeatureArray
CDynamicArrayTemplate< CSIFTFeatureEntry * > CSIFTFeatureArray
Definition: ObjectHypothesis.h:168
CHypothesisPoint::CHypothesisPoint
CHypothesisPoint()
Definition: ObjectHypothesis.h:174
CHypothesisPoint::fIntensity
float fIntensity
Definition: ObjectHypothesis.h:241
CMSERDescriptor::vEigenvector1
Vec2d vEigenvector1
Definition: ObjectHypothesis.h:87
CObjectHypothesis::fRadius
float fRadius
Definition: ObjectHypothesis.h:313
GfxTL::Vec2d
VectorXD< 2, double > Vec2d
Definition: VectorXD.h:694
CHypothesisPoint::eHarrisCornerPoint
@ eHarrisCornerPoint
Definition: ObjectHypothesis.h:233
CHypothesisPoint::EPointType
EPointType
Definition: ObjectHypothesis.h:231
CMSERDescriptor3D::vSigmaPoint2a
Vec3d vSigmaPoint2a
Definition: ObjectHypothesis.h:160
CHypothesisPoint::~CHypothesisPoint
~CHypothesisPoint()
Definition: ObjectHypothesis.h:181
CObjectHypothesis::eType
eObjectType eType
Definition: ObjectHypothesis.h:289
CHypothesisPoint::fColorG
float fColorG
Definition: ObjectHypothesis.h:241
CObjectHypothesis::vThirdAxis
Vec3d vThirdAxis
Definition: ObjectHypothesis.h:305
CMSERDescriptor::vEigenvector2
Vec2d vEigenvector2
Definition: ObjectHypothesis.h:87
CMSERDescriptor::fAverageSaturationSurroundingRegion
float fAverageSaturationSurroundingRegion
Definition: ObjectHypothesis.h:92
CMSERDescriptor3D::~CMSERDescriptor3D
~CMSERDescriptor3D()
Definition: ObjectHypothesis.h:106
CHypothesisPoint::vPosition
Vec3d vPosition
Definition: ObjectHypothesis.h:238
CMSERDescriptor::pPoints2D
std::vector< Vec2d > * pPoints2D
Definition: ObjectHypothesis.h:79
OLP_SIZE_MSER_HISTOGRAM
#define OLP_SIZE_MSER_HISTOGRAM
Definition: ObjectLearningByPushingDefinitions.h:216
CMSERDescriptor3D::vPosition
Vec3d vPosition
Definition: ObjectHypothesis.h:158
ObjectLearningByPushingDefinitions.h
CObjectHypothesis::eRGBD
@ eRGBD
Definition: ObjectHypothesis.h:285
CMSERDescriptor3D::vSigmaPoint1b
Vec3d vSigmaPoint1b
Definition: ObjectHypothesis.h:160
CHypothesisPoint
Definition: ObjectHypothesis.h:171
CObjectHypothesis::CObjectHypothesis
CObjectHypothesis()
Definition: ObjectHypothesis.h:252
CObjectHypothesis::vLastTranslation
Vec3d vLastTranslation
Definition: ObjectHypothesis.h:318
CMSERDescriptor3D
Definition: ObjectHypothesis.h:97
CHypothesisPoint::GetCopy
CHypothesisPoint * GetCopy()
Definition: ObjectHypothesis.h:200
CObjectHypothesis::vCylinderAxis
Vec3d vCylinderAxis
Definition: ObjectHypothesis.h:303
GfxTL::Vec3d
VectorXD< 3, double > Vec3d
Definition: VectorXD.h:695
CMSERDescriptor::nSize
int nSize
Definition: ObjectHypothesis.h:81
CObjectHypothesis::vCenter
Vec3d vCenter
Definition: ObjectHypothesis.h:308
CObjectHypothesis::nHypothesisNumber
int nHypothesisNumber
Definition: ObjectHypothesis.h:287
CObjectHypothesis::aVisibleConfirmedPoints
std::vector< CHypothesisPoint * > aVisibleConfirmedPoints
Definition: ObjectHypothesis.h:294
CHypothesisPoint::pFeatureDescriptors
CSIFTFeatureArray * pFeatureDescriptors
Definition: ObjectHypothesis.h:243
CMSERDescriptor::fEigenvalue1
float fEigenvalue1
Definition: ObjectHypothesis.h:85
CMSERDescriptor3D::pRegionLeft
CMSERDescriptor * pRegionLeft
Definition: ObjectHypothesis.h:156
CHypothesisPoint::eDepthMapPoint
@ eDepthMapPoint
Definition: ObjectHypothesis.h:235
CMSERDescriptor3D::pRegionRight
CMSERDescriptor * pRegionRight
Definition: ObjectHypothesis.h:156
CMSERDescriptor3D::vSigmaPoint2b
Vec3d vSigmaPoint2b
Definition: ObjectHypothesis.h:160
CObjectHypothesis::fStdDev2
float fStdDev2
Definition: ObjectHypothesis.h:310
CMSERDescriptor::fAverageSaturationInnerPoints
float fAverageSaturationInnerPoints
Definition: ObjectHypothesis.h:90
CObjectHypothesis::eSingleColored
@ eSingleColored
Definition: ObjectHypothesis.h:285
CHypothesisPoint::fColorR
float fColorR
Definition: ObjectHypothesis.h:241
CObjectHypothesis
Definition: ObjectHypothesis.h:249
CObjectHypothesis::fStdDev1
float fStdDev1
Definition: ObjectHypothesis.h:310
CMSERDescriptor::vMean
Vec2d vMean
Definition: ObjectHypothesis.h:83
CObjectHypothesis::fMaxExtent
float fMaxExtent
Definition: ObjectHypothesis.h:315
CMSERDescriptor::GetCopy
CMSERDescriptor * GetCopy()
Definition: ObjectHypothesis.h:43
CObjectHypothesis::eUnstructured
@ eUnstructured
Definition: ObjectHypothesis.h:285
CObjectHypothesisArray
CDynamicArrayTemplate< CObjectHypothesis * > CObjectHypothesisArray
Definition: ObjectHypothesis.h:359
CObjectHypothesis::mLastRotation
Mat3d mLastRotation
Definition: ObjectHypothesis.h:317
CObjectHypothesis::aNewPoints
std::vector< CHypothesisPoint * > aNewPoints
Definition: ObjectHypothesis.h:291
CMSERDescriptor3D::GetCopy
CMSERDescriptor3D * GetCopy()
Definition: ObjectHypothesis.h:131
CObjectHypothesis::aDoubtablePoints
std::vector< CHypothesisPoint * > aDoubtablePoints
Definition: ObjectHypothesis.h:293
CHypothesisPoint::ePointType
EPointType ePointType
Definition: ObjectHypothesis.h:240
CObjectHypothesis::vSecondAxis
Vec3d vSecondAxis
Definition: ObjectHypothesis.h:305
CObjectHypothesis::aConfirmedPoints
std::vector< CHypothesisPoint * > aConfirmedPoints
Definition: ObjectHypothesis.h:292
CObjectHypothesis::ePlane
@ ePlane
Definition: ObjectHypothesis.h:285
CMSERDescriptor::fEigenvalue2
float fEigenvalue2
Definition: ObjectHypothesis.h:85
CHypothesisPoint::fColorB
float fColorB
Definition: ObjectHypothesis.h:241
CHypothesisPoint::fMembershipProbability
float fMembershipProbability
Definition: ObjectHypothesis.h:242
CObjectHypothesis::eObjectType
eObjectType
Definition: ObjectHypothesis.h:285
CObjectHypothesis::vNormal
Vec3d vNormal
Definition: ObjectHypothesis.h:299
CMSERDescriptor::pHueHistogramSurroundingRegion
float pHueHistogramSurroundingRegion[OLP_SIZE_MSER_HISTOGRAM]
Definition: ObjectHypothesis.h:91
CObjectHypothesis::eCylinder
@ eCylinder
Definition: ObjectHypothesis.h:285
CObjectHypothesis::~CObjectHypothesis
~CObjectHypothesis()
Definition: ObjectHypothesis.h:261
CObjectHypothesis::aHypothesisHasMoved
std::vector< bool > aHypothesisHasMoved
Definition: ObjectHypothesis.h:297
CMSERDescriptor::pHueHistogramInnerPoints
float pHueHistogramInnerPoints[OLP_SIZE_MSER_HISTOGRAM]
Definition: ObjectHypothesis.h:89