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{
36public:
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
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
82 Vec2d vMean;
83
85
87
92};
93
95{
96public:
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 {
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
164using CSIFTFeatureArray = CDynamicArrayTemplate<CSIFTFeatureEntry*>;
165
167{
168public:
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 {
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 {
210 pRet->pMSERDescriptor = pMSERDescriptor->GetCopy();
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
234
242};
243
245{
246public:
248 {
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
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/*
326struct 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
362using CObjectHypothesisArray = CDynamicArrayTemplate<CObjectHypothesis*>;
CDynamicArrayTemplate< CSIFTFeatureEntry * > CSIFTFeatureArray
CDynamicArrayTemplate< CObjectHypothesis * > CObjectHypothesisArray
#define OLP_SIZE_MSER_HISTOGRAM
CSIFTFeatureArray * pFeatureDescriptors
CHypothesisPoint * GetCopy()
CMSERDescriptor3D * pMSERDescriptor
CMSERDescriptor3D * GetCopy()
CMSERDescriptor * pRegionLeft
CMSERDescriptor * pRegionRight
float pHueHistogramSurroundingRegion[OLP_SIZE_MSER_HISTOGRAM]
std::vector< Vec2d > * pPoints2D
CMSERDescriptor * GetCopy()
float fAverageSaturationSurroundingRegion
float pHueHistogramInnerPoints[OLP_SIZE_MSER_HISTOGRAM]
float fAverageSaturationInnerPoints
std::vector< CHypothesisPoint * > aNewPoints
std::vector< bool > aHypothesisHasMoved
std::vector< CHypothesisPoint * > aDoubtablePoints
std::vector< CHypothesisPoint * > aConfirmedPoints
std::vector< CHypothesisPoint * > aVisibleConfirmedPoints