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