Point Cloud Library (PCL)
1.7.0
Main Page
Modules
Namespaces
Classes
recognition
include
pcl
recognition
ransac_based
hypothesis.h
1
/*
2
* Software License Agreement (BSD License)
3
*
4
* Point Cloud Library (PCL) - www.pointclouds.org
5
* Copyright (c) 2010-2012, Willow Garage, Inc.
6
*
7
* All rights reserved.
8
*
9
* Redistribution and use in source and binary forms, with or without
10
* modification, are permitted provided that the following conditions
11
* are met:
12
*
13
* * Redistributions of source code must retain the above copyright
14
* notice, this list of conditions and the following disclaimer.
15
* * Redistributions in binary form must reproduce the above
16
* copyright notice, this list of conditions and the following
17
* disclaimer in the documentation and/or other materials provided
18
* with the distribution.
19
* * Neither the name of Willow Garage, Inc. nor the names of its
20
* contributors may be used to endorse or promote products derived
21
* from this software without specific prior written permission.
22
*
23
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
26
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
27
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
28
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
29
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
31
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
33
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34
* POSSIBILITY OF SUCH DAMAGE.
35
*
36
*
37
*/
38
39
/*
40
* hypothesis.h
41
*
42
* Created on: Mar 12, 2013
43
* Author: papazov
44
*/
45
46
#ifndef PCL_RECOGNITION_HYPOTHESIS_H_
47
#define PCL_RECOGNITION_HYPOTHESIS_H_
48
49
#include <pcl/recognition/ransac_based/model_library.h>
50
#include <pcl/recognition/ransac_based/auxiliary.h>
51
52
namespace
pcl
53
{
54
namespace
recognition
55
{
56
class
HypothesisBase
57
{
58
public
:
59
HypothesisBase
(
const
ModelLibrary::Model
* obj_model)
60
:
obj_model_
(obj_model)
61
{}
62
63
HypothesisBase
(
const
ModelLibrary::Model
* obj_model,
const
float
* rigid_transform)
64
:
obj_model_
(obj_model)
65
{
66
memcpy (
rigid_transform_
, rigid_transform, 12*
sizeof
(
float
));
67
}
68
69
virtual
~HypothesisBase
(){}
70
71
void
72
setModel
(
const
ModelLibrary::Model
* model)
73
{
74
obj_model_
= model;
75
}
76
77
public
:
78
float
rigid_transform_
[12];
79
const
ModelLibrary::Model
*
obj_model_
;
80
};
81
82
class
Hypothesis
:
public
HypothesisBase
83
{
84
public
:
85
Hypothesis
(
const
ModelLibrary::Model
* obj_model = NULL)
86
:
HypothesisBase
(obj_model),
87
match_confidence_
(-1.0f),
88
linear_id_
(-1)
89
{
90
}
91
92
Hypothesis
(
const
Hypothesis
& src)
93
:
HypothesisBase
(src.
obj_model_
, src.
rigid_transform_
),
94
match_confidence_
(src.
match_confidence_
),
95
explained_pixels_
(src.
explained_pixels_
)
96
{
97
}
98
99
virtual
~Hypothesis
(){}
100
101
const
Hypothesis
&
102
operator =
(
const
Hypothesis
& src)
103
{
104
memcpy (this->
rigid_transform_
, src.
rigid_transform_
, 12*sizeof (
float
));
105
this->
obj_model_
= src.
obj_model_
;
106
this->
match_confidence_
= src.
match_confidence_
;
107
this->
explained_pixels_
= src.
explained_pixels_
;
108
109
return
*
this
;
110
}
111
112
void
113
setLinearId
(
int
id
)
114
{
115
linear_id_
= id;
116
}
117
118
int
119
getLinearId
()
const
120
{
121
return
(
linear_id_
);
122
}
123
124
void
125
computeBounds
(
float
bounds[6])
const
126
{
127
const
float
*b =
obj_model_
->
getBoundsOfOctreePoints
();
128
float
p[3];
129
130
// Initialize 'bounds'
131
aux::transform
(
rigid_transform_
, b[0], b[2], b[4], p);
132
bounds[0] = bounds[1] = p[0];
133
bounds[2] = bounds[3] = p[1];
134
bounds[4] = bounds[5] = p[2];
135
136
// Expand 'bounds' to contain the other 7 points of the octree bounding box
137
aux::transform
(
rigid_transform_
, b[0], b[2], b[5], p);
aux::expandBoundingBoxToContainPoint
(bounds, p);
138
aux::transform
(
rigid_transform_
, b[0], b[3], b[4], p);
aux::expandBoundingBoxToContainPoint
(bounds, p);
139
aux::transform
(
rigid_transform_
, b[0], b[3], b[5], p);
aux::expandBoundingBoxToContainPoint
(bounds, p);
140
aux::transform
(
rigid_transform_
, b[1], b[2], b[4], p);
aux::expandBoundingBoxToContainPoint
(bounds, p);
141
aux::transform
(
rigid_transform_
, b[1], b[2], b[5], p);
aux::expandBoundingBoxToContainPoint
(bounds, p);
142
aux::transform
(
rigid_transform_
, b[1], b[3], b[4], p);
aux::expandBoundingBoxToContainPoint
(bounds, p);
143
aux::transform
(
rigid_transform_
, b[1], b[3], b[5], p);
aux::expandBoundingBoxToContainPoint
(bounds, p);
144
}
145
146
void
147
computeCenterOfMass
(
float
center_of_mass[3])
const
148
{
149
aux::transform
(
rigid_transform_
,
obj_model_
->
getOctreeCenterOfMass
(), center_of_mass);
150
}
151
152
public
:
153
float
match_confidence_
;
154
std::set<int>
explained_pixels_
;
155
int
linear_id_
;
156
};
157
}
// namespace recognition
158
}
// namespace pcl
159
160
#endif
/* PCL_RECOGNITION_HYPOTHESIS_H_ */