Point Cloud Library (PCL) 1.12.0
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
45namespace 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 */
54 template <typename PointInT, typename PointOutT>
55 class MomentInvariantsEstimation: public Feature<PointInT, PointOutT>
56 {
57 public:
58 using Ptr = shared_ptr<MomentInvariantsEstimation<PointInT, PointOutT> >;
59 using ConstPtr = shared_ptr<const MomentInvariantsEstimation<PointInT, PointOutT> >;
67
69
70 /** \brief Empty constructor. */
72 {
73 feature_name_ = "MomentInvariantsEstimation";
74 };
75
76 /** \brief Compute the 3 moment invariants (j1, j2, j3) for a given set of points, using their indices.
77 * \param[in] cloud the input point cloud
78 * \param[in] indices the point cloud indices that need to be used
79 * \param[out] j1 the resultant first moment invariant
80 * \param[out] j2 the resultant second moment invariant
81 * \param[out] j3 the resultant third moment invariant
82 */
83 void
85 const pcl::Indices &indices,
86 float &j1, float &j2, float &j3);
87
88 /** \brief Compute the 3 moment invariants (j1, j2, j3) for a given set of points, using their indices.
89 * \param[in] cloud the input point cloud
90 * \param[out] j1 the resultant first moment invariant
91 * \param[out] j2 the resultant second moment invariant
92 * \param[out] j3 the resultant third moment invariant
93 */
94 void
96 float &j1, float &j2, float &j3);
97
98 protected:
99
100 /** \brief Estimate moment invariants for all points given in <setInputCloud (), setIndices ()> using the surface
101 * in setSearchSurface () and the spatial locator in setSearchMethod ()
102 * \param[out] output the resultant point cloud model dataset that contains the moment invariants
103 */
104 void
105 computeFeature (PointCloudOut &output) override;
106 private:
107 /** \brief 16-bytes aligned placeholder for the XYZ centroid of a surface patch. */
108 Eigen::Vector4f xyz_centroid_;
109
110 /** \brief Internal data vector. */
111 Eigen::Vector4f temp_pt_;
112 };
113}
114
115#ifdef PCL_NO_PRECOMPILE
116#include <pcl/features/impl/moment_invariants.hpp>
117#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:223
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