Point Cloud Library (PCL)  1.6.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
harris_keypoint3D.h
Go to the documentation of this file.
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 #ifndef PCL_HARRIS_KEYPOINT_3D_H_
39 #define PCL_HARRIS_KEYPOINT_3D_H_
40 
41 #include <pcl/keypoints/keypoint.h>
42 
43 namespace pcl
44 {
51  template <typename PointInT, typename PointOutT, typename NormalT = pcl::Normal>
52  class HarrisKeypoint3D : public Keypoint<PointInT, PointOutT>
53  {
54  public:
59 
61  typedef typename PointCloudN::Ptr PointCloudNPtr;
63 
73 
74  typedef enum {HARRIS = 1, NOBLE, LOWE, TOMASI, CURVATURE} ResponseMethod;
75 
81  HarrisKeypoint3D (ResponseMethod method = HARRIS, float radius = 0.01f, float threshold = 0.0f)
82  : threshold_ (threshold)
83  , refine_ (true)
84  , nonmax_ (true)
85  , method_ (method)
86  , normals_ (new pcl::PointCloud<NormalT>)
87  , threads_ (1)
88  {
89  name_ = "HarrisKeypoint3D";
90  search_radius_ = radius;
91  }
92 
96  void
98 
102  void
103  setRadius (float radius);
104 
109  void
110  setThreshold (float threshold);
111 
116  void
117  setNonMaxSupression (bool = false);
118 
123  void
124  setRefine (bool do_refine);
125 
129  void
130  setNormals (const PointCloudNPtr &normals);
131 
139  virtual void
140  setSearchSurface (const PointCloudInConstPtr &cloud) { surface_ = cloud; normals_->clear (); }
141 
145  inline void
146  setNumberOfThreads (int nr_threads)
147  {
148  if (nr_threads == 0)
149  nr_threads = 1;
150  threads_ = nr_threads;
151  }
152  protected:
153  bool
154  initCompute ();
155  void detectKeypoints (PointCloudOut &output);
157  void responseHarris (PointCloudOut &output) const;
158  void responseNoble (PointCloudOut &output) const;
159  void responseLowe (PointCloudOut &output) const;
160  void responseTomasi (PointCloudOut &output) const;
161  void responseCurvature (PointCloudOut &output) const;
162  void refineCorners (PointCloudOut &corners) const;
164  void calculateNormalCovar (const std::vector<int>& neighbors, float* coefficients) const;
165  private:
166  float threshold_;
167  bool refine_;
168  bool nonmax_;
169  ResponseMethod method_;
170  PointCloudNPtr normals_;
171  int threads_;
172  };
173 }
174 
176 
177 #endif // #ifndef PCL_HARRIS_KEYPOINT_3D_H_
178