Point Cloud Library (PCL)  1.6.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
spin_image.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  * $Id: spin_image.h 6144 2012-07-04 22:06:28Z rusu $
37  */
38 
39 #ifndef PCL_SPIN_IMAGE_H_
40 #define PCL_SPIN_IMAGE_H_
41 
42 #include <pcl/point_types.h>
43 #include <pcl/features/feature.h>
44 
45 namespace pcl
46 {
86  template <typename PointInT, typename PointNT, typename PointOutT>
87  class SpinImageEstimation : public Feature<PointInT, PointOutT>
88  {
89  public:
98 
100 
104 
108 
109  typedef typename boost::shared_ptr<SpinImageEstimation<PointInT, PointNT, PointOutT> > Ptr;
110  typedef typename boost::shared_ptr<const SpinImageEstimation<PointInT, PointNT, PointOutT> > ConstPtr;
111 
121  SpinImageEstimation (unsigned int image_width = 8,
122  double support_angle_cos = 0.0, // when 0, this is bogus, so not applied
123  unsigned int min_pts_neighb = 0);
124 
129  void
130  setImageWidth (unsigned int bin_count)
131  {
132  image_width_ = bin_count;
133  }
134 
141  void
142  setSupportAngle (double support_angle_cos)
143  {
144  if (0.0 > support_angle_cos || support_angle_cos > 1.0) // may be permit negative cosine?
145  {
146  throw PCLException ("Cosine of support angle should be between 0 and 1",
147  "spin_image.h", "setSupportAngle");
148  }
149 
150  support_angle_cos_ = support_angle_cos;
151  }
152 
158  void
159  setMinPointCountInNeighbourhood (unsigned int min_pts_neighb)
160  {
161  min_pts_neighb_ = min_pts_neighb;
162  }
163 
174  inline void
176  {
177  input_normals_ = normals;
178  }
179 
185  void
186  setRotationAxis (const PointNT& axis)
187  {
188  rotation_axis_ = axis;
189  use_custom_axis_ = true;
190  use_custom_axes_cloud_ = false;
191  }
192 
199  void
201  {
202  rotation_axes_cloud_ = axes;
203 
204  use_custom_axes_cloud_ = true;
205  use_custom_axis_ = false;
206  }
207 
209  void
211  {
212  use_custom_axis_ = false;
213  use_custom_axes_cloud_ = false;
214  }
215 
227  void
228  setAngularDomain (bool is_angular = true) { is_angular_ = is_angular; }
229 
237  void
238  setRadialStructure (bool is_radial = true) { is_radial_ = is_radial; }
239 
240  protected:
245  virtual void
246  computeFeature (PointCloudOut &output);
247 
252  virtual bool
253  initCompute ();
254 
259  Eigen::ArrayXXd
260  computeSiForPoint (int index) const;
261 
262  private:
263  PointCloudNConstPtr input_normals_;
264  PointCloudNConstPtr rotation_axes_cloud_;
265 
266  bool is_angular_;
267 
268  PointNT rotation_axis_;
269  bool use_custom_axis_;
270  bool use_custom_axes_cloud_;
271 
272  bool is_radial_;
273 
274  unsigned int image_width_;
275  double support_angle_cos_;
276  unsigned int min_pts_neighb_;
277 
281  void
282  computeFeatureEigen (pcl::PointCloud<Eigen::MatrixXf> &) {}
283  };
284 
315  template <typename PointInT, typename PointNT>
316  class SpinImageEstimation<PointInT, PointNT, Eigen::MatrixXf> : public SpinImageEstimation<PointInT, PointNT, pcl::Histogram<153> >
317  {
318  public:
325 
335  SpinImageEstimation (unsigned int image_width = 8,
336  double support_angle_cos = 0.0, // when 0, this is bogus, so not applied
337  unsigned int min_pts_neighb = 0) :
338  SpinImageEstimation<PointInT, PointNT, pcl::Histogram<153> > (image_width, support_angle_cos, min_pts_neighb) {}
339 
340  private:
345  virtual void
346  computeFeatureEigen (pcl::PointCloud<Eigen::MatrixXf> &output);
347 
351  void
353  };
354 }
355 
356 #endif //#ifndef PCL_SPIN_IMAGE_H_
357 
358