Point Cloud Library (PCL)
1.12.1
Toggle main menu visibility
Loading...
Searching...
No Matches
pcl
features
principal_curvatures.h
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
#pragma once
42
43
#include <pcl/features/feature.h>
44
45
namespace
pcl
46
{
47
/** \brief PrincipalCurvaturesEstimation estimates the directions (eigenvectors) and magnitudes (eigenvalues) of
48
* principal surface curvatures for a given point cloud dataset containing points and normals.
49
*
50
* The recommended PointOutT is pcl::PrincipalCurvatures.
51
*
52
* \note The code is stateful as we do not expect this class to be multicore parallelized. Please look at
53
* \ref NormalEstimationOMP for an example on how to extend this to parallel implementations.
54
*
55
* \author Radu B. Rusu, Jared Glover
56
* \ingroup features
57
*/
58
template
<
typename
Po
int
InT,
typename
Po
int
NT,
typename
Po
int
OutT = pcl::PrincipalCurvatures>
59
class
PrincipalCurvaturesEstimation
:
public
FeatureFromNormals
<PointInT, PointNT, PointOutT>
60
{
61
public
:
62
using
Ptr
= shared_ptr<PrincipalCurvaturesEstimation<PointInT, PointNT, PointOutT> >;
63
using
ConstPtr
= shared_ptr<const PrincipalCurvaturesEstimation<PointInT, PointNT, PointOutT> >;
64
using
Feature
<PointInT, PointOutT>
::feature_name_
;
65
using
Feature
<PointInT, PointOutT>
::getClassName
;
66
using
Feature
<PointInT, PointOutT>
::indices_
;
67
using
Feature
<PointInT, PointOutT>
::k_
;
68
using
Feature
<PointInT, PointOutT>
::search_parameter_
;
69
using
Feature
<PointInT, PointOutT>
::surface_
;
70
using
Feature
<PointInT, PointOutT>
::input_
;
71
using
FeatureFromNormals
<PointInT, PointNT, PointOutT>
::normals_
;
72
73
using
PointCloudOut
=
typename
Feature<PointInT, PointOutT>::PointCloudOut
;
74
using
PointCloudIn
=
pcl::PointCloud<PointInT>
;
75
76
/** \brief Empty constructor. */
77
PrincipalCurvaturesEstimation
() :
78
xyz_centroid_ (
Eigen
::Vector3f::Zero ()),
79
demean_ (
Eigen
::Vector3f::Zero ()),
80
covariance_matrix_ (
Eigen
::Matrix3f::Zero ()),
81
eigenvector_ (
Eigen
::Vector3f::Zero ()),
82
eigenvalues_ (
Eigen
::Vector3f::Zero ())
83
{
84
feature_name_
=
"PrincipalCurvaturesEstimation"
;
85
};
86
87
/** \brief Perform Principal Components Analysis (PCA) on the point normals of a surface patch in the tangent
88
* plane of the given point normal, and return the principal curvature (eigenvector of the max eigenvalue),
89
* along with both the max (pc1) and min (pc2) eigenvalues
90
* \param[in] normals the point cloud normals
91
* \param[in] p_idx the query point at which the least-squares plane was estimated
92
* \param[in] indices the point cloud indices that need to be used
93
* \param[out] pcx the principal curvature X direction
94
* \param[out] pcy the principal curvature Y direction
95
* \param[out] pcz the principal curvature Z direction
96
* \param[out] pc1 the max eigenvalue of curvature
97
* \param[out] pc2 the min eigenvalue of curvature
98
*/
99
void
100
computePointPrincipalCurvatures
(
const
pcl::PointCloud<PointNT>
&normals,
101
int
p_idx,
const
pcl::Indices
&indices,
102
float
&pcx,
float
&pcy,
float
&pcz,
float
&pc1,
float
&pc2);
103
104
protected
:
105
106
/** \brief Estimate the principal curvature (eigenvector of the max eigenvalue), along with both the max (pc1)
107
* and min (pc2) eigenvalues for all points given in <setInputCloud (), setIndices ()> using the surface in
108
* setSearchSurface () and the spatial locator in setSearchMethod ()
109
* \param[out] output the resultant point cloud model dataset that contains the principal curvature estimates
110
*/
111
void
112
computeFeature
(
PointCloudOut
&output)
override
;
113
114
private
:
115
/** \brief A pointer to the input dataset that contains the point normals of the XYZ dataset. */
116
std::vector<Eigen::Vector3f, Eigen::aligned_allocator<Eigen::Vector3f> > projected_normals_;
117
118
/** \brief SSE aligned placeholder for the XYZ centroid of a surface patch. */
119
Eigen::Vector3f xyz_centroid_;
120
121
/** \brief Temporary point placeholder. */
122
Eigen::Vector3f demean_;
123
124
/** \brief Placeholder for the 3x3 covariance matrix at each surface patch. */
125
EIGEN_ALIGN16 Eigen::Matrix3f covariance_matrix_;
126
127
/** \brief SSE aligned eigenvectors placeholder for a covariance matrix. */
128
Eigen::Vector3f eigenvector_;
129
/** \brief eigenvalues placeholder for a covariance matrix. */
130
Eigen::Vector3f eigenvalues_;
131
};
132
}
133
134
#ifdef PCL_NO_PRECOMPILE
135
#include <pcl/features/impl/principal_curvatures.hpp>
136
#endif
pcl::FeatureFromNormals< PointInT, PointNT, pcl::PrincipalCurvatures >::FeatureFromNormals
FeatureFromNormals()
Definition
feature.h:332
pcl::FeatureFromNormals< PointInT, PointNT, pcl::PrincipalCurvatures >::normals_
PointCloudNConstPtr normals_
Definition
feature.h:355
pcl::Feature
Feature represents the base feature class.
Definition
feature.h:107
pcl::Feature< PointInT, pcl::PrincipalCurvatures >::search_parameter_
double search_parameter_
Definition
feature.h:237
pcl::Feature< PointInT, pcl::PrincipalCurvatures >::getClassName
const std::string & getClassName() const
Definition
feature.h:247
pcl::Feature::PointCloudOut
pcl::PointCloud< PointOutT > PointCloudOut
Definition
feature.h:124
pcl::Feature< PointInT, pcl::PrincipalCurvatures >::k_
int k_
Definition
feature.h:243
pcl::Feature< PointInT, pcl::PrincipalCurvatures >::feature_name_
std::string feature_name_
Definition
feature.h:223
pcl::Feature< PointInT, pcl::PrincipalCurvatures >::surface_
PointCloudInConstPtr surface_
Definition
feature.h:231
pcl::PointCloudOut
pcl::PCLBase< PointInT >::input_
PointCloudConstPtr input_
Definition
pcl_base.h:147
pcl::PCLBase< PointInT >::indices_
IndicesPtr indices_
Definition
pcl_base.h:150
pcl::PointCloud
PointCloud represents the base class in PCL for storing collections of 3D points.
Definition
point_cloud.h:173
pcl::PrincipalCurvaturesEstimation::PointCloudIn
pcl::PointCloud< PointInT > PointCloudIn
Definition
principal_curvatures.h:74
pcl::PrincipalCurvaturesEstimation::Ptr
shared_ptr< PrincipalCurvaturesEstimation< PointInT, PointNT, PointOutT > > Ptr
Definition
principal_curvatures.h:62
pcl::PrincipalCurvaturesEstimation::computePointPrincipalCurvatures
void computePointPrincipalCurvatures(const pcl::PointCloud< PointNT > &normals, int p_idx, const pcl::Indices &indices, float &pcx, float &pcy, float &pcz, float &pc1, float &pc2)
Perform Principal Components Analysis (PCA) on the point normals of a surface patch in the tangent pl...
Definition
principal_curvatures.hpp:50
pcl::PrincipalCurvaturesEstimation::PrincipalCurvaturesEstimation
PrincipalCurvaturesEstimation()
Empty constructor.
Definition
principal_curvatures.h:77
pcl::PrincipalCurvaturesEstimation::ConstPtr
shared_ptr< const PrincipalCurvaturesEstimation< PointInT, PointNT, PointOutT > > ConstPtr
Definition
principal_curvatures.h:63
pcl::PrincipalCurvaturesEstimation::computeFeature
void computeFeature(PointCloudOut &output) override
Estimate the principal curvature (eigenvector of the max eigenvalue), along with both the max (pc1) a...
Definition
principal_curvatures.hpp:115
pcl::PrincipalCurvaturesEstimation::PointCloudOut
typename Feature< PointInT, PointOutT >::PointCloudOut PointCloudOut
Definition
principal_curvatures.h:73
Eigen
Definition
bfgs.h:10
pcl
Definition
convolution.h:46
pcl::Indices
IndicesAllocator<> Indices
Type used for indices in PCL.
Definition
types.h:133