Point Cloud Library (PCL)
1.15.1
Toggle main menu visibility
Loading...
Searching...
No Matches
pcl
filters
farthest_point_sampling.h
1
/*
2
* SPDX-License-Identifier: BSD-3-Clause
3
*
4
* Point Cloud Library (PCL) - www.pointclouds.org
5
* Copyright (c) 2020-, Open Perception, Inc.
6
*
7
* All rights reserved
8
*/
9
10
#pragma once
11
12
#include <pcl/filters/filter_indices.h>
13
14
#include <climits>
15
#include <random>
16
17
namespace
pcl
18
{
19
/** \brief @b FarthestPointSampling applies farthest point sampling using euclidean
20
* distance, starting with a random point, utilizing a naive method.
21
* \author Haritha Jayasinghe
22
* \ingroup filters
23
* \todo add support to export/import distance metric
24
*/
25
template
<
typename
Po
int
T>
26
class
FarthestPointSampling
:
public
FilterIndices
<PointT>
27
{
28
using
PCLBase
<PointT>
::input_
;
29
using
PCLBase
<PointT>
::indices_
;
30
using
Filter
<PointT>
::filter_name_
;
31
using
FilterIndices
<PointT>
::keep_organized_
;
32
using
FilterIndices
<PointT>
::user_filter_value_
;
33
using
FilterIndices
<PointT>
::extract_removed_indices_
;
34
using
FilterIndices
<PointT>
::removed_indices_
;
35
36
using
typename
FilterIndices<PointT>::PointCloud
;
37
38
public
:
39
/** \brief Empty constructor. */
40
FarthestPointSampling
(
bool
extract_removed_indices =
false
) :
41
FilterIndices
<PointT> (extract_removed_indices),
42
sample_size_
(std::numeric_limits<int>::max ()),
43
seed_
(std::random_device()())
44
{
45
filter_name_
=
"FarthestPointSamping"
;
46
}
47
48
/** \brief Set number of points to be sampled.
49
* \param sample_size the number of points to sample
50
*/
51
inline
void
52
setSample
(std::size_t sample_size)
53
{
54
sample_size_
= sample_size;
55
}
56
57
/** \brief Get the value of the internal \a sample_size parameter.
58
*/
59
inline
std::size_t
60
getSample
()
const
61
{
62
return
(
sample_size_
);
63
}
64
65
/** \brief Set seed of random function.
66
* \param seed for the random number generator, to choose the first sample point
67
*/
68
inline
void
69
setSeed
(
unsigned
int
seed)
70
{
71
seed_
= seed;
72
}
73
74
/** \brief Get the value of the internal \a seed_ parameter.
75
*/
76
inline
unsigned
int
77
getSeed
()
const
78
{
79
return
(
seed_
);
80
}
81
82
protected
:
83
84
/** \brief Number of points that will be returned. */
85
std::size_t
sample_size_
;
86
/** \brief Random number seed. */
87
unsigned
int
seed_
;
88
89
/** \brief Sample of point indices
90
* \param indices indices of the filtered point cloud
91
*/
92
void
93
applyFilter
(
pcl::Indices
&indices)
override
;
94
95
};
96
}
97
98
#ifdef PCL_NO_PRECOMPILE
99
#include <pcl/filters/impl/farthest_point_sampling.hpp>
100
#endif
pcl::FarthestPointSampling::seed_
unsigned int seed_
Random number seed.
Definition
farthest_point_sampling.h:87
pcl::FarthestPointSampling::setSample
void setSample(std::size_t sample_size)
Set number of points to be sampled.
Definition
farthest_point_sampling.h:52
pcl::FarthestPointSampling::getSample
std::size_t getSample() const
Get the value of the internal sample_size parameter.
Definition
farthest_point_sampling.h:60
pcl::FarthestPointSampling::getSeed
unsigned int getSeed() const
Get the value of the internal seed_ parameter.
Definition
farthest_point_sampling.h:77
pcl::FarthestPointSampling::applyFilter
void applyFilter(pcl::Indices &indices) override
Sample of point indices.
Definition
farthest_point_sampling.hpp:21
pcl::FarthestPointSampling::sample_size_
std::size_t sample_size_
Number of points that will be returned.
Definition
farthest_point_sampling.h:85
pcl::FarthestPointSampling::setSeed
void setSeed(unsigned int seed)
Set seed of random function.
Definition
farthest_point_sampling.h:69
pcl::FarthestPointSampling::FarthestPointSampling
FarthestPointSampling(bool extract_removed_indices=false)
Empty constructor.
Definition
farthest_point_sampling.h:40
pcl::Filter
Filter represents the base filter class.
Definition
filter.h:81
pcl::Filter::extract_removed_indices_
bool extract_removed_indices_
Set to true if we want to return the indices of the removed points.
Definition
filter.h:161
pcl::Filter::filter_name_
std::string filter_name_
The filter name.
Definition
filter.h:158
pcl::Filter::removed_indices_
IndicesPtr removed_indices_
Indices of the points that are removed.
Definition
filter.h:155
pcl::FilterIndices::user_filter_value_
float user_filter_value_
The user given value that the filtered point dimensions should be set to (default = NaN).
Definition
filter_indices.h:173
pcl::FilterIndices::keep_organized_
bool keep_organized_
False = remove points (default), true = redefine points, keep structure.
Definition
filter_indices.h:170
pcl::FilterIndices::FilterIndices
FilterIndices(bool extract_removed_indices=false)
Constructor.
Definition
filter_indices.h:87
pcl::FilterIndices::PointCloud
pcl::PointCloud< PointT > PointCloud
Definition
filter_indices.h:78
pcl::PCLBase
PCL base class.
Definition
pcl_base.h:70
pcl::PCLBase::input_
PointCloudConstPtr input_
The input point cloud dataset.
Definition
pcl_base.h:147
pcl::PCLBase::indices_
IndicesPtr indices_
A pointer to the vector of point indices to use.
Definition
pcl_base.h:150
pcl
Definition
convolution.h:46
pcl::Indices
IndicesAllocator<> Indices
Type used for indices in PCL.
Definition
types.h:133