Point Cloud Library (PCL) 1.15.0
Loading...
Searching...
No Matches
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
45namespace 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. The output contains
49 * the principal curvature (eigenvector of the max eigenvalue), along with both the max (pc1) and min (pc2)
50 * eigenvalues. Parallel execution is supported through OpenMP.
51 *
52 * The recommended PointOutT is pcl::PrincipalCurvatures.
53 *
54 * \author Radu B. Rusu, Jared Glover, Alex Navarro
55 * \ingroup features
56 */
57 template <typename PointInT, typename PointNT, typename PointOutT = pcl::PrincipalCurvatures>
58 class PrincipalCurvaturesEstimation : public FeatureFromNormals<PointInT, PointNT, PointOutT>
59 {
60 public:
61 using Ptr = shared_ptr<PrincipalCurvaturesEstimation<PointInT, PointNT, PointOutT> >;
62 using ConstPtr = shared_ptr<const PrincipalCurvaturesEstimation<PointInT, PointNT, PointOutT> >;
63 using Feature<PointInT, PointOutT>::feature_name_;
64 using Feature<PointInT, PointOutT>::getClassName;
65 using Feature<PointInT, PointOutT>::indices_;
66 using Feature<PointInT, PointOutT>::k_;
67 using Feature<PointInT, PointOutT>::search_parameter_;
68 using Feature<PointInT, PointOutT>::surface_;
69 using Feature<PointInT, PointOutT>::input_;
70 using FeatureFromNormals<PointInT, PointNT, PointOutT>::normals_;
71
74
75 /** \brief Initialize the scheduler and set the number of threads to use.
76 * \param nr_threads the number of hardware threads to use (0 sets the value to automatic)
77 * \param chunk_size PCL will use dynamic scheduling with this chunk size. Setting it too
78 * low will lead to more parallelization overhead. Setting it too high
79 * will lead to a worse balancing between the threads.
80 */
81 PrincipalCurvaturesEstimation (unsigned int nr_threads = 1, int chunk_size = 256) :
82 chunk_size_(chunk_size)
83 {
84 feature_name_ = "PrincipalCurvaturesEstimation";
85
86 setNumberOfThreads(nr_threads);
87 };
88
89 /** \brief Perform Principal Components Analysis (PCA) on the point normals of a surface patch in the tangent
90 * plane of the given point normal, and return the principal curvature (eigenvector of the max eigenvalue),
91 * along with both the max (pc1) and min (pc2) eigenvalues
92 * \param[in] normals the point cloud normals
93 * \param[in] p_idx the query point at which the least-squares plane was estimated
94 * \param[in] indices the point cloud indices that need to be used
95 * \param[out] pcx the principal curvature X direction
96 * \param[out] pcy the principal curvature Y direction
97 * \param[out] pcz the principal curvature Z direction
98 * \param[out] pc1 the max eigenvalue of curvature
99 * \param[out] pc2 the min eigenvalue of curvature
100 */
101 void
103 int p_idx, const pcl::Indices &indices,
104 float &pcx, float &pcy, float &pcz, float &pc1, float &pc2);
105
106 /** \brief Initialize the scheduler and set the number of threads to use. The default behavior is
107 * single threaded exectution
108 * \param nr_threads the number of hardware threads to use (0 sets the value to automatic)
109 */
110 void
111 setNumberOfThreads (unsigned int nr_threads);
112
113 protected:
114 /** \brief The number of threads the scheduler should use. */
115 unsigned int threads_;
116
117 /** \brief Chunk size for (dynamic) scheduling. */
119
120 /** \brief Estimate the principal curvature (eigenvector of the max eigenvalue), along with both the max (pc1)
121 * and min (pc2) eigenvalues for all points given in <setInputCloud (), setIndices ()> using the surface in
122 * setSearchSurface () and the spatial locator in setSearchMethod ()
123 * \param[out] output the resultant point cloud model dataset that contains the principal curvature estimates
124 */
125 void
126 computeFeature (PointCloudOut &output) override;
127 };
128}
129
130#ifdef PCL_NO_PRECOMPILE
131#include <pcl/features/impl/principal_curvatures.hpp>
132#endif
PointCloudNConstPtr normals_
A pointer to the input dataset that contains the point normals of the XYZ dataset.
Definition feature.h:349
Feature represents the base feature class.
Definition feature.h:107
double search_parameter_
The actual search parameter (from either search_radius_ or k_).
Definition feature.h:234
const std::string & getClassName() const
Get a string representation of the name of this class.
Definition feature.h:244
int k_
The number of K nearest neighbors to use for each point.
Definition feature.h:240
std::string feature_name_
The feature name.
Definition feature.h:220
PointCloudInConstPtr surface_
An input point cloud describing the surface that is to be used for nearest neighbors estimation.
Definition feature.h:228
PointCloudConstPtr input_
The input point cloud dataset.
Definition pcl_base.h:147
IndicesPtr indices_
A pointer to the vector of point indices to use.
Definition pcl_base.h:150
PrincipalCurvaturesEstimation estimates the directions (eigenvectors) and magnitudes (eigenvalues) of...
int chunk_size_
Chunk size for (dynamic) scheduling.
void setNumberOfThreads(unsigned int nr_threads)
Initialize the scheduler and set the number of threads to use.
shared_ptr< PrincipalCurvaturesEstimation< PointInT, PointNT, PointOutT > > Ptr
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...
PrincipalCurvaturesEstimation(unsigned int nr_threads=1, int chunk_size=256)
Initialize the scheduler and set the number of threads to use.
shared_ptr< const PrincipalCurvaturesEstimation< PointInT, PointNT, PointOutT > > ConstPtr
void computeFeature(PointCloudOut &output) override
Estimate the principal curvature (eigenvector of the max eigenvalue), along with both the max (pc1) a...
typename Feature< PointInT, PointOutT >::PointCloudOut PointCloudOut
unsigned int threads_
The number of threads the scheduler should use.
IndicesAllocator<> Indices
Type used for indices in PCL.
Definition types.h:133