Point Cloud Library (PCL)
1.7.0
|
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: gfpfh.h 1423 2011-06-21 09:51:32Z bouffa $ 00038 * 00039 */ 00040 00041 #ifndef PCL_GFPFH_H_ 00042 #define PCL_GFPFH_H_ 00043 00044 #include <pcl/features/feature.h> 00045 00046 namespace pcl 00047 { 00048 /** \brief @b GFPFHEstimation estimates the Global Fast Point Feature Histogram (GFPFH) descriptor for a given point 00049 * cloud dataset containing points and labels. 00050 * 00051 * @note If you use this code in any academic work, please cite: 00052 * 00053 * <ul> 00054 * <li> R.B. Rusu, A. Holzbach, M. Beetz. 00055 * Detecting and Segmenting Objects for Mobile Manipulation. 00056 * In the S3DV Workshop of the 12th International Conference on Computer Vision (ICCV), 00057 * 2009. 00058 * </li> 00059 * </ul> 00060 * 00061 * \author Radu B. Rusu 00062 * \ingroup features 00063 */ 00064 template <typename PointInT, typename PointLT, typename PointOutT> 00065 class GFPFHEstimation : public FeatureFromLabels<PointInT, PointLT, PointOutT> 00066 { 00067 public: 00068 typedef boost::shared_ptr<GFPFHEstimation<PointInT, PointLT, PointOutT> > Ptr; 00069 typedef boost::shared_ptr<const GFPFHEstimation<PointInT, PointLT, PointOutT> > ConstPtr; 00070 using FeatureFromLabels<PointInT, PointLT, PointOutT>::feature_name_; 00071 using FeatureFromLabels<PointInT, PointLT, PointOutT>::getClassName; 00072 using FeatureFromLabels<PointInT, PointLT, PointOutT>::indices_; 00073 using FeatureFromLabels<PointInT, PointLT, PointOutT>::k_; 00074 using FeatureFromLabels<PointInT, PointLT, PointOutT>::search_parameter_; 00075 using FeatureFromLabels<PointInT, PointLT, PointOutT>::surface_; 00076 00077 using FeatureFromLabels<PointInT, PointLT, PointOutT>::input_; 00078 using FeatureFromLabels<PointInT, PointLT, PointOutT>::labels_; 00079 00080 typedef typename Feature<PointInT, PointOutT>::PointCloudOut PointCloudOut; 00081 typedef typename Feature<PointInT, PointOutT>::PointCloudIn PointCloudIn; 00082 00083 /** \brief Empty constructor. */ 00084 GFPFHEstimation () : 00085 octree_leaf_size_ (0.01), 00086 number_of_classes_ (16), 00087 descriptor_size_ (PointOutT::descriptorSize ()) 00088 { 00089 feature_name_ = "GFPFHEstimation"; 00090 } 00091 00092 /** \brief Set the size of the octree leaves. 00093 */ 00094 inline void 00095 setOctreeLeafSize (double size) { octree_leaf_size_ = size; } 00096 00097 /** \brief Get the sphere radius used for determining the neighbors. */ 00098 inline double 00099 getOctreeLeafSize () { return (octree_leaf_size_); } 00100 00101 /** \brief Return the empty label value. */ 00102 inline uint32_t 00103 emptyLabel () const { return 0; } 00104 00105 /** \brief Return the number of different classes. */ 00106 inline uint32_t 00107 getNumberOfClasses () const { return number_of_classes_; } 00108 00109 /** \brief Set the number of different classes. 00110 * \param n number of different classes. 00111 */ 00112 inline void 00113 setNumberOfClasses (uint32_t n) { number_of_classes_ = n; } 00114 00115 /** \brief Return the size of the descriptor. */ 00116 inline int 00117 descriptorSize () const { return descriptor_size_; } 00118 00119 /** \brief Overloaded computed method from pcl::Feature. 00120 * \param[out] output the resultant point cloud model dataset containing the estimated features 00121 */ 00122 void 00123 compute (PointCloudOut &output); 00124 00125 protected: 00126 00127 /** \brief Estimate the Point Feature Histograms (PFH) descriptors at a set of points given by 00128 * <setInputCloud (), setIndices ()> using the surface in setSearchSurface () and the spatial locator in 00129 * setSearchMethod () 00130 * \param output the resultant point cloud model dataset that contains the PFH feature estimates 00131 */ 00132 void 00133 computeFeature (PointCloudOut &output); 00134 00135 /** \brief Return the dominant label of a set of points. */ 00136 uint32_t 00137 getDominantLabel (const std::vector<int>& indices); 00138 00139 /** \brief Compute the fixed-length histograms of transitions. */ 00140 void computeTransitionHistograms (const std::vector< std::vector<int> >& label_histograms, 00141 std::vector< std::vector<int> >& transition_histograms); 00142 00143 /** \brief Compute the distance of each transition histogram to the mean. */ 00144 void 00145 computeDistancesToMean (const std::vector< std::vector<int> >& transition_histograms, 00146 std::vector<float>& distances); 00147 00148 /** \brief Return the Intersection Kernel distance between two histograms. */ 00149 float 00150 computeHIKDistance (const std::vector<int>& histogram, 00151 const std::vector<float>& mean_histogram); 00152 00153 /** \brief Compute the binned histogram of distance values. */ 00154 void 00155 computeDistanceHistogram (const std::vector<float>& distances, 00156 std::vector<float>& histogram); 00157 00158 /** \brief Compute the mean histogram of the given set of histograms. */ 00159 void 00160 computeMeanHistogram (const std::vector< std::vector<int> >& histograms, 00161 std::vector<float>& mean_histogram); 00162 00163 private: 00164 /** \brief Size of octree leaves. */ 00165 double octree_leaf_size_; 00166 00167 /** \brief Number of possible classes/labels. */ 00168 uint32_t number_of_classes_; 00169 00170 /** \brief Dimension of the descriptors. */ 00171 int descriptor_size_; 00172 }; 00173 } 00174 00175 #ifdef PCL_NO_PRECOMPILE 00176 #include <pcl/features/impl/gfpfh.hpp> 00177 #endif 00178 00179 #endif //#ifndef PCL_GFPFH_H_