Point Cloud Library (PCL) 1.13.1
Loading...
Searching...
No Matches
harris_3d.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 *
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 *
13 * * Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * * Redistributions in binary form must reproduce the above
16 * copyright notice, this list of conditions and the following
17 * disclaimer in the documentation and/or other materials provided
18 * with the distribution.
19 * * Neither the name of Willow Garage, Inc. nor the names of its
20 * contributors may be used to endorse or promote products derived
21 * from this software without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
26 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
27 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
28 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
29 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
33 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34 * POSSIBILITY OF SUCH DAMAGE.
35 *
36 */
37
38#pragma once
39
40#include <pcl/keypoints/keypoint.h>
41
42namespace pcl
43{
44 /** \brief HarrisKeypoint3D uses the idea of 2D Harris keypoints, but instead of using image gradients, it uses
45 * surface normals.
46 *
47 * \author Suat Gedikli
48 * \ingroup keypoints
49 */
50 template <typename PointInT, typename PointOutT, typename NormalT = pcl::Normal>
51 class HarrisKeypoint3D : public Keypoint<PointInT, PointOutT>
52 {
53 public:
54 using Ptr = shared_ptr<HarrisKeypoint3D<PointInT, PointOutT, NormalT> >;
55 using ConstPtr = shared_ptr<const HarrisKeypoint3D<PointInT, PointOutT, NormalT> >;
56
60 using PointCloudInConstPtr = typename PointCloudIn::ConstPtr;
61
65
66 using Keypoint<PointInT, PointOutT>::name_;
67 using Keypoint<PointInT, PointOutT>::input_;
68 using Keypoint<PointInT, PointOutT>::indices_;
69 using Keypoint<PointInT, PointOutT>::surface_;
70 using Keypoint<PointInT, PointOutT>::tree_;
71 using Keypoint<PointInT, PointOutT>::k_;
72 using Keypoint<PointInT, PointOutT>::search_radius_;
73 using Keypoint<PointInT, PointOutT>::search_parameter_;
74 using Keypoint<PointInT, PointOutT>::keypoints_indices_;
75 using Keypoint<PointInT, PointOutT>::initCompute;
76 using PCLBase<PointInT>::setInputCloud;
77
79
80 /** \brief Constructor
81 * \param[in] method the method to be used to determine the corner responses
82 * \param[in] radius the radius for normal estimation as well as for non maxima suppression
83 * \param[in] threshold the threshold to filter out weak corners
84 */
85 HarrisKeypoint3D (ResponseMethod method = HARRIS, float radius = 0.01f, float threshold = 0.0f)
86 : threshold_ (threshold)
87 , refine_ (true)
88 , nonmax_ (true)
89 , method_ (method)
90 , threads_ (0)
91 {
92 name_ = "HarrisKeypoint3D";
93 search_radius_ = radius;
94 }
95
96 /** \brief Empty destructor */
97 ~HarrisKeypoint3D () override = default;
98
99 /** \brief Provide a pointer to the input dataset
100 * \param[in] cloud the const boost shared pointer to a PointCloud message
101 */
102 void
103 setInputCloud (const PointCloudInConstPtr &cloud) override;
104
105 /** \brief Set the method of the response to be calculated.
106 * \param[in] type
107 */
108 void
110
111 /** \brief Set the radius for normal estimation and non maxima suppression.
112 * \param[in] radius
113 */
114 void
115 setRadius (float radius);
116
117 /** \brief Set the threshold value for detecting corners. This is only evaluated if non maxima suppression is turned on.
118 * \brief note non maxima suppression needs to be activated in order to use this feature.
119 * \param[in] threshold
120 */
121 void
122 setThreshold (float threshold);
123
124 /** \brief Whether non maxima suppression should be applied or the response for each point should be returned
125 * \note this value needs to be turned on in order to apply thresholding and refinement
126 * \param[in] nonmax default is false
127 */
128 void
129 setNonMaxSupression (bool = false);
130
131 /** \brief Whether the detected key points should be refined or not. If turned of, the key points are a subset of the original point cloud. Otherwise the key points may be arbitrary.
132 * \brief note non maxima suppression needs to be on in order to use this feature.
133 * \param[in] do_refine
134 */
135 void
136 setRefine (bool do_refine);
137
138 /** \brief Set normals if precalculated normals are available.
139 * \param normals
140 */
141 void
142 setNormals (const PointCloudNConstPtr &normals);
143
144 /** \brief Provide a pointer to a dataset to add additional information
145 * to estimate the features for every point in the input dataset. This
146 * is optional, if this is not set, it will only use the data in the
147 * input cloud to estimate the features. This is useful when you only
148 * need to compute the features for a downsampled cloud.
149 * \param[in] cloud a pointer to a PointCloud message
150 */
151 void
152 setSearchSurface (const PointCloudInConstPtr &cloud) override { surface_ = cloud; normals_.reset(); }
153
154 /** \brief Initialize the scheduler and set the number of threads to use.
155 * \param nr_threads the number of hardware threads to use (0 sets the value back to automatic)
156 */
157 inline void
158 setNumberOfThreads (unsigned int nr_threads = 0) { threads_ = nr_threads; }
159 protected:
160 bool
161 initCompute () override;
162 void detectKeypoints (PointCloudOut &output) override;
163 /** \brief gets the corner response for valid input points*/
164 void responseHarris (PointCloudOut &output) const;
165 void responseNoble (PointCloudOut &output) const;
166 void responseLowe (PointCloudOut &output) const;
167 void responseTomasi (PointCloudOut &output) const;
168 void responseCurvature (PointCloudOut &output) const;
169 void refineCorners (PointCloudOut &corners) const;
170 /** \brief calculates the upper triangular part of unnormalized covariance matrix over the normals given by the indices.*/
171 void calculateNormalCovar (const pcl::Indices& neighbors, float* coefficients) const;
172 private:
173 float threshold_;
174 bool refine_;
175 bool nonmax_;
176 ResponseMethod method_;
177 PointCloudNConstPtr normals_;
178 unsigned int threads_;
179 };
180}
181
182#include <pcl/keypoints/impl/harris_3d.hpp>
HarrisKeypoint3D uses the idea of 2D Harris keypoints, but instead of using image gradients,...
Definition harris_3d.h:52
typename PointCloudN::Ptr PointCloudNPtr
Definition harris_3d.h:63
void responseTomasi(PointCloudOut &output) const
HarrisKeypoint3D(ResponseMethod method=HARRIS, float radius=0.01f, float threshold=0.0f)
Constructor.
Definition harris_3d.h:85
void detectKeypoints(PointCloudOut &output) override
typename Keypoint< PointInT, PointOutT >::KdTree KdTree
Definition harris_3d.h:59
typename PointCloudN::ConstPtr PointCloudNConstPtr
Definition harris_3d.h:64
void responseNoble(PointCloudOut &output) const
bool initCompute() override
void responseHarris(PointCloudOut &output) const
gets the corner response for valid input points
shared_ptr< const HarrisKeypoint3D< PointInT, PointOutT, NormalT > > ConstPtr
Definition harris_3d.h:55
typename Keypoint< PointInT, PointOutT >::PointCloudOut PointCloudOut
Definition harris_3d.h:58
void setNormals(const PointCloudNConstPtr &normals)
Set normals if precalculated normals are available.
Definition harris_3d.hpp:96
void setNumberOfThreads(unsigned int nr_threads=0)
Initialize the scheduler and set the number of threads to use.
Definition harris_3d.h:158
void responseCurvature(PointCloudOut &output) const
shared_ptr< HarrisKeypoint3D< PointInT, PointOutT, NormalT > > Ptr
Definition harris_3d.h:54
void refineCorners(PointCloudOut &corners) const
void setRadius(float radius)
Set the radius for normal estimation and non maxima suppression.
Definition harris_3d.hpp:75
~HarrisKeypoint3D() override=default
Empty destructor.
void setNonMaxSupression(bool=false)
Whether non maxima suppression should be applied or the response for each point should be returned.
Definition harris_3d.hpp:89
void setSearchSurface(const PointCloudInConstPtr &cloud) override
Provide a pointer to a dataset to add additional information to estimate the features for every point...
Definition harris_3d.h:152
void setInputCloud(const PointCloudInConstPtr &cloud) override
Provide a pointer to the input dataset.
Definition harris_3d.hpp:52
void setMethod(ResponseMethod type)
Set the method of the response to be calculated.
Definition harris_3d.hpp:61
void setThreshold(float threshold)
Set the threshold value for detecting corners.
Definition harris_3d.hpp:68
void responseLowe(PointCloudOut &output) const
void calculateNormalCovar(const pcl::Indices &neighbors, float *coefficients) const
calculates the upper triangular part of unnormalized covariance matrix over the normals given by the ...
typename PointCloudIn::ConstPtr PointCloudInConstPtr
Definition harris_3d.h:60
void setRefine(bool do_refine)
Whether the detected key points should be refined or not.
Definition harris_3d.hpp:82
typename Keypoint< PointInT, PointOutT >::PointCloudIn PointCloudIn
Definition harris_3d.h:57
Keypoint represents the base class for key points.
Definition keypoint.h:49
int k_
The number of K nearest neighbors to use for each point.
Definition keypoint.h:190
std::string name_
The key point detection method's name.
Definition keypoint.h:169
double search_parameter_
The actual search parameter (casted from either search_radius_ or k_).
Definition keypoint.h:184
pcl::PointIndicesPtr keypoints_indices_
Indices of the keypoints in the input cloud.
Definition keypoint.h:193
KdTreePtr tree_
A pointer to the spatial search object.
Definition keypoint.h:181
PointCloudInConstPtr surface_
An input point cloud describing the surface that is to be used for nearest neighbors estimation.
Definition keypoint.h:178
double search_radius_
The nearest neighbors search radius for each point.
Definition keypoint.h:187
PCL base class.
Definition pcl_base.h:70
PointCloudConstPtr input_
The input point cloud dataset.
Definition pcl_base.h:147
IndicesPtr indices_
A pointer to the vector of point indices to use.
Definition pcl_base.h:150
shared_ptr< PointCloud< NormalT > > Ptr
shared_ptr< const PointCloud< NormalT > > ConstPtr
IndicesAllocator<> Indices
Type used for indices in PCL.
Definition types.h:133