Point Cloud Library (PCL)  1.6.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
fpfh.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: fpfh.h 4927 2012-03-07 03:35:53Z rusu $
37  *
38  */
39 
40 #ifndef PCL_FPFH_H_
41 #define PCL_FPFH_H_
42 
43 #include <pcl/features/feature.h>
44 #include <set>
45 
46 namespace pcl
47 {
78  template <typename PointInT, typename PointNT, typename PointOutT = pcl::FPFHSignature33>
79  class FPFHEstimation : public FeatureFromNormals<PointInT, PointNT, PointOutT>
80  {
81  public:
90 
92 
95  nr_bins_f1_ (11), nr_bins_f2_ (11), nr_bins_f3_ (11),
96  hist_f1_ (), hist_f2_ (), hist_f3_ (), fpfh_histogram_ (),
97  d_pi_ (1.0f / (2.0f * static_cast<float> (M_PI)))
98  {
99  feature_name_ = "FPFHEstimation";
100  };
101 
115  bool
117  int p_idx, int q_idx, float &f1, float &f2, float &f3, float &f4);
118 
130  void
132  const pcl::PointCloud<PointNT> &normals, int p_idx, int row,
133  const std::vector<int> &indices,
134  Eigen::MatrixXf &hist_f1, Eigen::MatrixXf &hist_f2, Eigen::MatrixXf &hist_f3);
135 
145  void
146  weightPointSPFHSignature (const Eigen::MatrixXf &hist_f1,
147  const Eigen::MatrixXf &hist_f2,
148  const Eigen::MatrixXf &hist_f3,
149  const std::vector<int> &indices,
150  const std::vector<float> &dists,
151  Eigen::VectorXf &fpfh_histogram);
152 
158  inline void
159  setNrSubdivisions (int nr_bins_f1, int nr_bins_f2, int nr_bins_f3)
160  {
161  nr_bins_f1_ = nr_bins_f1;
162  nr_bins_f2_ = nr_bins_f2;
163  nr_bins_f3_ = nr_bins_f3;
164  }
165 
171  inline void
172  getNrSubdivisions (int &nr_bins_f1, int &nr_bins_f2, int &nr_bins_f3)
173  {
174  nr_bins_f1 = nr_bins_f1_;
175  nr_bins_f2 = nr_bins_f2_;
176  nr_bins_f3 = nr_bins_f3_;
177  }
178 
179  protected:
180 
187  void
188  computeSPFHSignatures (std::vector<int> &spf_hist_lookup,
189  Eigen::MatrixXf &hist_f1, Eigen::MatrixXf &hist_f2, Eigen::MatrixXf &hist_f3);
190 
196  void
197  computeFeature (PointCloudOut &output);
198 
200  int nr_bins_f1_, nr_bins_f2_, nr_bins_f3_;
201 
203  Eigen::MatrixXf hist_f1_;
204 
206  Eigen::MatrixXf hist_f2_;
207 
209  Eigen::MatrixXf hist_f3_;
210 
212  Eigen::VectorXf fpfh_histogram_;
213 
215  float d_pi_;
216 
217  private:
221  void
222  computeFeatureEigen (pcl::PointCloud<Eigen::MatrixXf> &) {}
223  };
224 
253  template <typename PointInT, typename PointNT>
254  class FPFHEstimation<PointInT, PointNT, Eigen::MatrixXf> : public FPFHEstimation<PointInT, PointNT, pcl::FPFHSignature33>
255  {
256  public:
269 
270  private:
276  void
277  computeFeatureEigen (pcl::PointCloud<Eigen::MatrixXf> &output);
278 
282  void
284  };
285 }
286 
287 #endif //#ifndef PCL_FPFH_H_