Point Cloud Library (PCL)  1.6.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
sift_keypoint.h
Go to the documentation of this file.
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  */
35 
36 #ifndef PCL_SIFT_KEYPOINT_H_
37 #define PCL_SIFT_KEYPOINT_H_
38 
39 #include <pcl/keypoints/keypoint.h>
40 
41 namespace pcl
42 {
43  template<typename PointT>
45  {
46  inline float
47  operator () (const PointT & p) const
48  {
49  return p.intensity;
50  }
51  };
52  template<>
54  {
55  inline float
56  operator () (const PointNormal & p) const
57  {
58  return p.curvature;
59  }
60  };
61  template<>
63  {
64  inline float
65  operator () (const PointXYZRGB & p) const
66  {
67  return (static_cast<float> (299*p.r + 587*p.g + 114*p.b) / 1000.0f);
68  }
69  };
70  template<>
72  {
73  inline float
74  operator () (const PointXYZRGBA & p) const
75  {
76  return (static_cast<float> (299*p.r + 587*p.g + 114*p.b) / 1000.0f);
77  }
78  };
79 
93  template <typename PointInT, typename PointOutT>
94  class SIFTKeypoint : public Keypoint<PointInT, PointOutT>
95  {
96  public:
100 
107 
109  SIFTKeypoint () : min_scale_ (0.0), nr_octaves_ (0), nr_scales_per_octave_ (0),
110  min_contrast_ (-std::numeric_limits<float>::max ()), scale_idx_ (-1),
111  out_fields_ (), getFieldValue_ ()
112  {
113  name_ = "SIFTKeypoint";
114  }
115 
121  void
122  setScales (float min_scale, int nr_octaves, int nr_scales_per_octave);
123 
127  void
128  setMinimumContrast (float min_contrast);
129 
130  protected:
131  bool
132  initCompute ();
133 
138  void
139  detectKeypoints (PointCloudOut &output);
140 
141  private:
149  void
150  detectKeypointsForOctave (const PointCloudIn &input, KdTree &tree,
151  float base_scale, int nr_scales_per_octave,
152  PointCloudOut &output);
153 
160  void
161  computeScaleSpace (const PointCloudIn &input, KdTree &tree,
162  const std::vector<float> &scales,
163  Eigen::MatrixXf &diff_of_gauss);
164 
172  void
173  findScaleSpaceExtrema (const PointCloudIn &input, KdTree &tree,
174  const Eigen::MatrixXf &diff_of_gauss,
175  std::vector<int> &extrema_indices, std::vector<int> &extrema_scales);
176 
177 
179  float min_scale_;
180 
182  int nr_octaves_;
183 
185  int nr_scales_per_octave_;
186 
188  float min_contrast_;
189 
192  int scale_idx_;
193 
195  std::vector<sensor_msgs::PointField> out_fields_;
196 
198  };
199 }
200 
202 
203 #endif // #ifndef PCL_SIFT_KEYPOINT_H_