Point Cloud Library (PCL)  1.14.1-dev
moment_invariants.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 MomentInvariantsEstimation estimates the 3 moment invariants (j1, j2, j3) at each 3D point.
48  *
49  * \note The code is stateful as we do not expect this class to be multicore parallelized. Please look at
50  * \ref NormalEstimationOMP for an example on how to extend this to parallel implementations.
51  * \author Radu B. Rusu
52  * \ingroup features
53  * \tparam PointOutT Suggested type is `pcl::MomentInvariants`
54  */
55  template <typename PointInT, typename PointOutT>
56  class MomentInvariantsEstimation: public Feature<PointInT, PointOutT>
57  {
58  public:
59  using Ptr = shared_ptr<MomentInvariantsEstimation<PointInT, PointOutT> >;
60  using ConstPtr = shared_ptr<const MomentInvariantsEstimation<PointInT, PointOutT> >;
68 
70 
71  /** \brief Empty constructor. */
73  {
74  feature_name_ = "MomentInvariantsEstimation";
75  };
76 
77  /** \brief Compute the 3 moment invariants (j1, j2, j3) for a given set of points, using their indices.
78  * \param[in] cloud the input point cloud
79  * \param[in] indices the point cloud indices that need to be used
80  * \param[out] j1 the resultant first moment invariant
81  * \param[out] j2 the resultant second moment invariant
82  * \param[out] j3 the resultant third moment invariant
83  */
84  void
86  const pcl::Indices &indices,
87  float &j1, float &j2, float &j3);
88 
89  /** \brief Compute the 3 moment invariants (j1, j2, j3) for a given set of points, using their indices.
90  * \param[in] cloud the input point cloud
91  * \param[out] j1 the resultant first moment invariant
92  * \param[out] j2 the resultant second moment invariant
93  * \param[out] j3 the resultant third moment invariant
94  */
95  void
97  float &j1, float &j2, float &j3);
98 
99  protected:
100 
101  /** \brief Estimate moment invariants for all points given in <setInputCloud (), setIndices ()> using the surface
102  * in setSearchSurface () and the spatial locator in setSearchMethod ()
103  * \param[out] output the resultant point cloud model dataset that contains the moment invariants
104  */
105  void
106  computeFeature (PointCloudOut &output) override;
107  private:
108  /** \brief 16-bytes aligned placeholder for the XYZ centroid of a surface patch. */
109  Eigen::Vector4f xyz_centroid_;
110 
111  /** \brief Internal data vector. */
112  Eigen::Vector4f temp_pt_;
113  };
114 }
115 
116 #ifdef PCL_NO_PRECOMPILE
117 #include <pcl/features/impl/moment_invariants.hpp>
118 #endif
Feature represents the base feature class.
Definition: feature.h:107
shared_ptr< Feature< PointInT, PointOutT > > Ptr
Definition: feature.h:114
std::string feature_name_
The feature name.
Definition: feature.h:220
shared_ptr< const Feature< PointInT, PointOutT > > ConstPtr
Definition: feature.h:115
MomentInvariantsEstimation estimates the 3 moment invariants (j1, j2, j3) at each 3D point.
MomentInvariantsEstimation()
Empty constructor.
void computeFeature(PointCloudOut &output) override
Estimate moment invariants for all points given in <setInputCloud (), setIndices ()> using the surfac...
typename Feature< PointInT, PointOutT >::PointCloudOut PointCloudOut
void computePointMomentInvariants(const pcl::PointCloud< PointInT > &cloud, const pcl::Indices &indices, float &j1, float &j2, float &j3)
Compute the 3 moment invariants (j1, j2, j3) for a given set of points, using their indices.
IndicesAllocator<> Indices
Type used for indices in PCL.
Definition: types.h:133