Point Cloud Library (PCL)
1.15.1
Toggle main menu visibility
Loading...
Searching...
No Matches
pcl
features
impl
normal_3d.hpp
1
/*
2
* Software License Agreement (BSD License)
3
*
4
* Point Cloud Library (PCL) - www.pointclouds.org
5
* Copyright (c) 2010-2011, Willow Garage, Inc.
6
* Copyright (c) 2012-, Open Perception, Inc.
7
*
8
* All rights reserved.
9
*
10
* Redistribution and use in source and binary forms, with or without
11
* modification, are permitted provided that the following conditions
12
* are met:
13
*
14
* * Redistributions of source code must retain the above copyright
15
* notice, this list of conditions and the following disclaimer.
16
* * Redistributions in binary form must reproduce the above
17
* copyright notice, this list of conditions and the following
18
* disclaimer in the documentation and/or other materials provided
19
* with the distribution.
20
* * Neither the name of the copyright holder(s) nor the names of its
21
* contributors may be used to endorse or promote products derived
22
* from this software without specific prior written permission.
23
*
24
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
27
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
28
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
29
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
30
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
31
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
32
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
34
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35
* POSSIBILITY OF SUCH DAMAGE.
36
*
37
* $Id$
38
*
39
*/
40
41
#ifndef PCL_FEATURES_IMPL_NORMAL_3D_H_
42
#define PCL_FEATURES_IMPL_NORMAL_3D_H_
43
44
#include <pcl/features/normal_3d.h>
45
46
///////////////////////////////////////////////////////////////////////////////////////////
47
template
<
typename
Po
int
InT,
typename
Po
int
OutT>
void
48
pcl::NormalEstimation<PointInT, PointOutT>::computeFeature
(
PointCloudOut
&output)
49
{
50
// Allocate enough space to hold the results
51
// \note This resize is irrelevant for a radiusSearch ().
52
pcl::Indices
nn_indices (
k_
);
53
std::vector<float> nn_dists (
k_
);
54
55
output.is_dense =
true
;
56
// Save a few cycles by not checking every point for NaN/Inf values if the cloud is set to dense
57
if
(
input_
->is_dense)
58
{
59
// Iterating over the entire index vector
60
for
(std::size_t idx = 0; idx <
indices_
->size (); ++idx)
61
{
62
if
(this->
searchForNeighbors
((*
indices_
)[idx],
search_parameter_
, nn_indices, nn_dists) == 0 ||
63
!
computePointNormal
(*
surface_
, nn_indices, output[idx].normal[0], output[idx].normal[1], output[idx].normal[2], output[idx].curvature))
64
{
65
output[idx].normal[0] = output[idx].normal[1] = output[idx].normal[2] = output[idx].curvature = std::numeric_limits<float>::quiet_NaN ();
66
67
output.is_dense =
false
;
68
continue
;
69
}
70
71
flipNormalTowardsViewpoint
((*
input_
)[(*
indices_
)[idx]],
vpx_
,
vpy_
,
vpz_
,
72
output[idx].normal[0], output[idx].normal[1], output[idx].normal[2]);
73
74
}
75
}
76
else
77
{
78
// Iterating over the entire index vector
79
for
(std::size_t idx = 0; idx <
indices_
->size (); ++idx)
80
{
81
if
(!
isFinite
((*
input_
)[(*
indices_
)[idx]]) ||
82
this->
searchForNeighbors
((*
indices_
)[idx],
search_parameter_
, nn_indices, nn_dists) == 0 ||
83
!
computePointNormal
(*
surface_
, nn_indices, output[idx].normal[0], output[idx].normal[1], output[idx].normal[2], output[idx].curvature))
84
{
85
output[idx].normal[0] = output[idx].normal[1] = output[idx].normal[2] = output[idx].curvature = std::numeric_limits<float>::quiet_NaN ();
86
87
output.is_dense =
false
;
88
continue
;
89
}
90
91
flipNormalTowardsViewpoint
((*
input_
)[(*
indices_
)[idx]],
vpx_
,
vpy_
,
vpz_
,
92
output[idx].normal[0], output[idx].normal[1], output[idx].normal[2]);
93
94
}
95
}
96
}
97
98
#define PCL_INSTANTIATE_NormalEstimation(T,NT) template class PCL_EXPORTS pcl::NormalEstimation<T,NT>;
99
100
#endif
// PCL_FEATURES_IMPL_NORMAL_3D_H_
pcl::Feature::search_parameter_
double search_parameter_
The actual search parameter (from either search_radius_ or k_).
Definition
feature.h:234
pcl::Feature::searchForNeighbors
int searchForNeighbors(std::size_t index, double parameter, pcl::Indices &indices, std::vector< float > &distances) const
Search for k-nearest neighbors using the spatial locator from setSearchmethod, and the given surface ...
Definition
feature.h:268
pcl::Feature::k_
int k_
The number of K nearest neighbors to use for each point.
Definition
feature.h:240
pcl::Feature::surface_
PointCloudInConstPtr surface_
An input point cloud describing the surface that is to be used for nearest neighbors estimation.
Definition
feature.h:228
pcl::NormalEstimation::vpz_
float vpz_
Definition
normal_3d.h:402
pcl::NormalEstimation::computeFeature
void computeFeature(PointCloudOut &output) override
Estimate normals for all points given in <setInputCloud (), setIndices ()> using the surface in setSe...
Definition
normal_3d.hpp:48
pcl::NormalEstimation::computePointNormal
bool computePointNormal(const pcl::PointCloud< PointInT > &cloud, const pcl::Indices &indices, Eigen::Vector4f &plane_parameters, float &curvature)
Compute the Least-Squares plane fit for a given set of points, using their indices,...
Definition
normal_3d.h:280
pcl::NormalEstimation::vpx_
float vpx_
Values describing the viewpoint ("pinhole" camera model assumed).
Definition
normal_3d.h:402
pcl::NormalEstimation::PointCloudOut
typename Feature< PointInT, PointOutT >::PointCloudOut PointCloudOut
Definition
normal_3d.h:257
pcl::NormalEstimation::vpy_
float vpy_
Definition
normal_3d.h:402
pcl::PCLBase< PointInT >::input_
PointCloudConstPtr input_
Definition
pcl_base.h:147
pcl::PCLBase< PointInT >::indices_
IndicesPtr indices_
Definition
pcl_base.h:150
pcl::flipNormalTowardsViewpoint
void flipNormalTowardsViewpoint(const PointT &point, float vp_x, float vp_y, float vp_z, Eigen::Matrix< Scalar, 4, 1 > &normal)
Flip (in place) the estimated normal of a point towards a given viewpoint.
Definition
normal_3d.h:122
pcl::isFinite
bool isFinite(const PointT &pt)
Tests if the 3D components of a point are all finite param[in] pt point to be tested return true if f...
Definition
point_tests.h:55
pcl::Indices
IndicesAllocator<> Indices
Type used for indices in PCL.
Definition
types.h:133