Point Cloud Library (PCL)
1.15.1
Toggle main menu visibility
Loading...
Searching...
No Matches
pcl
features
impl
don.hpp
1
/*
2
* Software License Agreement (BSD License)
3
*
4
* Point Cloud Library (PCL) - www.pointclouds.org
5
* Copyright (c) 2012, Yani Ioannou <yani.ioannou@gmail.com>
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
#ifndef PCL_FILTERS_DON_IMPL_H_
38
#define PCL_FILTERS_DON_IMPL_H_
39
40
#include <pcl/features/don.h>
41
42
//////////////////////////////////////////////////////////////////////////////////////////////
43
template
<
typename
Po
int
InT,
typename
Po
int
NT,
typename
Po
int
OutT>
bool
44
pcl::DifferenceOfNormalsEstimation<PointInT, PointNT, PointOutT>::initCompute
()
45
{
46
// Check if input normals are set
47
if
(!input_normals_small_)
48
{
49
PCL_ERROR (
"[pcl::%s::initCompute] No input dataset containing small support radius normals was given!\n"
,
getClassName
().c_str ());
50
Feature<PointInT, PointOutT>::deinitCompute
();
51
return
(
false
);
52
}
53
54
if
(!input_normals_large_)
55
{
56
PCL_ERROR (
"[pcl::%s::initCompute] No input dataset containing large support radius normals was given!\n"
,
getClassName
().c_str ());
57
Feature<PointInT, PointOutT>::deinitCompute
();
58
return
(
false
);
59
}
60
61
// Check if the size of normals is the same as the size of the surface
62
if
(input_normals_small_->size () !=
input_
->size ())
63
{
64
PCL_ERROR (
"[pcl::%s::initCompute] "
,
getClassName
().c_str ());
65
PCL_ERROR (
"The number of points in the input dataset differs from "
);
66
PCL_ERROR (
"the number of points in the dataset containing the small support radius normals!\n"
);
67
Feature<PointInT, PointOutT>::deinitCompute
();
68
return
(
false
);
69
}
70
71
if
(input_normals_large_->size () !=
input_
->size ())
72
{
73
PCL_ERROR (
"[pcl::%s::initCompute] "
,
getClassName
().c_str ());
74
PCL_ERROR (
"The number of points in the input dataset differs from "
);
75
PCL_ERROR (
"the number of points in the dataset containing the large support radius normals!\n"
);
76
Feature<PointInT, PointOutT>::deinitCompute
();
77
return
(
false
);
78
}
79
80
return
(
true
);
81
}
82
83
//////////////////////////////////////////////////////////////////////////////////////////////
84
template
<
typename
Po
int
InT,
typename
Po
int
NT,
typename
Po
int
OutT>
void
85
pcl::DifferenceOfNormalsEstimation<PointInT, PointNT, PointOutT>::computeFeature
(PointCloudOut &output)
86
{
87
//perform DoN subtraction and return results
88
for
(std::size_t point_id = 0; point_id <
input_
->size (); ++point_id)
89
{
90
output[point_id].getNormalVector3fMap () = ((*input_normals_small_)[point_id].getNormalVector3fMap ()
91
- (*input_normals_large_)[point_id].getNormalVector3fMap ()) / 2.0;
92
if
(!std::isfinite (output[point_id].normal_x) ||
93
!std::isfinite (output[point_id].normal_y) ||
94
!std::isfinite (output[point_id].normal_z)){
95
output[point_id].getNormalVector3fMap () = Eigen::Vector3f(0,0,0);
96
}
97
output[point_id].curvature = output[point_id].getNormalVector3fMap ().norm();
98
}
99
}
100
101
102
#define PCL_INSTANTIATE_DifferenceOfNormalsEstimation(T,NT,OutT) template class PCL_EXPORTS pcl::DifferenceOfNormalsEstimation<T,NT,OutT>;
103
104
#endif
// PCL_FILTERS_DON_H_
pcl::DifferenceOfNormalsEstimation::initCompute
bool initCompute() override
Initialize for computation of features.
Definition
don.hpp:44
pcl::DifferenceOfNormalsEstimation::computeFeature
void computeFeature(PointCloudOut &output) override
Computes the DoN vector for each point in the input point cloud and outputs the vector cloud to the g...
Definition
don.hpp:85
pcl::Feature::getClassName
const std::string & getClassName() const
Get a string representation of the name of this class.
Definition
feature.h:244
pcl::Feature::deinitCompute
virtual bool deinitCompute()
This method should get called after ending the actual computation.
Definition
feature.hpp:189
pcl::PCLBase< PointInT >::input_
PointCloudConstPtr input_
Definition
pcl_base.h:147