Point Cloud Library (PCL) 1.12.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:
60
61 /** \brief Constructor */
63 use_depth_dependent_smoothing_(false),
64 max_depth_change_factor_(1.0f),
65 normal_smoothing_size_(9.0f)
66 {
67 feature_name_ = "LinearLeastSquaresNormalEstimation";
68 tree_.reset ();
69 k_ = 1;
70 };
71
72 /** \brief Destructor */
74
75 /** \brief Computes the normal at the specified position.
76 * \param[in] pos_x x position (pixel)
77 * \param[in] pos_y y position (pixel)
78 * \param[out] normal the output estimated normal
79 */
80 void
81 computePointNormal (const int pos_x, const int pos_y, PointOutT &normal);
82
83 /** \brief Set the normal smoothing size
84 * \param[in] normal_smoothing_size factor which influences the size of the area used to smooth normals
85 * (depth dependent if useDepthDependentSmoothing is true)
86 */
87 void
89 {
90 normal_smoothing_size_ = normal_smoothing_size;
91 }
92
93 /** \brief Set whether to use depth depending smoothing or not
94 * \param[in] use_depth_dependent_smoothing decides whether the smoothing is depth dependent
95 */
96 void
98 {
99 use_depth_dependent_smoothing_ = use_depth_dependent_smoothing;
100 }
101
102 /** \brief The depth change threshold for computing object borders
103 * \param[in] max_depth_change_factor the depth change threshold for computing object borders based on
104 * depth changes
105 */
106 void
108 {
109 max_depth_change_factor_ = max_depth_change_factor;
110 }
111
112 /** \brief Provide a pointer to the input dataset (overwrites the PCLBase::setInputCloud method)
113 * \param[in] cloud the const boost shared pointer to a PointCloud message
114 */
115 inline void
116 setInputCloud (const typename PointCloudIn::ConstPtr &cloud) override
117 {
118 input_ = cloud;
119 }
120
121 protected:
122 /** \brief Computes the normal for the complete cloud.
123 * \param[out] output the resultant normals
124 */
125 void
127
128 private:
129
130 /** the threshold used to detect depth discontinuities */
131 //float distance_threshold_;
132
133 /** \brief Smooth data based on depth (true/false). */
134 bool use_depth_dependent_smoothing_;
135
136 /** \brief Threshold for detecting depth discontinuities */
137 float max_depth_change_factor_;
138
139 /** \brief */
140 float normal_smoothing_size_;
141 };
142}
143
144#ifdef PCL_NO_PRECOMPILE
145#include <pcl/features/impl/linear_least_squares_normal.hpp>
146#endif
Iterator class for point clouds with or without given indices.
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:243
std::string feature_name_
The feature name.
Definition feature.h:223
KdTreePtr tree_
A pointer to the spatial search object.
Definition feature.h:234
Surface normal estimation on dense data using a least-squares estimation based on a first-order Taylo...
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.
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.
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