Point Cloud Library (PCL)  1.14.1-dev
don.h
1 /*
2  * Software License Agreement (BSD License)
3  *
4  * Point Cloud Library (PCL) - www.pointclouds.org
5  * Copyright (c) 2012, Yani Ioannou <yani.ioannou@gmail.com>
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  */
38 
39 #pragma once
40 
41 #include <pcl/features/feature.h>
42 
43 namespace pcl
44 {
45  /** \brief A Difference of Normals (DoN) scale filter implementation for point cloud data.
46  *
47  * For each point in the point cloud two normals estimated with a differing search radius (sigma_s, sigma_l)
48  * are subtracted, the difference of these normals provides a scale-based feature which
49  * can be further used to filter the point cloud, somewhat like the Difference of Guassians
50  * in image processing, but instead on surfaces. Best results are had when the two search
51  * radii are related as sigma_l=10*sigma_s, the octaves between the two search radii
52  * can be though of as a filter bandwidth. For appropriate values and thresholds it
53  * can be used for surface edge extraction.
54  *
55  * \attention The input normals given by setInputNormalsSmall and setInputNormalsLarge have
56  * to match the input point cloud given by setInputCloud. This behavior is different than
57  * feature estimation methods that extend FeatureFromNormals, which match the normals
58  * with the search surface.
59  *
60  * \note For more information please see
61  * <b>Yani Ioannou. Automatic Urban Modelling using Mobile Urban LIDAR Data.
62  * Thesis (Master, Computing), Queen's University, March, 2010.</b>
63  *
64  * \author Yani Ioannou.
65  * \ingroup features
66  */
67  template <typename PointInT, typename PointNT, typename PointOutT>
68  class DifferenceOfNormalsEstimation : public Feature<PointInT, PointOutT>
69  {
74  using PointCloudNPtr = typename PointCloudN::Ptr;
75  using PointCloudNConstPtr = typename PointCloudN::ConstPtr;
76  using PointCloudOut = typename Feature<PointInT, PointOutT>::PointCloudOut;
77  public:
78  using Ptr = shared_ptr<DifferenceOfNormalsEstimation<PointInT, PointNT, PointOutT> >;
79  using ConstPtr = shared_ptr<const DifferenceOfNormalsEstimation<PointInT, PointNT, PointOutT> >;
80 
81  /**
82  * Creates a new Difference of Normals filter.
83  */
85  {
86  feature_name_ = "DifferenceOfNormalsEstimation";
87  }
88 
89  ~DifferenceOfNormalsEstimation () override = default;
90 
91  /**
92  * Set the normals calculated using a smaller search radius (scale) for the DoN operator.
93  * @param normals the smaller radius (scale) of the DoN filter.
94  */
95  inline void
96  setNormalScaleSmall (const PointCloudNConstPtr &normals)
97  {
98  input_normals_small_ = normals;
99  }
100 
101  /**
102  * Set the normals calculated using a larger search radius (scale) for the DoN operator.
103  * @param normals the larger radius (scale) of the DoN filter.
104  */
105  inline void
106  setNormalScaleLarge (const PointCloudNConstPtr &normals)
107  {
108  input_normals_large_ = normals;
109  }
110 
111  /**
112  * Computes the DoN vector for each point in the input point cloud and outputs the vector cloud to the given output.
113  * @param output the cloud to output the DoN vector cloud to.
114  */
115  void
116  computeFeature (PointCloudOut &output) override;
117 
118  /**
119  * Initialize for computation of features.
120  * @return true if parameters (input normals, input) are sufficient to perform computation.
121  */
122  bool
123  initCompute () override;
124  private:
125  /** \brief Make the compute (&PointCloudOut); inaccessible from outside the class
126  * \param[out] output the output point cloud
127  */
128  void
129  compute (PointCloudOut &) {}
130 
131  ///The smallest radius (scale) used in the DoN filter.
132  PointCloudNConstPtr input_normals_small_;
133  ///The largest radius (scale) used in the DoN filter.
134  PointCloudNConstPtr input_normals_large_;
135  };
136 }
137 
138 #ifdef PCL_NO_PRECOMPILE
139 #include <pcl/features/impl/don.hpp>
140 #endif
A Difference of Normals (DoN) scale filter implementation for point cloud data.
Definition: don.h:69
void setNormalScaleLarge(const PointCloudNConstPtr &normals)
Set the normals calculated using a larger search radius (scale) for the DoN operator.
Definition: don.h:106
DifferenceOfNormalsEstimation()
Creates a new Difference of Normals filter.
Definition: don.h:84
bool initCompute() override
Initialize for computation of features.
Definition: don.hpp:44
shared_ptr< DifferenceOfNormalsEstimation< PointInT, PointNT, PointOutT > > Ptr
Definition: don.h:78
void computeFeature(PointCloudOut &output) override
Computes the DoN vector for each point in the input point cloud and outputs the vector cloud to the g...
Definition: don.hpp:85
void setNormalScaleSmall(const PointCloudNConstPtr &normals)
Set the normals calculated using a smaller search radius (scale) for the DoN operator.
Definition: don.h:96
shared_ptr< const DifferenceOfNormalsEstimation< PointInT, PointNT, PointOutT > > ConstPtr
Definition: don.h:79
~DifferenceOfNormalsEstimation() override=default
Feature represents the base feature class.
Definition: feature.h:107
std::string feature_name_
The feature name.
Definition: feature.h:220
PCL base class.
Definition: pcl_base.h:70
shared_ptr< PointCloud< PointNT > > Ptr
Definition: point_cloud.h:413
shared_ptr< const PointCloud< PointNT > > ConstPtr
Definition: point_cloud.h:414