Point Cloud Library (PCL)  1.10.0-dev
linear_least_squares_normal.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  */
38 
39 #pragma once
40 
41 #include <pcl/point_cloud.h>
42 #include <pcl/point_types.h>
43 #include <pcl/features/feature.h>
44 
45 namespace pcl
46 {
47  /** \brief Surface normal estimation on dense data using a least-squares estimation based on a first-order Taylor approximation.
48  * \author Stefan Holzer, Cedric Cagniart
49  */
50  template <typename PointInT, typename PointOutT>
51  class LinearLeastSquaresNormalEstimation : public Feature<PointInT, PointOutT>
52  {
53  public:
62 
63  /** \brief Constructor */
65  use_depth_dependent_smoothing_(false),
66  max_depth_change_factor_(1.0f),
67  normal_smoothing_size_(9.0f)
68  {
69  feature_name_ = "LinearLeastSquaresNormalEstimation";
70  tree_.reset ();
71  k_ = 1;
72  };
73 
74  /** \brief Destructor */
76 
77  /** \brief Computes the normal at the specified position.
78  * \param[in] pos_x x position (pixel)
79  * \param[in] pos_y y position (pixel)
80  * \param[out] normal the output estimated normal
81  */
82  void
83  computePointNormal (const int pos_x, const int pos_y, PointOutT &normal);
84 
85  /** \brief Set the normal smoothing size
86  * \param[in] normal_smoothing_size factor which influences the size of the area used to smooth normals
87  * (depth dependent if useDepthDependentSmoothing is true)
88  */
89  void
90  setNormalSmoothingSize (float normal_smoothing_size)
91  {
92  normal_smoothing_size_ = normal_smoothing_size;
93  }
94 
95  /** \brief Set whether to use depth depending smoothing or not
96  * \param[in] use_depth_dependent_smoothing decides whether the smoothing is depth dependent
97  */
98  void
99  setDepthDependentSmoothing (bool use_depth_dependent_smoothing)
100  {
101  use_depth_dependent_smoothing_ = use_depth_dependent_smoothing;
102  }
103 
104  /** \brief The depth change threshold for computing object borders
105  * \param[in] max_depth_change_factor the depth change threshold for computing object borders based on
106  * depth changes
107  */
108  void
109  setMaxDepthChangeFactor (float max_depth_change_factor)
110  {
111  max_depth_change_factor_ = max_depth_change_factor;
112  }
113 
114  /** \brief Provide a pointer to the input dataset (overwrites the PCLBase::setInputCloud method)
115  * \param[in] cloud the const boost shared pointer to a PointCloud message
116  */
117  inline void
118  setInputCloud (const typename PointCloudIn::ConstPtr &cloud) override
119  {
120  input_ = cloud;
121  }
122 
123  protected:
124  /** \brief Computes the normal for the complete cloud.
125  * \param[out] output the resultant normals
126  */
127  void
128  computeFeature (PointCloudOut &output) override;
129 
130  private:
131 
132  /** the threshold used to detect depth discontinuities */
133  //float distance_threshold_;
134 
135  /** \brief Smooth data based on depth (true/false). */
136  bool use_depth_dependent_smoothing_;
137 
138  /** \brief Threshold for detecting depth discontinuities */
139  float max_depth_change_factor_;
140 
141  /** \brief */
142  float normal_smoothing_size_;
143  };
144 }
145 
146 #ifdef PCL_NO_PRECOMPILE
147 #include <pcl/features/impl/linear_least_squares_normal.hpp>
148 #endif
void setDepthDependentSmoothing(bool use_depth_dependent_smoothing)
Set whether to use depth depending smoothing or not.
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
int k_
The number of K nearest neighbors to use for each point.
Definition: feature.h:242
void setNormalSmoothingSize(float normal_smoothing_size)
Set the normal smoothing size.
KdTreePtr tree_
A pointer to the spatial search object.
Definition: feature.h:233
shared_ptr< const Feature< PointInT, PointOutT > > ConstPtr
Definition: feature.h:114
void setMaxDepthChangeFactor(float max_depth_change_factor)
The depth change threshold for computing object borders.
Defines all the PCL implemented PointT point type structures.
void computeFeature(PointCloudOut &output) override
Computes the normal for the complete cloud.
shared_ptr< const PointCloud< PointInT > > ConstPtr
Definition: point_cloud.h:416
PointCloudConstPtr input_
The input point cloud dataset.
Definition: pcl_base.h:151
Feature represents the base feature class.
Definition: feature.h:105
void computePointNormal(const int pos_x, const int pos_y, PointOutT &normal)
Computes the normal at the specified position.
Surface normal estimation on dense data using a least-squares estimation based on a first-order Taylo...
void setInputCloud(const typename PointCloudIn::ConstPtr &cloud) override
Provide a pointer to the input dataset (overwrites the PCLBase::setInputCloud method) ...
boost::shared_ptr< T > shared_ptr
Alias for boost::shared_ptr.
Definition: pcl_macros.h:90
shared_ptr< Feature< PointInT, PointOutT > > Ptr
Definition: feature.h:113