Point Cloud Library (PCL)  1.9.1
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
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 #ifndef PCL_MOMENT_INVARIANTS_H_
42 #define PCL_MOMENT_INVARIANTS_H_
43 
44 #include <pcl/features/feature.h>
45 
46 namespace pcl
47 {
48  /** \brief MomentInvariantsEstimation estimates the 3 moment invariants (j1, j2, j3) at each 3D point.
49  *
50  * \note The code is stateful as we do not expect this class to be multicore parallelized. Please look at
51  * \ref NormalEstimationOMP for an example on how to extend this to parallel implementations.
52  * \author Radu B. Rusu
53  * \ingroup features
54  */
55  template <typename PointInT, typename PointOutT>
56  class MomentInvariantsEstimation: public Feature<PointInT, PointOutT>
57  {
58  public:
59  typedef boost::shared_ptr<MomentInvariantsEstimation<PointInT, PointOutT> > Ptr;
60  typedef boost::shared_ptr<const MomentInvariantsEstimation<PointInT, PointOutT> > ConstPtr;
68 
70 
71  /** \brief Empty constructor. */
72  MomentInvariantsEstimation () : xyz_centroid_ (), temp_pt_ ()
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 std::vector<int> &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);
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
119 
120 #endif //#ifndef PCL_MOMENT_INVARIANTS_H_
std::string feature_name_
The feature name.
Definition: feature.h:222
This file defines compatibility wrappers for low level I/O functions.
Definition: convolution.h:45
boost::shared_ptr< const MomentInvariantsEstimation< PointInT, PointOutT > > ConstPtr
MomentInvariantsEstimation()
Empty constructor.
void computePointMomentInvariants(const pcl::PointCloud< PointInT > &cloud, const std::vector< int > &indices, float &j1, float &j2, float &j3)
Compute the 3 moment invariants (j1, j2, j3) for a given set of points, using their indices...
MomentInvariantsEstimation estimates the 3 moment invariants (j1, j2, j3) at each 3D point...
PointCloud represents the base class in PCL for storing collections of 3D points. ...
boost::shared_ptr< MomentInvariantsEstimation< PointInT, PointOutT > > Ptr
Feature< PointInT, PointOutT >::PointCloudOut PointCloudOut
Feature represents the base feature class.
Definition: feature.h:105
void computeFeature(PointCloudOut &output)
Estimate moment invariants for all points given in using the surfac...