Loading...
Searching...
No Matches
farthest_point_sampling.h
/*
* SPDX-License-Identifier: BSD-3-Clause
*
* Point Cloud Library (PCL) - www.pointclouds.org
* Copyright (c) 2020-, Open Perception, Inc.
*
* All rights reserved
*/
#pragma once
#include <pcl/filters/filter_indices.h>
#include <climits>
#include <random>
namespace pcl
{
/** \brief @b FarthestPointSampling applies farthest point sampling using euclidean
* distance, starting with a random point, utilizing a naive method.
* \author Haritha Jayasinghe
* \ingroup filters
* \todo add support to export/import distance metric
*/
template<typename PointT>
class FarthestPointSampling : public FilterIndices<PointT>
{
using PCLBase<PointT>::input_;
using PCLBase<PointT>::indices_;
using Filter<PointT>::filter_name_;
using FilterIndices<PointT>::keep_organized_;
using FilterIndices<PointT>::user_filter_value_;
using FilterIndices<PointT>::extract_removed_indices_;
using FilterIndices<PointT>::removed_indices_;
using typename FilterIndices<PointT>::PointCloud;
public:
/** \brief Empty constructor. */
FarthestPointSampling (bool extract_removed_indices = false) :
FilterIndices<PointT> (extract_removed_indices),
sample_size_ (std::numeric_limits<int>::max ()),
seed_ (std::random_device()())
{
filter_name_ = "FarthestPointSamping";
}
/** \brief Set number of points to be sampled.
* \param sample_size the number of points to sample
*/
inline void
setSample (std::size_t sample_size)
{
sample_size_ = sample_size;
}
/** \brief Get the value of the internal \a sample_size parameter.
*/
inline std::size_t
getSample () const
{
return (sample_size_);
}
/** \brief Set seed of random function.
* \param seed for the random number generator, to choose the first sample point
*/
inline void
setSeed (unsigned int seed)
{
seed_ = seed;
}
/** \brief Get the value of the internal \a seed_ parameter.
*/
inline unsigned int
getSeed () const
{
return (seed_);
}
protected:
/** \brief Number of points that will be returned. */
std::size_t sample_size_;
/** \brief Random number seed. */
unsigned int seed_;
/** \brief Sample of point indices
* \param indices indices of the filtered point cloud
*/
void
applyFilter (pcl::Indices &indices) override;
};
}
#ifdef PCL_NO_PRECOMPILE
#include <pcl/filters/impl/farthest_point_sampling.hpp>
#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