Point Cloud Library (PCL) 1.15.1-dev
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#include <pcl/point_types.h> // for pcl::Normal
42
43namespace pcl
44{
45 /** \brief HarrisKeypoint3D uses the idea of 2D Harris keypoints, but instead of using image gradients, it uses
46 * surface normals.
47 *
48 * \author Suat Gedikli
49 * \ingroup keypoints
50 */
51 template <typename PointInT, typename PointOutT, typename NormalT = pcl::Normal>
52 class HarrisKeypoint3D : public Keypoint<PointInT, PointOutT>
53 {
54 public:
55 using Ptr = shared_ptr<HarrisKeypoint3D<PointInT, PointOutT, NormalT> >;
56 using ConstPtr = shared_ptr<const HarrisKeypoint3D<PointInT, PointOutT, NormalT> >;
57
61 using PointCloudInConstPtr = typename PointCloudIn::ConstPtr;
62
66
67 using Keypoint<PointInT, PointOutT>::name_;
68 using Keypoint<PointInT, PointOutT>::input_;
69 using Keypoint<PointInT, PointOutT>::indices_;
70 using Keypoint<PointInT, PointOutT>::surface_;
71 using Keypoint<PointInT, PointOutT>::tree_;
72 using Keypoint<PointInT, PointOutT>::k_;
73 using Keypoint<PointInT, PointOutT>::search_radius_;
74 using Keypoint<PointInT, PointOutT>::search_parameter_;
75 using Keypoint<PointInT, PointOutT>::keypoints_indices_;
76 using Keypoint<PointInT, PointOutT>::initCompute;
77 using PCLBase<PointInT>::setInputCloud;
78
80
81 /** \brief Constructor
82 * \param[in] method the method to be used to determine the corner responses
83 * \param[in] radius the radius for normal estimation as well as for non maxima suppression
84 * \param[in] threshold the threshold to filter out weak corners
85 */
86 HarrisKeypoint3D (ResponseMethod method = HARRIS, float radius = 0.01f, float threshold = 0.0f)
87 : threshold_ (threshold)
88 , method_ (method)
89 {
90 name_ = "HarrisKeypoint3D";
91 search_radius_ = radius;
92 }
93
94 /** \brief Empty destructor */
95 ~HarrisKeypoint3D () override = default;
96
97 /** \brief Provide a pointer to the input dataset
98 * \param[in] cloud the const boost shared pointer to a PointCloud message
99 */
100 void
101 setInputCloud (const PointCloudInConstPtr &cloud) override;
102
103 /** \brief Set the method of the response to be calculated.
104 * \param[in] type
105 */
106 void
108
109 /** \brief Set the radius for normal estimation and non maxima suppression.
110 * \param[in] radius
111 */
112 void
113 setRadius (float radius);
114
115 /** \brief Set the threshold value for detecting corners. This is only evaluated if non maxima suppression is turned on.
116 * \brief note non maxima suppression needs to be activated in order to use this feature.
117 * \param[in] threshold
118 */
119 void
120 setThreshold (float threshold);
121
122 /** \brief Whether non maxima suppression should be applied or the response for each point should be returned
123 * \note this value needs to be turned on in order to apply thresholding and refinement
124 * \param[in] nonmax default is false
125 */
126 void
127 setNonMaxSupression (bool = false);
128
129 /** \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.
130 * \brief note non maxima suppression needs to be on in order to use this feature.
131 * \param[in] do_refine
132 */
133 void
134 setRefine (bool do_refine);
135
136 /** \brief Set normals if precalculated normals are available.
137 * \param normals
138 */
139 void
140 setNormals (const PointCloudNConstPtr &normals);
141
142 /** \brief Provide a pointer to a dataset to add additional information
143 * to estimate the features for every point in the input dataset. This
144 * is optional, if this is not set, it will only use the data in the
145 * input cloud to estimate the features. This is useful when you only
146 * need to compute the features for a downsampled cloud.
147 * \param[in] cloud a pointer to a PointCloud message
148 */
149 void
150 setSearchSurface (const PointCloudInConstPtr &cloud) override { surface_ = cloud; normals_.reset(); }
151
152 /** \brief Initialize the scheduler and set the number of threads to use.
153 * \param nr_threads the number of hardware threads to use (0 sets the value back to automatic)
154 */
155 inline void
156 setNumberOfThreads (unsigned int nr_threads = 0) { threads_ = nr_threads; }
157 protected:
158 bool
159 initCompute () override;
160 void detectKeypoints (PointCloudOut &output) override;
161 /** \brief gets the corner response for valid input points*/
162 void responseHarris (PointCloudOut &output) const;
163 void responseNoble (PointCloudOut &output) const;
164 void responseLowe (PointCloudOut &output) const;
165 void responseTomasi (PointCloudOut &output) const;
166 void responseCurvature (PointCloudOut &output) const;
167 void refineCorners (PointCloudOut &corners) const;
168 /** \brief calculates the upper triangular part of unnormalized covariance matrix over the normals given by the indices.*/
169 void calculateNormalCovar (const pcl::Indices& neighbors, float* coefficients) const;
170 private:
171 float threshold_;
172 bool refine_{true};
173 bool nonmax_{true};
174 ResponseMethod method_;
175 PointCloudNConstPtr normals_;
176 unsigned int threads_{0};
177 };
178}
179
180#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:53
typename PointCloudN::Ptr PointCloudNPtr
Definition harris_3d.h:64
void responseTomasi(PointCloudOut &output) const
HarrisKeypoint3D(ResponseMethod method=HARRIS, float radius=0.01f, float threshold=0.0f)
Constructor.
Definition harris_3d.h:86
void detectKeypoints(PointCloudOut &output) override
typename Keypoint< PointInT, PointOutT >::KdTree KdTree
Definition harris_3d.h:60
typename PointCloudN::ConstPtr PointCloudNConstPtr
Definition harris_3d.h:65
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:56
typename Keypoint< PointInT, PointOutT >::PointCloudOut PointCloudOut
Definition harris_3d.h:59
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:156
void responseCurvature(PointCloudOut &output) const
shared_ptr< HarrisKeypoint3D< PointInT, PointOutT, NormalT > > Ptr
Definition harris_3d.h:55
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:150
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:61
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:58
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:188
std::string name_
The key point detection method's name.
Definition keypoint.h:167
double search_parameter_
The actual search parameter (casted from either search_radius_ or k_).
Definition keypoint.h:182
pcl::PointIndicesPtr keypoints_indices_
Indices of the keypoints in the input cloud.
Definition keypoint.h:191
KdTreePtr tree_
A pointer to the spatial search object.
Definition keypoint.h:179
PointCloudInConstPtr surface_
An input point cloud describing the surface that is to be used for nearest neighbors estimation.
Definition keypoint.h:176
double search_radius_
The nearest neighbors search radius for each point.
Definition keypoint.h:185
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
Defines all the PCL implemented PointT point type structures.
IndicesAllocator<> Indices
Type used for indices in PCL.
Definition types.h:133