Point Cloud Library (PCL)  1.6.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
narf_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 /* \author Bastian Steder */
37 
38 #ifndef PCL_NARF_KEYPOINT_H_
39 #define PCL_NARF_KEYPOINT_H_
40 
41 #include <pcl/pcl_macros.h>
42 #include <pcl/point_cloud.h>
43 #include <pcl/point_types.h>
44 #include <pcl/keypoints/keypoint.h>
45 
46 namespace pcl {
47 
48 // Forward declarations
49 class RangeImage;
50 class RangeImageBorderExtractor;
51 
57 class PCL_EXPORTS NarfKeypoint : public Keypoint<PointWithRange, int>
58 {
59  public:
60  // =====TYPEDEFS=====
62 
64 
65  // =====PUBLIC STRUCTS=====
67  struct Parameters
68  {
69  Parameters() : support_size(-1.0f), max_no_of_interest_points(-1), min_distance_between_interest_points(0.25f),
70  optimal_distance_to_high_surface_change(0.25), min_interest_value(0.45f),
71  min_surface_change_score(0.2f), optimal_range_image_patch_size(10),
72  distance_for_additional_points(0.0f), add_points_on_straight_edges(false),
73  do_non_maximum_suppression(true), no_of_polynomial_approximations_per_point(0),
74  max_no_of_threads(1), use_recursive_scale_reduction(false),
75  calculate_sparse_interest_image(true) {}
76 
77  float support_size;
79  float min_distance_between_interest_points;
82  float optimal_distance_to_high_surface_change;
88  int optimal_range_image_patch_size;
92  // TODO:
93  float distance_for_additional_points;
97  bool add_points_on_straight_edges;
99  bool do_non_maximum_suppression;
102  bool no_of_polynomial_approximations_per_point;
106  bool use_recursive_scale_reduction;
108  bool calculate_sparse_interest_image;
110  };
111 
112  // =====CONSTRUCTOR & DESTRUCTOR=====
113  NarfKeypoint (RangeImageBorderExtractor* range_image_border_extractor=NULL, float support_size=-1.0f);
114  ~NarfKeypoint ();
115 
116  // =====PUBLIC METHODS=====
118  void
119  clearData ();
120 
122  void
123  setRangeImageBorderExtractor (RangeImageBorderExtractor* range_image_border_extractor);
124 
127  getRangeImageBorderExtractor () { return range_image_border_extractor_; }
128 
130  void
131  setRangeImage (const RangeImage* range_image);
132 
134  float*
135  getInterestImage () { calculateInterestImage(); return interest_image_;}
136 
138  const ::pcl::PointCloud<InterestPoint>&
139  getInterestPoints () { calculateInterestPoints(); return *interest_points_;}
140 
142  const std::vector<bool>&
143  getIsInterestPointImage () { calculateInterestPoints(); return is_interest_point_image_;}
144 
146  Parameters&
147  getParameters () { return parameters_;}
148 
150  const RangeImage&
151  getRangeImage ();
152 
154  void
155  compute (PointCloudOut& output);
156 
157  protected:
158  // =====PROTECTED METHODS=====
159  void
160  calculateScaleSpace ();
161  void
162  calculateInterestImage ();
163  void
164  calculateCompleteInterestImage ();
165  void
166  calculateSparseInterestImage ();
167  void
168  calculateInterestPoints ();
169  //void
170  //blurInterestImage ();
172  virtual void
173  detectKeypoints (PointCloudOut& output);
174 
175  // =====PROTECTED MEMBER VARIABLES=====
176  using BaseClass::name_;
177  RangeImageBorderExtractor* range_image_border_extractor_;
178  Parameters parameters_;
179  float* interest_image_;
180  ::pcl::PointCloud<InterestPoint>* interest_points_;
181  std::vector<bool> is_interest_point_image_;
182  std::vector<RangeImage*> range_image_scale_space_;
183  std::vector<RangeImageBorderExtractor*> border_extractor_scale_space_;
184  std::vector<float*> interest_image_scale_space_;
185 };
186 
190 inline std::ostream&
191  operator << (std::ostream& os, const NarfKeypoint::Parameters& p)
192 {
195  return (os);
196 }
197 
198 } // end namespace pcl
199 
200 #endif //#ifndef PCL_NARF_KEYPOINT_H_