Point Cloud Library (PCL)
1.15.1
Toggle main menu visibility
Loading...
Searching...
No Matches
pcl
recognition
ransac_based
orr_octree_zprojection.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
* orr_octree_zprojection.h
41
*
42
* Created on: Nov 17, 2012
43
* Author: papazov
44
*/
45
46
#pragma once
47
48
#include "orr_octree.h"
49
#include <pcl/pcl_exports.h>
50
#include <set>
51
52
namespace
pcl
53
{
54
namespace
recognition
55
{
56
class
PCL_EXPORTS
ORROctreeZProjection
57
{
58
public
:
59
class
Pixel
60
{
61
public
:
62
Pixel
(
int
id
):
id_
(id) {}
63
64
inline
void
65
set_z1
(
float
z1
) {
z1_
=
z1
;}
66
67
inline
void
68
set_z2
(
float
z2
) {
z2_
=
z2
;}
69
70
float
71
z1
()
const
{
return
z1_
;}
72
73
float
74
z2
()
const
{
return
z2_
;}
75
76
int
77
getId
()
const
{
return
id_
;}
78
79
protected
:
80
float
z1_
,
z2_
;
81
int
id_
;
82
};
83
84
public
:
85
class
Set
86
{
87
public
:
88
Set
(
int
x,
int
y)
89
:
nodes_
(
compare_nodes_z
),
x_
(x),
y_
(y)
90
{}
91
92
static
inline
bool
93
compare_nodes_z
(
ORROctree::Node
* node1,
ORROctree::Node
* node2)
94
{
95
return
node1->
getData
()->
get3dIdZ
() < node2->
getData
()->
get3dIdZ
();
96
}
97
98
inline
void
99
insert
(
ORROctree::Node
* leaf) {
nodes_
.insert(leaf);}
100
101
inline
std::set<
ORROctree::Node
*, bool(*)(
ORROctree::Node
*,
ORROctree::Node
*)>&
102
get_nodes
(){
return
nodes_
;}
103
104
inline
int
105
get_x
()
const
{
return
x_
;}
106
107
inline
int
108
get_y
()
const
{
return
y_
;}
109
110
protected
:
111
std::set<
ORROctree::Node
*, bool(*)(
ORROctree::Node
*,
ORROctree::Node
*)>
nodes_
;
112
int
x_
,
y_
;
113
};
114
115
public
:
116
ORROctreeZProjection
() =
default
;
117
118
virtual
~ORROctreeZProjection
(){ this->
clear
();}
119
120
void
121
build
(
const
ORROctree
& input,
float
eps_front,
float
eps_back);
122
123
void
124
clear
();
125
126
inline
void
127
getPixelCoordinates
(
const
float
* p,
int
& x,
int
& y)
const
128
{
129
x =
static_cast<
int
>
((p[0] -
bounds_
[0])*
inv_pixel_size_
);
130
y =
static_cast<
int
>
((p[1] -
bounds_
[2])*
inv_pixel_size_
);
131
}
132
133
inline
const
Pixel*
134
getPixel
(
const
float
* p)
const
135
{
136
int
x, y; this->
getPixelCoordinates
(p, x, y);
137
138
if
( x < 0 || x >=
num_pixels_x_
)
return
(
nullptr
);
139
if
( y < 0 || y >=
num_pixels_y_
)
return
(
nullptr
);
140
141
return
(
pixels_
[x][y]);
142
}
143
144
inline
Pixel*
145
getPixel
(
const
float
* p)
146
{
147
int
x, y; this->
getPixelCoordinates
(p, x, y);
148
149
if
( x < 0 || x >=
num_pixels_x_
)
return
(
nullptr
);
150
if
( y < 0 || y >=
num_pixels_y_
)
return
(
nullptr
);
151
152
return
(
pixels_
[x][y]);
153
}
154
155
inline
const
std::set<
ORROctree::Node
*, bool(*)(
ORROctree::Node
*,
ORROctree::Node
*)>*
156
getOctreeNodes
(
const
float
* p)
const
157
{
158
int
x, y; this->
getPixelCoordinates
(p, x, y);
159
160
if
( x < 0 || x >=
num_pixels_x_
)
return
(
nullptr
);
161
if
( y < 0 || y >=
num_pixels_y_
)
return
(
nullptr
);
162
163
if
( !
sets_
[x][y] )
164
return
nullptr
;
165
166
return
(&
sets_
[x][y]->get_nodes ());
167
}
168
169
inline
std::list<Pixel*>&
170
getFullPixels
(){
return
full_pixels_
;}
171
172
inline
const
Pixel*
173
getPixel
(
int
i,
int
j)
const
174
{
175
return
pixels_
[i][j];
176
}
177
178
inline
float
179
getPixelSize
()
const
180
{
181
return
pixel_size_
;
182
}
183
184
inline
const
float
*
185
getBounds
()
const
186
{
187
return
bounds_
;
188
}
189
190
/** \brief Get the width ('num_x') and height ('num_y') of the image. */
191
inline
void
192
getNumberOfPixels
(
int
& num_x,
int
& num_y)
const
193
{
194
num_x =
num_pixels_x_
;
195
num_y =
num_pixels_y_
;
196
}
197
198
protected
:
199
float
pixel_size_
,
inv_pixel_size_
,
bounds_
[4],
extent_x_
,
extent_y_
;
200
int
num_pixels_x_
,
num_pixels_y_
,
num_pixels_
;
201
Pixel
***
pixels_
{
nullptr
};
202
Set
***
sets_
{
nullptr
};
203
std::list<Set*>
full_sets_
;
204
std::list<Pixel*>
full_pixels_
;
205
};
206
}
// namespace recognition
207
}
// namespace pcl
pcl::recognition::ORROctree::Node::Data::get3dIdZ
int get3dIdZ() const
Definition
orr_octree.h:141
pcl::recognition::ORROctree::Node
Definition
orr_octree.h:76
pcl::recognition::ORROctree::Node::getData
Node::Data * getData()
Definition
orr_octree.h:212
pcl::recognition::ORROctree
That's a very specialized and simple octree class.
Definition
orr_octree.h:69
pcl::recognition::ORROctreeZProjection::Pixel
Definition
orr_octree_zprojection.h:60
pcl::recognition::ORROctreeZProjection::Pixel::z1_
float z1_
Definition
orr_octree_zprojection.h:80
pcl::recognition::ORROctreeZProjection::Pixel::z2
float z2() const
Definition
orr_octree_zprojection.h:74
pcl::recognition::ORROctreeZProjection::Pixel::set_z2
void set_z2(float z2)
Definition
orr_octree_zprojection.h:68
pcl::recognition::ORROctreeZProjection::Pixel::z2_
float z2_
Definition
orr_octree_zprojection.h:80
pcl::recognition::ORROctreeZProjection::Pixel::id_
int id_
Definition
orr_octree_zprojection.h:81
pcl::recognition::ORROctreeZProjection::Pixel::Pixel
Pixel(int id)
Definition
orr_octree_zprojection.h:62
pcl::recognition::ORROctreeZProjection::Pixel::getId
int getId() const
Definition
orr_octree_zprojection.h:77
pcl::recognition::ORROctreeZProjection::Pixel::set_z1
void set_z1(float z1)
Definition
orr_octree_zprojection.h:65
pcl::recognition::ORROctreeZProjection::Pixel::z1
float z1() const
Definition
orr_octree_zprojection.h:71
pcl::recognition::ORROctreeZProjection::Set
Definition
orr_octree_zprojection.h:86
pcl::recognition::ORROctreeZProjection::Set::y_
int y_
Definition
orr_octree_zprojection.h:112
pcl::recognition::ORROctreeZProjection::Set::x_
int x_
Definition
orr_octree_zprojection.h:112
pcl::recognition::ORROctreeZProjection::Set::get_nodes
std::set< ORROctree::Node *, bool(*)(ORROctree::Node *, ORROctree::Node *)> & get_nodes()
Definition
orr_octree_zprojection.h:102
pcl::recognition::ORROctreeZProjection::Set::get_y
int get_y() const
Definition
orr_octree_zprojection.h:108
pcl::recognition::ORROctreeZProjection::Set::Set
Set(int x, int y)
Definition
orr_octree_zprojection.h:88
pcl::recognition::ORROctreeZProjection::Set::get_x
int get_x() const
Definition
orr_octree_zprojection.h:105
pcl::recognition::ORROctreeZProjection::Set::compare_nodes_z
static bool compare_nodes_z(ORROctree::Node *node1, ORROctree::Node *node2)
Definition
orr_octree_zprojection.h:93
pcl::recognition::ORROctreeZProjection::Set::nodes_
std::set< ORROctree::Node *, bool(*)(ORROctree::Node *, ORROctree::Node *)> nodes_
Definition
orr_octree_zprojection.h:111
pcl::recognition::ORROctreeZProjection::Set::insert
void insert(ORROctree::Node *leaf)
Definition
orr_octree_zprojection.h:99
pcl::recognition::ORROctreeZProjection::ORROctreeZProjection
ORROctreeZProjection()=default
pcl::recognition::ORROctreeZProjection::extent_x_
float extent_x_
Definition
orr_octree_zprojection.h:199
pcl::recognition::ORROctreeZProjection::num_pixels_x_
int num_pixels_x_
Definition
orr_octree_zprojection.h:200
pcl::recognition::ORROctreeZProjection::extent_y_
float extent_y_
Definition
orr_octree_zprojection.h:199
pcl::recognition::ORROctreeZProjection::getFullPixels
std::list< Pixel * > & getFullPixels()
Definition
orr_octree_zprojection.h:170
pcl::recognition::ORROctreeZProjection::getPixel
const Pixel * getPixel(int i, int j) const
Definition
orr_octree_zprojection.h:173
pcl::recognition::ORROctreeZProjection::num_pixels_y_
int num_pixels_y_
Definition
orr_octree_zprojection.h:200
pcl::recognition::ORROctreeZProjection::getOctreeNodes
const std::set< ORROctree::Node *, bool(*)(ORROctree::Node *, ORROctree::Node *)> * getOctreeNodes(const float *p) const
Definition
orr_octree_zprojection.h:156
pcl::recognition::ORROctreeZProjection::getPixelCoordinates
void getPixelCoordinates(const float *p, int &x, int &y) const
Definition
orr_octree_zprojection.h:127
pcl::recognition::ORROctreeZProjection::pixel_size_
float pixel_size_
Definition
orr_octree_zprojection.h:199
pcl::recognition::ORROctreeZProjection::getNumberOfPixels
void getNumberOfPixels(int &num_x, int &num_y) const
Get the width ('num_x') and height ('num_y') of the image.
Definition
orr_octree_zprojection.h:192
pcl::recognition::ORROctreeZProjection::num_pixels_
int num_pixels_
Definition
orr_octree_zprojection.h:200
pcl::recognition::ORROctreeZProjection::full_sets_
std::list< Set * > full_sets_
Definition
orr_octree_zprojection.h:203
pcl::recognition::ORROctreeZProjection::~ORROctreeZProjection
virtual ~ORROctreeZProjection()
Definition
orr_octree_zprojection.h:118
pcl::recognition::ORROctreeZProjection::clear
void clear()
pcl::recognition::ORROctreeZProjection::build
void build(const ORROctree &input, float eps_front, float eps_back)
pcl::recognition::ORROctreeZProjection::getPixel
Pixel * getPixel(const float *p)
Definition
orr_octree_zprojection.h:145
pcl::recognition::ORROctreeZProjection::full_pixels_
std::list< Pixel * > full_pixels_
Definition
orr_octree_zprojection.h:204
pcl::recognition::ORROctreeZProjection::pixels_
Pixel *** pixels_
Definition
orr_octree_zprojection.h:201
pcl::recognition::ORROctreeZProjection::getPixelSize
float getPixelSize() const
Definition
orr_octree_zprojection.h:179
pcl::recognition::ORROctreeZProjection::bounds_
float bounds_[4]
Definition
orr_octree_zprojection.h:199
pcl::recognition::ORROctreeZProjection::sets_
Set *** sets_
Definition
orr_octree_zprojection.h:202
pcl::recognition::ORROctreeZProjection::inv_pixel_size_
float inv_pixel_size_
Definition
orr_octree_zprojection.h:199
pcl::recognition::ORROctreeZProjection::getPixel
const Pixel * getPixel(const float *p) const
Definition
orr_octree_zprojection.h:134
pcl::recognition::ORROctreeZProjection::getBounds
const float * getBounds() const
Definition
orr_octree_zprojection.h:185
pcl::recognition
Definition
hough_3d.h:52
pcl
Definition
convolution.h:46