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