Point Cloud Library (PCL)  1.7.0
fpfh_omp.h
1 /*
2  * Software License Agreement (BSD License)
3  *
4  * Point Cloud Library (PCL) - www.pointclouds.org
5  * Copyright (c) 2009, Willow Garage, Inc.
6  * Copyright (c) 2012-, Open Perception, Inc.
7  *
8  * All rights reserved.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  *
14  * * Redistributions of source code must retain the above copyright
15  * notice, this list of conditions and the following disclaimer.
16  * * Redistributions in binary form must reproduce the above
17  * copyright notice, this list of conditions and the following
18  * disclaimer in the documentation and/or other materials provided
19  * with the distribution.
20  * * Neither the name of the copyright holder(s) nor the names of its
21  * contributors may be used to endorse or promote products derived
22  * from this software without specific prior written permission.
23  *
24  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
27  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
28  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
29  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
30  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
31  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
32  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
34  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35  * POSSIBILITY OF SUCH DAMAGE.
36  *
37  * $Id$
38  *
39  */
40 
41 #ifndef PCL_FPFH_OMP_H_
42 #define PCL_FPFH_OMP_H_
43 
44 #include <pcl/features/feature.h>
45 #include <pcl/features/fpfh.h>
46 
47 namespace pcl
48 {
49  /** \brief FPFHEstimationOMP estimates the Fast Point Feature Histogram (FPFH) descriptor for a given point cloud
50  * dataset containing points and normals, in parallel, using the OpenMP standard.
51  *
52  * \note If you use this code in any academic work, please cite:
53  *
54  * - R.B. Rusu, N. Blodow, M. Beetz.
55  * Fast Point Feature Histograms (FPFH) for 3D Registration.
56  * In Proceedings of the IEEE International Conference on Robotics and Automation (ICRA),
57  * Kobe, Japan, May 12-17 2009.
58  * - R.B. Rusu, A. Holzbach, N. Blodow, M. Beetz.
59  * Fast Geometric Point Labeling using Conditional Random Fields.
60  * In Proceedings of the 22nd IEEE/RSJ International Conference on Intelligent Robots and Systems (IROS),
61  * St. Louis, MO, USA, October 11-15 2009.
62  *
63  * \attention
64  * The convention for FPFH features is:
65  * - if a query point's nearest neighbors cannot be estimated, the FPFH feature will be set to NaN
66  * (not a number)
67  * - it is impossible to estimate a FPFH descriptor for a point that
68  * doesn't have finite 3D coordinates. Therefore, any point that contains
69  * NaN data on x, y, or z, will have its FPFH feature property set to NaN.
70  *
71  * \author Radu B. Rusu
72  * \ingroup features
73  */
74  template <typename PointInT, typename PointNT, typename PointOutT>
75  class FPFHEstimationOMP : public FPFHEstimation<PointInT, PointNT, PointOutT>
76  {
77  public:
78  typedef boost::shared_ptr<FPFHEstimationOMP<PointInT, PointNT, PointOutT> > Ptr;
79  typedef boost::shared_ptr<const FPFHEstimationOMP<PointInT, PointNT, PointOutT> > ConstPtr;
92 
94 
95  /** \brief Initialize the scheduler and set the number of threads to use.
96  * \param[in] nr_threads the number of hardware threads to use (0 sets the value back to automatic)
97  */
98  FPFHEstimationOMP (unsigned int nr_threads = 0) : nr_bins_f1_ (11), nr_bins_f2_ (11), nr_bins_f3_ (11), threads_ (nr_threads)
99  {
100  feature_name_ = "FPFHEstimationOMP";
101  }
102 
103  /** \brief Initialize the scheduler and set the number of threads to use.
104  * \param[in] nr_threads the number of hardware threads to use (0 sets the value back to automatic)
105  */
106  inline void
107  setNumberOfThreads (unsigned int nr_threads = 0) { threads_ = nr_threads; }
108 
109  private:
110  /** \brief Estimate the Fast Point Feature Histograms (FPFH) descriptors at a set of points given by
111  * <setInputCloud (), setIndices ()> using the surface in setSearchSurface () and the spatial locator in
112  * setSearchMethod ()
113  * \param[out] output the resultant point cloud model dataset that contains the FPFH feature estimates
114  */
115  void
116  computeFeature (PointCloudOut &output);
117 
118  public:
119  /** \brief The number of subdivisions for each angular feature interval. */
121  private:
122  /** \brief The number of threads the scheduler should use. */
123  unsigned int threads_;
124  };
125 }
126 
127 #ifdef PCL_NO_PRECOMPILE
128 #include <pcl/features/impl/fpfh_omp.hpp>
129 #endif
130 
131 #endif //#ifndef PCL_FPFH_OMP_H_