Point Cloud Library (PCL)
1.15.1
Toggle main menu visibility
Loading...
Searching...
No Matches
pcl
2d
convolution.h
1
/*
2
* Software License Agreement (BSD License)
3
*
4
* Point Cloud Library (PCL) - www.pointclouds.org
5
* Copyright (c) 2012-, Open Perception, 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 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
*/
37
38
#pragma once
39
40
#include <pcl/filters/filter.h>
41
#include <
pcl/memory.h
>
42
#include <pcl/pcl_base.h>
43
#include <
pcl/pcl_macros.h
>
44
#include <
pcl/point_types.h
>
45
46
namespace
pcl
{
47
48
/// Point cloud containing edge information.
49
struct
EIGEN_ALIGN16
PointXYZIEdge
{
50
PCL_ADD_POINT4D
;
// preferred way of adding a XYZ+padding
51
float
magnitude
;
52
float
direction
;
53
float
magnitude_x
;
54
float
magnitude_y
;
55
PCL_MAKE_ALIGNED_OPERATOR_NEW
// make sure our new allocators are aligned
56
};
// enforce SSE padding for correct memory alignment
57
58
/// A 2D convolution class.
59
template
<
typename
Po
int
T>
60
class
Convolution
:
public
Filter
<PointT> {
61
public
:
62
using
Filter
<PointT>
::input_
;
63
64
/**
65
* Extra pixels are added to the input image so that convolution can be performed over
66
* the entire image.
67
*
68
* (kernel_height/2) rows are added before the first row and after the last row
69
* (kernel_width/2) columns are added before the first column and after the last
70
* column border options define what values are set for these extra rows and columns
71
*
72
* Assume that the three rows of right edge of the image looks like this:
73
* .. 3 2 1
74
* .. 6 5 4
75
* .. 9 8 7
76
*
77
* BOUNDARY_OPTION_CLAMP : the extra pixels are set to the pixel value of the boundary
78
* pixel. This option makes it seem as if it were:
79
* .. 3 2 1| 1 1 1 ..
80
* .. 6 5 4| 4 4 4 ..
81
* .. 9 8 7| 7 7 7 ..
82
*
83
* BOUNDARY_OPTION_MIRROR : the input image is mirrored at the boundary. This option
84
* makes it seem as if it were:
85
* .. 3 2 1| 1 2 3 ..
86
* .. 6 5 4| 4 5 6 ..
87
* .. 9 8 7| 7 8 9 ..
88
*
89
* BOUNDARY_OPTION_ZERO_PADDING : the extra pixels are simply set to 0. This option
90
* makes it seem as if it were:
91
* .. 3 2 1| 0 0 0 ..
92
* .. 6 5 4| 0 0 0 ..
93
* .. 9 8 7| 0 0 0 ..
94
*
95
* Note that the input image is not actually extended in size. Instead, based on these
96
* options, the convolution is performed differently at the border pixels.
97
*/
98
enum
BOUNDARY_OPTIONS_ENUM
{
99
BOUNDARY_OPTION_CLAMP
,
100
BOUNDARY_OPTION_MIRROR
,
101
BOUNDARY_OPTION_ZERO_PADDING
102
};
103
104
Convolution
() { boundary_options_ =
BOUNDARY_OPTION_CLAMP
; }
105
106
/** \brief Sets the kernel to be used for convolution
107
* \param[in] kernel convolution kernel passed by reference
108
*/
109
inline
void
110
setKernel
(
const
pcl::PointCloud<PointT>
&
kernel
)
111
{
112
kernel_ =
kernel
;
113
}
114
115
/**
116
* \param[in] boundary_options enum indicating the boundary options to be used for
117
* convolution
118
*/
119
inline
void
120
setBoundaryOptions
(
BOUNDARY_OPTIONS_ENUM
boundary_options)
121
{
122
boundary_options_ = boundary_options;
123
}
124
125
/** \brief Performs 2D convolution of the input point cloud with the kernel.
126
* Uses clamp as the default boundary option.
127
* \param[out] output Output point cloud passed by reference
128
*/
129
void
130
filter
(
pcl::PointCloud<PointT>
& output);
131
132
protected
:
133
/** \brief This is an over-ride function for the pcl::Filter interface. */
134
void
135
applyFilter
(
pcl::PointCloud<PointT>
&)
override
136
{}
137
138
private
:
139
BOUNDARY_OPTIONS_ENUM
boundary_options_;
140
pcl::PointCloud<PointT>
kernel_;
141
};
142
}
// namespace pcl
143
144
#include <pcl/2d/impl/convolution.hpp>
145
146
POINT_CLOUD_REGISTER_POINT_STRUCT(
pcl::PointXYZIEdge
,
//
147
(
float
, x, x)
//
148
(
float
, y, y)
//
149
(
float
, z, z)
//
150
(
float
, magnitude, magnitude)
//
151
(
float
, direction, direction)
//
152
(
float
, magnitude_x, magnitude_x)
//
153
(
float
, magnitude_y, magnitude_y))
//
pcl::Convolution::setBoundaryOptions
void setBoundaryOptions(BOUNDARY_OPTIONS_ENUM boundary_options)
Definition
convolution.h:120
pcl::Convolution::Convolution
Convolution()
Definition
convolution.h:104
pcl::Convolution::BOUNDARY_OPTIONS_ENUM
BOUNDARY_OPTIONS_ENUM
Extra pixels are added to the input image so that convolution can be performed over the entire image.
Definition
convolution.h:98
pcl::Convolution::BOUNDARY_OPTION_ZERO_PADDING
@ BOUNDARY_OPTION_ZERO_PADDING
Definition
convolution.h:101
pcl::Convolution::BOUNDARY_OPTION_MIRROR
@ BOUNDARY_OPTION_MIRROR
Definition
convolution.h:100
pcl::Convolution::BOUNDARY_OPTION_CLAMP
@ BOUNDARY_OPTION_CLAMP
Definition
convolution.h:99
pcl::Convolution::setKernel
void setKernel(const pcl::PointCloud< PointT > &kernel)
Sets the kernel to be used for convolution.
Definition
convolution.h:110
pcl::Convolution::filter
void filter(pcl::PointCloud< PointT > &output)
Performs 2D convolution of the input point cloud with the kernel.
Definition
convolution.hpp:46
pcl::Convolution::applyFilter
void applyFilter(pcl::PointCloud< PointT > &) override
This is an over-ride function for the pcl::Filter interface.
Definition
convolution.h:135
pcl::Filter::Filter
Filter(bool extract_removed_indices=false)
Empty constructor.
Definition
filter.h:95
pcl::PCLBase::input_
PointCloudConstPtr input_
The input point cloud dataset.
Definition
pcl_base.h:147
pcl::PointCloud
PointCloud represents the base class in PCL for storing collections of 3D points.
Definition
point_cloud.h:174
pcl::kernel
Definition
kernel.h:46
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
Definition
convolution.h:46
pcl_macros.h
Defines all the PCL and non-PCL macros used.
pcl::PointXYZIEdge
Point cloud containing edge information.
Definition
convolution.h:49
pcl::PointXYZIEdge::magnitude
float magnitude
Definition
convolution.h:51
pcl::PointXYZIEdge::magnitude_y
float magnitude_y
Definition
convolution.h:54
pcl::PointXYZIEdge::direction
float direction
Definition
convolution.h:52
pcl::PointXYZIEdge::PCL_ADD_POINT4D
PCL_ADD_POINT4D
Definition
convolution.h:50
pcl::PointXYZIEdge::magnitude_x
float magnitude_x
Definition
convolution.h:53