Point Cloud Library (PCL)
1.15.1
Toggle main menu visibility
Loading...
Searching...
No Matches
pcl
segmentation
unary_classifier.h
1
/*
2
* Software License Agreement (BSD License)
3
*
4
* Point Cloud Library (PCL) - www.pointclouds.org
5
*
6
* All rights reserved.
7
*
8
* Redistribution and use in source and binary forms, with or without
9
* modification, are permitted provided that the following conditions
10
* are met:
11
*
12
* * Redistributions of source code must retain the above copyright
13
* notice, this list of conditions and the following disclaimer.
14
* * Redistributions in binary form must reproduce the above
15
* copyright notice, this list of conditions and the following
16
* disclaimer in the documentation and/or other materials provided
17
* with the distribution.
18
* * Neither the name of the copyright holder(s) nor the names of its
19
* contributors may be used to endorse or promote products derived
20
* from this software without specific prior written permission.
21
*
22
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
25
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
27
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
28
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
30
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
32
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33
* POSSIBILITY OF SUCH DAMAGE.
34
*
35
* Author : Christian Potthast
36
* Email : potthast@usc.edu
37
*
38
*/
39
40
#pragma once
41
42
#include <
pcl/memory.h
>
43
#include <
pcl/pcl_macros.h
>
44
#include <pcl/point_cloud.h>
45
#include <
pcl/point_types.h
>
46
47
#include <pcl/features/fpfh.h>
48
49
#include <pcl/ml/kmeans.h>
50
51
namespace
pcl
52
{
53
/** \brief
54
*
55
*/
56
template
<
typename
Po
int
T>
57
class
PCL_EXPORTS
UnaryClassifier
58
{
59
public
:
60
61
/** \brief Constructor that sets default values for member variables. */
62
UnaryClassifier
();
63
64
/** \brief This destructor destroys the cloud...
65
*
66
*/
67
~UnaryClassifier
();
68
69
/** \brief This method sets the input cloud.
70
* \param[in] input_cloud input point cloud
71
*/
72
void
73
setInputCloud
(
typename
pcl::PointCloud<PointT>::Ptr
input_cloud);
74
75
void
76
train
(
pcl::PointCloud<pcl::FPFHSignature33>::Ptr
&output);
77
78
void
79
trainWithLabel
(std::vector<
pcl::PointCloud<pcl::FPFHSignature33>
, Eigen::aligned_allocator<
pcl::PointCloud<pcl::FPFHSignature33>
> > &output);
80
81
void
82
segment
(
pcl::PointCloud<pcl::PointXYZRGBL>::Ptr
&out);
83
84
void
85
queryFeatureDistances
(std::vector<
pcl::PointCloud<pcl::FPFHSignature33>::Ptr
> &trained_features,
86
pcl::PointCloud<pcl::FPFHSignature33>::Ptr
query_features,
87
pcl::Indices
&indi,
88
std::vector<float> &dist);
89
90
void
91
assignLabels
(
pcl::Indices
&indi,
92
std::vector<float> &dist,
93
int
n_feature_means,
94
float
feature_threshold,
95
pcl::PointCloud<pcl::PointXYZRGBL>::Ptr
out);
96
97
void
98
setClusterSize
(
unsigned
int
k){
cluster_size_
= k;};
99
100
void
101
setNormalRadiusSearch
(
float
param){
normal_radius_search_
= param;};
102
103
void
104
setFPFHRadiusSearch
(
float
param){
fpfh_radius_search_
= param;};
105
106
void
107
setLabelField
(
bool
l){
label_field_
= l;};
108
109
void
110
setTrainedFeatures
(std::vector<
pcl::PointCloud<pcl::FPFHSignature33>::Ptr
> &
features
){
trained_features_
=
features
;};
111
112
void
113
setFeatureThreshold
(
float
threshold){
feature_threshold_
= threshold;};
114
115
protected
:
116
117
void
118
convertCloud (
typename
pcl::PointCloud<PointT>::Ptr
in,
119
pcl::PointCloud<pcl::PointXYZ>::Ptr
out);
120
121
void
122
convertCloud (
typename
pcl::PointCloud<PointT>::Ptr
in,
123
pcl::PointCloud<pcl::PointXYZRGBL>::Ptr
out);
124
125
void
126
findClusters (
typename
pcl::PointCloud<PointT>::Ptr
in,
127
std::vector<int> &cluster_numbers);
128
129
void
130
getCloudWithLabel (
typename
pcl::PointCloud<PointT>::Ptr
in,
131
pcl::PointCloud<pcl::PointXYZ>::Ptr
out,
132
int
label_num);
133
134
void
135
computeFPFH (
pcl::PointCloud<pcl::PointXYZ>::Ptr
in,
136
pcl::PointCloud<pcl::FPFHSignature33>::Ptr
out,
137
float
normal_radius_search,
138
float
fpfh_radius_search);
139
140
void
141
kmeansClustering (
pcl::PointCloud<pcl::FPFHSignature33>::Ptr
in,
142
pcl::PointCloud<pcl::FPFHSignature33>::Ptr
out,
143
int
k);
144
145
146
147
/** \brief Contains the input cloud */
148
typename
pcl::PointCloud<PointT>::Ptr
input_cloud_
{
new
pcl::PointCloud<PointT>
};
149
150
bool
label_field_
{
false
};
151
152
unsigned
int
cluster_size_
{0};
153
154
float
normal_radius_search_
{0.01f};
155
float
fpfh_radius_search_
{0.05f};
156
float
feature_threshold_
{5.0};
157
158
159
std::vector<pcl::PointCloud<pcl::FPFHSignature33>::Ptr>
trained_features_
{};
160
161
/** \brief Contains normals of the points that will be segmented. */
162
//typename pcl::PointCloud<pcl::Normal>::Ptr normals_;
163
164
/** \brief Stores the cloud that will be segmented. */
165
//typename pcl::PointCloud<PointT>::Ptr cloud_for_segmentation_;
166
167
public
:
168
PCL_MAKE_ALIGNED_OPERATOR_NEW
169
};
170
}
171
172
#ifdef PCL_NO_PRECOMPILE
173
#include <pcl/segmentation/impl/unary_classifier.hpp>
174
#endif
pcl::PointCloud
PointCloud represents the base class in PCL for storing collections of 3D points.
Definition
point_cloud.h:174
pcl::PointCloud::Ptr
shared_ptr< PointCloud< PointT > > Ptr
Definition
point_cloud.h:414
pcl::UnaryClassifier::setFPFHRadiusSearch
void setFPFHRadiusSearch(float param)
Definition
unary_classifier.h:104
pcl::UnaryClassifier::setTrainedFeatures
void setTrainedFeatures(std::vector< pcl::PointCloud< pcl::FPFHSignature33 >::Ptr > &features)
Definition
unary_classifier.h:110
pcl::UnaryClassifier::setNormalRadiusSearch
void setNormalRadiusSearch(float param)
Definition
unary_classifier.h:101
pcl::UnaryClassifier::segment
void segment(pcl::PointCloud< pcl::PointXYZRGBL >::Ptr &out)
Definition
unary_classifier.hpp:395
pcl::UnaryClassifier::setInputCloud
void setInputCloud(typename pcl::PointCloud< PointT >::Ptr input_cloud)
This method sets the input cloud.
Definition
unary_classifier.hpp:63
pcl::UnaryClassifier::setClusterSize
void setClusterSize(unsigned int k)
Definition
unary_classifier.h:98
pcl::UnaryClassifier::train
void train(pcl::PointCloud< pcl::FPFHSignature33 >::Ptr &output)
Definition
unary_classifier.hpp:346
pcl::UnaryClassifier::cluster_size_
unsigned int cluster_size_
Definition
unary_classifier.h:152
pcl::UnaryClassifier::input_cloud_
pcl::PointCloud< PointT >::Ptr input_cloud_
Contains the input cloud.
Definition
unary_classifier.h:148
pcl::UnaryClassifier::setLabelField
void setLabelField(bool l)
Definition
unary_classifier.h:107
pcl::UnaryClassifier::queryFeatureDistances
void queryFeatureDistances(std::vector< pcl::PointCloud< pcl::FPFHSignature33 >::Ptr > &trained_features, pcl::PointCloud< pcl::FPFHSignature33 >::Ptr query_features, pcl::Indices &indi, std::vector< float > &dist)
Definition
unary_classifier.hpp:263
pcl::UnaryClassifier::assignLabels
void assignLabels(pcl::Indices &indi, std::vector< float > &dist, int n_feature_means, float feature_threshold, pcl::PointCloud< pcl::PointXYZRGBL >::Ptr out)
Definition
unary_classifier.hpp:320
pcl::UnaryClassifier::setFeatureThreshold
void setFeatureThreshold(float threshold)
Definition
unary_classifier.h:113
pcl::UnaryClassifier::UnaryClassifier
UnaryClassifier()
Constructor that sets default values for member variables.
pcl::UnaryClassifier::feature_threshold_
float feature_threshold_
Definition
unary_classifier.h:156
pcl::UnaryClassifier::normal_radius_search_
float normal_radius_search_
Definition
unary_classifier.h:154
pcl::UnaryClassifier::~UnaryClassifier
~UnaryClassifier()
This destructor destroys the cloud...
pcl::UnaryClassifier::trainWithLabel
void trainWithLabel(std::vector< pcl::PointCloud< pcl::FPFHSignature33 >, Eigen::aligned_allocator< pcl::PointCloud< pcl::FPFHSignature33 > > > &output)
Definition
unary_classifier.hpp:364
pcl::UnaryClassifier::label_field_
bool label_field_
Definition
unary_classifier.h:150
pcl::UnaryClassifier::fpfh_radius_search_
float fpfh_radius_search_
Definition
unary_classifier.h:155
pcl::UnaryClassifier::trained_features_
std::vector< pcl::PointCloud< pcl::FPFHSignature33 >::Ptr > trained_features_
Definition
unary_classifier.h:159
point_types.h
Defines all the PCL implemented PointT point type structures.
PCL_MAKE_ALIGNED_OPERATOR_NEW
#define PCL_MAKE_ALIGNED_OPERATOR_NEW
Macro to signal a class requires a custom allocator.
Definition
memory.h:86
memory.h
Defines functions, macros and traits for allocating and using memory.
pcl::features
Definition
from_meshes.h:9
pcl
Definition
convolution.h:46
pcl::Indices
IndicesAllocator<> Indices
Type used for indices in PCL.
Definition
types.h:133
pcl_macros.h
Defines all the PCL and non-PCL macros used.