Point Cloud Library (PCL)  1.9.1
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
susan.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  * $Id$
37  */
38 
39 #ifndef PCL_SUSAN_KEYPOINT_H_
40 #define PCL_SUSAN_KEYPOINT_H_
41 
42 #include <pcl/keypoints/keypoint.h>
43 #include <pcl/common/intensity.h>
44 
45 namespace pcl
46 {
47  /** \brief SUSANKeypoint implements a RGB-D extension of the SUSAN detector including normal
48  * directions variation in top of intensity variation.
49  * It is different from Harris in that it exploits normals directly so it is faster.
50  * Original paper "SUSAN — A New Approach to Low Level Image Processing", Smith,
51  * Stephen M. and Brady, J. Michael
52  *
53  * \author Nizar Sallem
54  * \ingroup keypoints
55  */
56  template <typename PointInT, typename PointOutT, typename NormalT = pcl::Normal, typename IntensityT= pcl::common::IntensityFieldAccessor<PointInT> >
57  class SUSANKeypoint : public Keypoint<PointInT, PointOutT>
58  {
59  public:
60  typedef boost::shared_ptr<SUSANKeypoint<PointInT, PointOutT, NormalT, IntensityT> > Ptr;
61  typedef boost::shared_ptr<const SUSANKeypoint<PointInT, PointOutT, NormalT, Intensity> > ConstPtr;
62 
67 
69  typedef typename PointCloudN::Ptr PointCloudNPtr;
71 
82 
83  /** \brief Constructor
84  * \param[in] radius the radius for normal estimation as well as for non maxima suppression
85  * \param[in] distance_threshold to test if the nucleus is far enough from the centroid
86  * \param[in] angular_threshold to test if normals are parallel
87  * \param[in] intensity_threshold to test if points are of same color
88  */
89  SUSANKeypoint (float radius = 0.01f,
90  float distance_threshold = 0.001f,
91  float angular_threshold = 0.0001f,
92  float intensity_threshold = 7.0f)
93  : distance_threshold_ (distance_threshold)
94  , angular_threshold_ (angular_threshold)
95  , intensity_threshold_ (intensity_threshold)
96  , normals_ (new pcl::PointCloud<NormalT>)
97  , threads_ (0)
98  , label_idx_ (-1)
99  , out_fields_ ()
100  {
101  name_ = "SUSANKeypoint";
102  search_radius_ = radius;
103  geometric_validation_ = false;
104  tolerance_ = 2 * distance_threshold_;
105  }
106 
107  /** \brief Empty destructor */
108  virtual ~SUSANKeypoint () {}
109 
110  /** \brief set the radius for normal estimation and non maxima supression.
111  * \param[in] radius
112  */
113  void
114  setRadius (float radius);
115 
116  void
117  setDistanceThreshold (float distance_threshold);
118 
119  /** \brief set the angular_threshold value for detecting corners. Normals are considered as
120  * parallel if 1 - angular_threshold <= (Ni.Nj) <= 1
121  * \param[in] angular_threshold
122  */
123  void
124  setAngularThreshold (float angular_threshold);
125 
126  /** \brief set the intensity_threshold value for detecting corners.
127  * \param[in] intensity_threshold
128  */
129  void
130  setIntensityThreshold (float intensity_threshold);
131 
132  /**
133  * \brief set normals if precalculated normals are available.
134  * \param normals
135  */
136  void
137  setNormals (const PointCloudNConstPtr &normals);
138 
139  virtual void
140  setSearchSurface (const PointCloudInConstPtr &cloud);
141 
142  /** \brief Initialize the scheduler and set the number of threads to use.
143  * \param nr_threads the number of hardware threads to use (0 sets the value back to automatic)
144  */
145  void
146  setNumberOfThreads (unsigned int nr_threads);
147 
148  /** \brief Apply non maxima suppression to the responses to keep strongest corners.
149  * \note in SUSAN points with less response or stronger corners
150  */
151  void
152  setNonMaxSupression (bool nonmax);
153 
154  /** \brief Filetr false positive using geometric criteria.
155  * The nucleus and the centroid should at least distance_threshold_ from each other AND all the
156  * points belonging to the USAN must be within the segment [nucleus centroid].
157  * \param[in] validate
158  */
159  void
160  setGeometricValidation (bool validate);
161 
162  protected:
163  bool
164  initCompute ();
165 
166  void
167  detectKeypoints (PointCloudOut &output);
168  /** \brief return true if a point lies within the line between the nucleus and the centroid
169  * \param[in] nucleus coordinate of the nucleus
170  * \param[in] centroid of the SUSAN
171  * \param[in] nc to centroid vector (used to speed up since it is constant for a given
172  * neighborhood)
173  * \param[in] point the query point to test against
174  * \return true if the point lies within [nucleus centroid]
175  */
176  bool
177  isWithinNucleusCentroid (const Eigen::Vector3f& nucleus,
178  const Eigen::Vector3f& centroid,
179  const Eigen::Vector3f& nc,
180  const PointInT& point) const;
181  private:
182  float distance_threshold_;
183  float angular_threshold_;
184  float intensity_threshold_;
185  float tolerance_;
186  PointCloudNConstPtr normals_;
187  unsigned int threads_;
188  bool geometric_validation_;
189  bool nonmax_;
190  /// intensity field accessor
191  IntensityT intensity_;
192  /** \brief Set to a value different than -1 if the output cloud has a "label" field and we have
193  * to save the keypoints indices.
194  */
195  int label_idx_;
196  /** \brief The list of fields present in the output point cloud data. */
197  std::vector<pcl::PCLPointField> out_fields_;
199  };
200 }
201 
202 #include <pcl/keypoints/impl/susan.hpp>
203 
204 #endif // #ifndef PCL_SUSAN_KEYPOINT_H_
void setNormals(const PointCloudNConstPtr &normals)
set normals if precalculated normals are available.
Definition: susan.hpp:89
A point structure representing normal coordinates and the surface curvature estimate.
boost::shared_ptr< PointCloud< NormalT > > Ptr
Definition: point_cloud.h:428
void setRadius(float radius)
set the radius for normal estimation and non maxima supression.
Definition: susan.hpp:61
virtual void setSearchSurface(const PointCloudInConstPtr &cloud)
Definition: susan.hpp:96
PointCloudIn::ConstPtr PointCloudInConstPtr
Definition: susan.h:66
SUSANKeypoint(float radius=0.01f, float distance_threshold=0.001f, float angular_threshold=0.0001f, float intensity_threshold=7.0f)
Constructor.
Definition: susan.h:89
bool initCompute()
Definition: susan.hpp:215
void setNumberOfThreads(unsigned int nr_threads)
Initialize the scheduler and set the number of threads to use.
Definition: susan.hpp:104
std::string name_
The key point detection method's name.
Definition: keypoint.h:173
This file defines compatibility wrappers for low level I/O functions.
Definition: convolution.h:45
void setDistanceThreshold(float distance_threshold)
Definition: susan.hpp:68
double search_radius_
The nearest neighbors search radius for each point.
Definition: keypoint.h:191
pcl::PointCloud< NormalT > PointCloudN
Definition: susan.h:68
boost::shared_ptr< const PointCloud< PointInT > > ConstPtr
Definition: point_cloud.h:429
Keypoint represents the base class for key points.
Definition: keypoint.h:49
void setGeometricValidation(bool validate)
Filetr false positive using geometric criteria.
Definition: susan.hpp:54
Keypoint< PointInT, PointOutT >::KdTree KdTree
Definition: susan.h:65
PointCloudN::Ptr PointCloudNPtr
Definition: susan.h:69
void setAngularThreshold(float angular_threshold)
set the angular_threshold value for detecting corners.
Definition: susan.hpp:75
bool isWithinNucleusCentroid(const Eigen::Vector3f &nucleus, const Eigen::Vector3f &centroid, const Eigen::Vector3f &nc, const PointInT &point) const
return true if a point lies within the line between the nucleus and the centroid
Definition: susan.hpp:255
void detectKeypoints(PointCloudOut &output)
Abstract key point detection method.
Definition: susan.hpp:303
virtual ~SUSANKeypoint()
Empty destructor.
Definition: susan.h:108
boost::shared_ptr< const SUSANKeypoint< PointInT, PointOutT, NormalT, Intensity > > ConstPtr
Definition: susan.h:61
void setNonMaxSupression(bool nonmax)
Apply non maxima suppression to the responses to keep strongest corners.
Definition: susan.hpp:47
SUSANKeypoint implements a RGB-D extension of the SUSAN detector including normal directions variatio...
Definition: susan.h:57
Keypoint< PointInT, PointOutT >::PointCloudOut PointCloudOut
Definition: susan.h:64
Keypoint< PointInT, PointOutT >::PointCloudIn PointCloudIn
Definition: susan.h:63
PointCloudN::ConstPtr PointCloudNConstPtr
Definition: susan.h:70
boost::shared_ptr< SUSANKeypoint< PointInT, PointOutT, NormalT, IntensityT > > Ptr
Definition: susan.h:60
void setIntensityThreshold(float intensity_threshold)
set the intensity_threshold value for detecting corners.
Definition: susan.hpp:82