Point Cloud Library (PCL)  1.6.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
smoothed_surfaces_keypoint.h
Go to the documentation of this file.
1 /*
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2011, Alexandru-Eugen Ichim
5  * Willow Garage, Inc
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * * Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  * * Redistributions in binary form must reproduce the above
15  * copyright notice, this list of conditions and the following
16  * disclaimer in the documentation and/or other materials provided
17  * with the distribution.
18  * * Neither the name of Willow Garage, Inc. nor the names of its
19  * contributors may be used to endorse or promote products derived
20  * from this software without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
25  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
27  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
28  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
30  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
32  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33  * POSSIBILITY OF SUCH DAMAGE.
34  *
35  * $Id: smoothed_surfaces_keypoint.h 2127 2011-08-16 20:00:21Z aichim $
36  */
37 
38 #ifndef PCL_SMOOTHEDSURFACESKEYPOINT_H_
39 #define PCL_SMOOTHEDSURFACESKEYPOINT_H_
40 
41 #include <pcl/keypoints/keypoint.h>
42 
43 namespace pcl
44 {
54  template <typename PointT, typename PointNT>
55  class SmoothedSurfacesKeypoint : public Keypoint <PointT, PointT>
56  {
57  public:
62 
67  typedef typename PointCloudT::Ptr PointCloudTPtr;
69 
71  : Keypoint<PointT, PointT> (),
72  neighborhood_constant_ (0.5f),
73  clouds_ (),
74  cloud_normals_ (),
75  cloud_trees_ (),
76  normals_ (),
77  scales_ (),
78  input_scale_ (0.0f),
79  input_index_ ()
80  {
81  name_ = "SmoothedSurfacesKeypoint";
82 
83  // hack to pass the initCompute () check of Keypoint - although it is never used in SmoothedSurfacesKeypoint
85  }
86 
87  void
89  const PointCloudNTConstPtr &normals,
90  KdTreePtr &kdtree,
91  float &scale);
92 
93 
94  void
95  resetClouds ();
96 
97  inline void
98  setNeighborhoodConstant (float neighborhood_constant) { neighborhood_constant_ = neighborhood_constant; }
99 
100  inline float
101  getNeighborhoodConstant () { return neighborhood_constant_; }
102 
103  inline void
104  setInputNormals (const PointCloudNTConstPtr &normals) { normals_ = normals; }
105 
106  inline void
107  setInputScale (float input_scale) { input_scale_ = input_scale; }
108 
109  void
110  detectKeypoints (PointCloudT &output);
111 
112  protected:
113  bool
114  initCompute ();
115 
116  private:
117  float neighborhood_constant_;
118  std::vector<PointCloudTConstPtr> clouds_;
119  std::vector<PointCloudNTConstPtr> cloud_normals_;
120  std::vector<KdTreePtr> cloud_trees_;
121  PointCloudNTConstPtr normals_;
122  std::vector<std::pair<float, size_t> > scales_;
123  float input_scale_;
124  size_t input_index_;
125 
126  static bool
127  compareScalesFunction (const std::pair<float, size_t> &a,
128  const std::pair<float, size_t> &b) { return a.first < b.first; }
129  };
130 }
131 
132 #endif /* PCL_SMOOTHEDSURFACESKEYPOINT_H_ */