Point Cloud Library (PCL)  1.6.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
keypoint.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_KEYPOINT_H_
39 #define PCL_KEYPOINT_H_
40 
41 // PCL includes
42 #include <pcl/pcl_base.h>
43 #include <boost/function.hpp>
44 #include <boost/bind.hpp>
45 #include <pcl/search/pcl_search.h>
46 #include <pcl/pcl_config.h>
47 
48 namespace pcl
49 {
54  template <typename PointInT, typename PointOutT>
55  class Keypoint : public PCLBase<PointInT>
56  {
57  public:
60 
68  typedef boost::function<int (int, double, std::vector<int> &, std::vector<float> &)> SearchMethod;
69  typedef boost::function<int (const PointCloudIn &cloud, int index, double, std::vector<int> &, std::vector<float> &)> SearchMethodSurface;
70 
71  public:
73  Keypoint () :
74  BaseClass (),
75  name_ (),
76  search_method_ (),
77  search_method_surface_ (),
78  surface_ (),
79  tree_ (),
80  search_parameter_ (0),
81  search_radius_ (0),
82  k_ (0)
83  {};
84 
88  virtual void
89  setSearchSurface (const PointCloudInConstPtr &cloud) { surface_ = cloud; }
90 
93  getSearchSurface () { return (surface_); }
94 
98  inline void
99  setSearchMethod (const KdTreePtr &tree) { tree_ = tree; }
100 
102  inline KdTreePtr
103  getSearchMethod () { return (tree_); }
104 
106  inline double
107  getSearchParameter () { return (search_parameter_); }
108 
112  inline void
113  setKSearch (int k) { k_ = k; }
114 
116  inline int
117  getKSearch () { return (k_); }
118 
123  inline void
124  setRadiusSearch (double radius) { search_radius_ = radius; }
125 
127  inline double
128  getRadiusSearch () { return (search_radius_); }
129 
134  inline void
135  compute (PointCloudOut &output);
136 
145  inline int
146  searchForNeighbors (int index, double parameter, std::vector<int> &indices, std::vector<float> &distances) const
147  {
148  if (surface_ == input_) // if the two surfaces are the same
149  return (search_method_ (index, parameter, indices, distances));
150  else
151  return (search_method_surface_ (*input_, index, parameter, indices, distances));
152  }
153 
154  protected:
156 
157  virtual bool
158  initCompute ();
159 
161  std::string name_;
162 
164  SearchMethod search_method_;
165 
167  SearchMethodSurface search_method_surface_;
168 
170  PointCloudInConstPtr surface_;
171 
173  KdTreePtr tree_;
174 
176  double search_parameter_;
177 
179  double search_radius_;
180 
182  int k_;
183 
185  inline const std::string&
186  getClassName () const { return (name_); }
187 
189  virtual void
190  detectKeypoints (PointCloudOut &output) = 0;
191  };
192 }
193 
195 
196 #endif //#ifndef PCL_KEYPOINT_H_