Point Cloud Library (PCL)  1.7.0
/tmp/buildd/pcl-1.7-1.7.0/features/include/pcl/features/fpfh_omp.h
00001 /*
00002  * Software License Agreement (BSD License)
00003  *
00004  *  Point Cloud Library (PCL) - www.pointclouds.org
00005  *  Copyright (c) 2009, Willow Garage, Inc.
00006  *  Copyright (c) 2012-, Open Perception, Inc.
00007  *
00008  *  All rights reserved.
00009  *
00010  *  Redistribution and use in source and binary forms, with or without
00011  *  modification, are permitted provided that the following conditions
00012  *  are met:
00013  *
00014  *   * Redistributions of source code must retain the above copyright
00015  *     notice, this list of conditions and the following disclaimer.
00016  *   * Redistributions in binary form must reproduce the above
00017  *     copyright notice, this list of conditions and the following
00018  *     disclaimer in the documentation and/or other materials provided
00019  *     with the distribution.
00020  *   * Neither the name of the copyright holder(s) nor the names of its
00021  *     contributors may be used to endorse or promote products derived
00022  *     from this software without specific prior written permission.
00023  *
00024  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00025  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00026  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00027  *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00028  *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00029  *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00030  *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00031  *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00032  *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00033  *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00034  *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00035  *  POSSIBILITY OF SUCH DAMAGE.
00036  *
00037  * $Id$
00038  *
00039  */
00040 
00041 #ifndef PCL_FPFH_OMP_H_
00042 #define PCL_FPFH_OMP_H_
00043 
00044 #include <pcl/features/feature.h>
00045 #include <pcl/features/fpfh.h>
00046 
00047 namespace pcl
00048 {
00049   /** \brief FPFHEstimationOMP estimates the Fast Point Feature Histogram (FPFH) descriptor for a given point cloud
00050     * dataset containing points and normals, in parallel, using the OpenMP standard.
00051     *
00052     * \note If you use this code in any academic work, please cite:
00053     *
00054     *   - R.B. Rusu, N. Blodow, M. Beetz.
00055     *     Fast Point Feature Histograms (FPFH) for 3D Registration.
00056     *     In Proceedings of the IEEE International Conference on Robotics and Automation (ICRA),
00057     *     Kobe, Japan, May 12-17 2009.
00058     *   - R.B. Rusu, A. Holzbach, N. Blodow, M. Beetz.
00059     *     Fast Geometric Point Labeling using Conditional Random Fields.
00060     *     In Proceedings of the 22nd IEEE/RSJ International Conference on Intelligent Robots and Systems (IROS),
00061     *     St. Louis, MO, USA, October 11-15 2009.
00062     *
00063     * \attention 
00064     * The convention for FPFH features is:
00065     *   - if a query point's nearest neighbors cannot be estimated, the FPFH feature will be set to NaN 
00066     *     (not a number)
00067     *   - it is impossible to estimate a FPFH descriptor for a point that
00068     *     doesn't have finite 3D coordinates. Therefore, any point that contains
00069     *     NaN data on x, y, or z, will have its FPFH feature property set to NaN.
00070     *
00071     * \author Radu B. Rusu
00072     * \ingroup features
00073     */
00074   template <typename PointInT, typename PointNT, typename PointOutT>
00075   class FPFHEstimationOMP : public FPFHEstimation<PointInT, PointNT, PointOutT>
00076   {
00077     public:
00078       typedef boost::shared_ptr<FPFHEstimationOMP<PointInT, PointNT, PointOutT> > Ptr;
00079       typedef boost::shared_ptr<const FPFHEstimationOMP<PointInT, PointNT, PointOutT> > ConstPtr;
00080       using Feature<PointInT, PointOutT>::feature_name_;
00081       using Feature<PointInT, PointOutT>::getClassName;
00082       using Feature<PointInT, PointOutT>::indices_;
00083       using Feature<PointInT, PointOutT>::k_;
00084       using Feature<PointInT, PointOutT>::search_parameter_;
00085       using Feature<PointInT, PointOutT>::input_;
00086       using Feature<PointInT, PointOutT>::surface_;
00087       using FeatureFromNormals<PointInT, PointNT, PointOutT>::normals_;
00088       using FPFHEstimation<PointInT, PointNT, PointOutT>::hist_f1_;
00089       using FPFHEstimation<PointInT, PointNT, PointOutT>::hist_f2_;
00090       using FPFHEstimation<PointInT, PointNT, PointOutT>::hist_f3_;
00091       using FPFHEstimation<PointInT, PointNT, PointOutT>::weightPointSPFHSignature;
00092 
00093       typedef typename Feature<PointInT, PointOutT>::PointCloudOut PointCloudOut;
00094 
00095       /** \brief Initialize the scheduler and set the number of threads to use.
00096         * \param[in] nr_threads the number of hardware threads to use (0 sets the value back to automatic)
00097         */
00098       FPFHEstimationOMP (unsigned int nr_threads = 0) : nr_bins_f1_ (11), nr_bins_f2_ (11), nr_bins_f3_ (11), threads_ (nr_threads)
00099       {
00100         feature_name_ = "FPFHEstimationOMP";
00101       }
00102 
00103       /** \brief Initialize the scheduler and set the number of threads to use.
00104         * \param[in] nr_threads the number of hardware threads to use (0 sets the value back to automatic)
00105         */
00106       inline void 
00107       setNumberOfThreads (unsigned int nr_threads = 0) { threads_ = nr_threads; }
00108 
00109     private:
00110       /** \brief Estimate the Fast Point Feature Histograms (FPFH) descriptors at a set of points given by
00111         * <setInputCloud (), setIndices ()> using the surface in setSearchSurface () and the spatial locator in
00112         * setSearchMethod ()
00113         * \param[out] output the resultant point cloud model dataset that contains the FPFH feature estimates
00114         */
00115       void 
00116       computeFeature (PointCloudOut &output);
00117 
00118     public:
00119       /** \brief The number of subdivisions for each angular feature interval. */
00120       int nr_bins_f1_, nr_bins_f2_, nr_bins_f3_;
00121     private:
00122       /** \brief The number of threads the scheduler should use. */
00123       unsigned int threads_;
00124   };
00125 }
00126 
00127 #ifdef PCL_NO_PRECOMPILE
00128 #include <pcl/features/impl/fpfh_omp.hpp>
00129 #endif
00130 
00131 #endif  //#ifndef PCL_FPFH_OMP_H_