Point Cloud Library (PCL)
1.15.1
Toggle main menu visibility
Loading...
Searching...
No Matches
pcl
filters
pyramid.h
1
/*
2
* Software License Agreement (BSD License)
3
*
4
* Point Cloud Library (PCL) - www.pointclouds.org
5
* Copyright (c) 2012-, Open Perception.
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 the copyright holder(s) 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
* $Id$
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/pcl_config.h>
46
47
namespace
pcl
48
{
49
namespace
filters
50
{
51
/** Pyramid constructs a multi-scale representation of an organised point cloud.
52
* It is an iterative smoothing subsampling algorithm.
53
* The subsampling is fixed to 2. Two smoothing kernels may be used:
54
* - [1/16 1/4 3/8 1/4 1/16] slower but produces finer result;
55
* - [1/4 1/2 1/4] the more conventional binomial kernel which is faster.
56
* We use a memory efficient algorithm so the convolving and subsampling are combined in a
57
* single step.
58
*
59
* \author Nizar Sallem
60
*/
61
template
<
typename
Po
int
T>
62
class
Pyramid
63
{
64
public
:
65
using
PointCloudPtr
=
typename
PointCloud<PointT>::Ptr
;
66
using
PointCloudConstPtr
=
typename
PointCloud<PointT>::ConstPtr
;
67
using
Ptr
= shared_ptr< Pyramid<PointT> >;
68
using
ConstPtr
= shared_ptr< const Pyramid<PointT> >;
69
70
Pyramid
(
int
levels = 4)
71
: levels_ (levels)
72
, name_ (
"Pyramid"
)
73
{
74
}
75
76
/** \brief Provide a pointer to the input dataset
77
* \param cloud the const boost shared pointer to a PointCloud message
78
*/
79
inline
void
80
setInputCloud
(
const
PointCloudConstPtr
&cloud) { input_ = cloud; }
81
82
/** \brief Get a pointer to the input point cloud dataset. */
83
inline
PointCloudConstPtr
const
84
getInputCloud
() {
return
(input_); }
85
86
/** \brief Set the number of pyramid levels
87
* \param levels desired number of pyramid levels
88
*/
89
inline
void
90
setNumberOfLevels
(
int
levels) { levels_ = levels; }
91
92
/// \brief \return the number of pyramid levels
93
inline
int
94
getNumberOfLevels
()
const
{
return
(levels_); }
95
96
/** \brief Initialize the scheduler and set the number of threads to use.
97
* \param nr_threads the number of hardware threads to use (0 sets the value back to automatic).
98
*/
99
inline
void
100
setNumberOfThreads
(
unsigned
int
nr_threads = 0) { threads_ = nr_threads; }
101
102
/** \brief Choose a larger smoothing kernel for enhanced smoothing.
103
* \param large if true large smoothng kernel will be used.
104
*/
105
inline
void
106
setLargeSmoothingKernel
(
bool
large) { large_ = large; }
107
108
/** Only points such us distance (center,point) < threshold are accounted for to prevent
109
* ghost points.
110
* Default value is 0.01, to disable set to std::numeric<float>::infinity ().
111
* \param[in] threshold maximum allowed distance between center and neighbor.
112
*/
113
inline
void
114
setDistanceThreshold
(
float
threshold) { threshold_ = threshold; }
115
116
/// \return the distance threshold
117
inline
float
118
getDistanceThreshold
()
const
{
return
(threshold_); }
119
120
/** \brief compute the pyramid levels.
121
* \param[out] output the constructed pyramid. It is resized to the number of levels.
122
* \remark input_ is copied to output[0] for consistency reasons.
123
*/
124
void
125
compute
(std::vector<PointCloudPtr>& output);
126
127
inline
const
std::string&
128
getClassName
()
const
{
return
(name_); }
129
130
private
:
131
132
/// \brief init computation
133
bool
134
initCompute ();
135
136
/** \brief nullify a point
137
* \param[in][out] p point to nullify
138
*/
139
inline
void
140
nullify (PointT& p)
const
141
{
142
p.x = p.y = p.z = std::numeric_limits<float>::quiet_NaN ();
143
}
144
145
/// \brief The input point cloud dataset.
146
PointCloudConstPtr input_;
147
/// \brief number of pyramid levels
148
int
levels_{4};
149
/// \brief use large smoothing kernel
150
bool
large_{
false
};
151
/// \brief filter name
152
std::string name_;
153
/// \brief smoothing kernel
154
Eigen::MatrixXf kernel_;
155
/// Threshold distance between adjacent points
156
float
threshold_{0.01f};
157
/// \brief number of threads
158
unsigned
int
threads_{0};
159
160
public
:
161
PCL_MAKE_ALIGNED_OPERATOR_NEW
162
};
163
}
164
}
pcl::PointCloud::Ptr
shared_ptr< PointCloud< PointT > > Ptr
Definition
point_cloud.h:414
pcl::PointCloud::ConstPtr
shared_ptr< const PointCloud< PointT > > ConstPtr
Definition
point_cloud.h:415
pcl::filters::Pyramid::getNumberOfLevels
int getNumberOfLevels() const
Definition
pyramid.h:94
pcl::filters::Pyramid::setNumberOfLevels
void setNumberOfLevels(int levels)
Set the number of pyramid levels.
Definition
pyramid.h:90
pcl::filters::Pyramid::compute
void compute(std::vector< PointCloudPtr > &output)
compute the pyramid levels.
Definition
pyramid.hpp:100
pcl::filters::Pyramid::getDistanceThreshold
float getDistanceThreshold() const
Definition
pyramid.h:118
pcl::filters::Pyramid::Pyramid
Pyramid(int levels=4)
Definition
pyramid.h:70
pcl::filters::Pyramid::PointCloudPtr
typename PointCloud< PointT >::Ptr PointCloudPtr
Definition
pyramid.h:65
pcl::filters::Pyramid::getInputCloud
PointCloudConstPtr const getInputCloud()
Get a pointer to the input point cloud dataset.
Definition
pyramid.h:84
pcl::filters::Pyramid::setDistanceThreshold
void setDistanceThreshold(float threshold)
Only points such us distance (center,point) < threshold are accounted for to prevent ghost points.
Definition
pyramid.h:114
pcl::filters::Pyramid::setNumberOfThreads
void setNumberOfThreads(unsigned int nr_threads=0)
Initialize the scheduler and set the number of threads to use.
Definition
pyramid.h:100
pcl::filters::Pyramid::setLargeSmoothingKernel
void setLargeSmoothingKernel(bool large)
Choose a larger smoothing kernel for enhanced smoothing.
Definition
pyramid.h:106
pcl::filters::Pyramid::getClassName
const std::string & getClassName() const
Definition
pyramid.h:128
pcl::filters::Pyramid::setInputCloud
void setInputCloud(const PointCloudConstPtr &cloud)
Provide a pointer to the input dataset.
Definition
pyramid.h:80
pcl::filters::Pyramid::ConstPtr
shared_ptr< const Pyramid< PointT > > ConstPtr
Definition
pyramid.h:68
pcl::filters::Pyramid::Ptr
shared_ptr< Pyramid< PointT > > Ptr
Definition
pyramid.h:67
pcl::filters::Pyramid::PointCloudConstPtr
typename PointCloud< PointT >::ConstPtr PointCloudConstPtr
Definition
pyramid.h:66
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::filters
Definition
convolution.h:47
pcl
Definition
convolution.h:46
pcl_macros.h
Defines all the PCL and non-PCL macros used.