Point Cloud Library (PCL)
1.6.0
Main Page
Modules
Namespaces
Classes
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
segmentation
include
pcl
segmentation
organized_connected_component_segmentation.h
Go to the documentation of this file.
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
#ifndef PCL_SEGMENTATION_ORGANIZED_CONNECTED_COMPONENT_SEGMENTATION_H_
41
#define PCL_SEGMENTATION_ORGANIZED_CONNECTED_COMPONENT_SEGMENTATION_H_
42
43
#include <
pcl/pcl_base.h
>
44
#include <
pcl/PointIndices.h
>
45
#include <
pcl/segmentation/comparator.h
>
46
47
namespace
pcl
48
{
58
template
<
typename
Po
int
T,
typename
Po
int
LT>
59
class
OrganizedConnectedComponentSegmentation
:
public
PCLBase
<PointT>
60
{
61
using
PCLBase<PointT>::input_
;
62
using
PCLBase<PointT>::indices_
;
63
using
PCLBase<PointT>::initCompute
;
64
using
PCLBase<PointT>::deinitCompute
;
65
66
public
:
67
typedef
typename
pcl::PointCloud<PointT>
PointCloud
;
68
typedef
typename
PointCloud::Ptr
PointCloudPtr
;
69
typedef
typename
PointCloud::ConstPtr
PointCloudConstPtr
;
70
71
typedef
typename
pcl::PointCloud<PointLT>
PointCloudL
;
72
typedef
typename
PointCloudL::Ptr
PointCloudLPtr
;
73
typedef
typename
PointCloudL::ConstPtr
PointCloudLConstPtr
;
74
75
typedef
typename
pcl::Comparator<PointT>
Comparator
;
76
typedef
typename
Comparator::Ptr
ComparatorPtr
;
77
typedef
typename
Comparator::ConstPtr
ComparatorConstPtr
;
78
82
OrganizedConnectedComponentSegmentation
(
const
ComparatorConstPtr
& compare)
83
: compare_ (compare)
84
{
85
}
86
88
virtual
89
~OrganizedConnectedComponentSegmentation
()
90
{
91
}
92
96
void
97
setComparator
(
const
ComparatorConstPtr
& compare)
98
{
99
compare_ = compare;
100
}
101
103
ComparatorConstPtr
104
getComparator
()
const
{
return
(compare_); }
105
110
void
111
segment
(
pcl::PointCloud<PointLT>
& labels, std::vector<pcl::PointIndices>& label_indices)
const
;
112
118
static
void
119
findLabeledRegionBoundary
(
int
start_idx,
PointCloudLPtr
labels,
pcl::PointIndices
& boundary_indices);
120
121
122
protected
:
123
ComparatorConstPtr
compare_;
124
125
inline
unsigned
126
findRoot (
const
std::vector<unsigned>& runs,
unsigned
index)
const
127
{
128
register
unsigned
idx = index;
129
while
(runs[idx] != idx)
130
idx = runs[idx];
131
132
return
(idx);
133
}
134
135
private
:
136
struct
Neighbor
137
{
138
Neighbor (
int
dx,
int
dy,
int
didx)
139
: d_x (dx)
140
, d_y (dy)
141
, d_index (didx)
142
{}
143
144
int
d_x;
145
int
d_y;
146
int
d_index;
// = dy * width + dx: pre-calculated
147
};
148
};
149
}
150
151
#endif //#ifndef PCL_ORGANIZED_CONNECTED_COMPONENT_SEGMENTATION_H_
Generated on Sat Aug 24 2013 17:28:39 for Point Cloud Library (PCL) by
1.8.4