Point Cloud Library (PCL) 1.14.0
Loading...
Searching...
No Matches
harris_6d.h
1/*
2 * Software License Agreement (BSD License)
3 *
4 * Copyright (c) 2010, Willow Garage, Inc.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 *
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above
14 * copyright notice, this list of conditions and the following
15 * disclaimer in the documentation and/or other materials provided
16 * with the distribution.
17 * * Neither the name of Willow Garage, Inc. nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 * POSSIBILITY OF SUCH DAMAGE.
33 *
34 * @author Suat Gedikli
35 */
36
37#pragma once
38
39#include <pcl/keypoints/keypoint.h>
40
41namespace pcl
42{
43
44 /** \brief Keypoint detector for detecting corners in 3D (XYZ), 2D (intensity) AND mixed versions of these.
45 * \author Suat Gedikli
46 * \ingroup keypoints
47 */
48 template <typename PointInT, typename PointOutT, typename NormalT = pcl::Normal>
49 class HarrisKeypoint6D : public Keypoint<PointInT, PointOutT>
50 {
51 public:
52 using Ptr = shared_ptr<HarrisKeypoint6D<PointInT, PointOutT, NormalT> >;
53 using ConstPtr = shared_ptr<const HarrisKeypoint6D<PointInT, PointOutT, NormalT> >;
54
58 using PointCloudInConstPtr = typename PointCloudIn::ConstPtr;
59
60 using Keypoint<PointInT, PointOutT>::name_;
61 using Keypoint<PointInT, PointOutT>::input_;
62 using Keypoint<PointInT, PointOutT>::indices_;
63 using Keypoint<PointInT, PointOutT>::surface_;
64 using Keypoint<PointInT, PointOutT>::tree_;
65 using Keypoint<PointInT, PointOutT>::k_;
66 using Keypoint<PointInT, PointOutT>::search_radius_;
67 using Keypoint<PointInT, PointOutT>::search_parameter_;
68 using Keypoint<PointInT, PointOutT>::keypoints_indices_;
69
70 /**
71 * @brief Constructor
72 * @param radius the radius for normal estimation as well as for non maxima suppression
73 * @param threshold the threshold to filter out weak corners
74 */
75 HarrisKeypoint6D (float radius = 0.01, float threshold = 0.0)
76 : threshold_ (threshold)
77 ,
78 normals_ (new pcl::PointCloud<NormalT>)
79 , intensity_gradients_ (new pcl::PointCloud<pcl::IntensityGradient>)
80 {
81 name_ = "HarrisKeypoint6D";
82 search_radius_ = radius;
83 }
84
85 /** \brief Empty destructor */
86 virtual ~HarrisKeypoint6D () = default;
87
88 /**
89 * @brief set the radius for normal estimation and non maxima suppression.
90 * @param radius
91 */
92 void setRadius (float radius);
93
94 /**
95 * @brief set the threshold value for detecting corners. This is only evaluated if non maxima suppression is turned on.
96 * @brief note non maxima suppression needs to be activated in order to use this feature.
97 * @param threshold
98 */
99 void setThreshold (float threshold);
100
101 /**
102 * @brief whether non maxima suppression should be applied or the response for each point should be returned
103 * @note this value needs to be turned on in order to apply thresholding and refinement
104 * @param nonmax default is false
105 */
106 void setNonMaxSupression (bool = false);
107
108 /**
109 * @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.
110 * @brief note non maxima suppression needs to be on in order to use this feature.
111 * @param do_refine
112 */
113 void setRefine (bool do_refine);
114
115 virtual void
116 setSearchSurface (const PointCloudInConstPtr &cloud) { surface_ = cloud; normals_->clear (); intensity_gradients_->clear ();}
117
118 /** \brief Initialize the scheduler and set the number of threads to use.
119 * \param nr_threads the number of hardware threads to use (0 sets the value back to automatic)
120 */
121 inline void
122 setNumberOfThreads (unsigned int nr_threads = 0) { threads_ = nr_threads; }
123 protected:
124 void detectKeypoints (PointCloudOut &output);
125 void responseTomasi (PointCloudOut &output) const;
126 void refineCorners (PointCloudOut &corners) const;
127 void calculateCombinedCovar (const pcl::Indices& neighbors, float* coefficients) const;
128 private:
129 float threshold_;
130 bool refine_{true};
131 bool nonmax_{true};
132 unsigned int threads_{0};
133 typename pcl::PointCloud<NormalT>::Ptr normals_;
135 } ;
136}
137
138#include <pcl/keypoints/impl/harris_6d.hpp>
Keypoint detector for detecting corners in 3D (XYZ), 2D (intensity) AND mixed versions of these.
Definition harris_6d.h:50
typename Keypoint< PointInT, PointOutT >::PointCloudIn PointCloudIn
Definition harris_6d.h:55
void setNonMaxSupression(bool=false)
whether non maxima suppression should be applied or the response for each point should be returned
Definition harris_6d.hpp:68
shared_ptr< const HarrisKeypoint6D< PointInT, PointOutT, NormalT > > ConstPtr
Definition harris_6d.h:53
void setThreshold(float threshold)
set the threshold value for detecting corners.
Definition harris_6d.hpp:50
void setRefine(bool do_refine)
whether the detected key points should be refined or not.
Definition harris_6d.hpp:62
void setRadius(float radius)
set the radius for normal estimation and non maxima suppression.
Definition harris_6d.hpp:56
void responseTomasi(PointCloudOut &output) const
void setNumberOfThreads(unsigned int nr_threads=0)
Initialize the scheduler and set the number of threads to use.
Definition harris_6d.h:122
typename PointCloudIn::ConstPtr PointCloudInConstPtr
Definition harris_6d.h:58
void detectKeypoints(PointCloudOut &output)
typename Keypoint< PointInT, PointOutT >::PointCloudOut PointCloudOut
Definition harris_6d.h:56
void refineCorners(PointCloudOut &corners) const
typename Keypoint< PointInT, PointOutT >::KdTree KdTree
Definition harris_6d.h:57
shared_ptr< HarrisKeypoint6D< PointInT, PointOutT, NormalT > > Ptr
Definition harris_6d.h:52
virtual ~HarrisKeypoint6D()=default
Empty destructor.
HarrisKeypoint6D(float radius=0.01, float threshold=0.0)
Constructor.
Definition harris_6d.h:75
virtual void setSearchSurface(const PointCloudInConstPtr &cloud)
Definition harris_6d.h:116
void calculateCombinedCovar(const pcl::Indices &neighbors, float *coefficients) const
Definition harris_6d.hpp:75
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
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
void clear()
Removes all points in a cloud and sets the width and height to 0.
shared_ptr< PointCloud< PointT > > Ptr
IndicesAllocator<> Indices
Type used for indices in PCL.
Definition types.h:133
A point structure representing the intensity gradient of an XYZI point cloud.
A point structure representing normal coordinates and the surface curvature estimate.