pfh.h
Go to the documentation of this file.
00001 /*
00002  * Software License Agreement (BSD License)
00003  *
00004  *  Point Cloud Library (PCL) - www.pointclouds.org
00005  *  Copyright (c) 2010-2011, 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_PFH_H_
00042 #define PCL_PFH_H_
00043 
00044 #include <pcl/point_types.h>
00045 #include <pcl/features/feature.h>
00046 #include <pcl/features/pfh_tools.h>
00047 #include <map>
00048 
00049 namespace pcl
00050 {
00081   template <typename PointInT, typename PointNT, typename PointOutT = pcl::PFHSignature125>
00082   class PFHEstimation : public FeatureFromNormals<PointInT, PointNT, PointOutT>
00083   {
00084     public:
00085       typedef boost::shared_ptr<PFHEstimation<PointInT, PointNT, PointOutT> > Ptr;
00086       typedef boost::shared_ptr<const PFHEstimation<PointInT, PointNT, PointOutT> > ConstPtr;
00087       using Feature<PointInT, PointOutT>::feature_name_;
00088       using Feature<PointInT, PointOutT>::getClassName;
00089       using Feature<PointInT, PointOutT>::indices_;
00090       using Feature<PointInT, PointOutT>::k_;
00091       using Feature<PointInT, PointOutT>::search_parameter_;
00092       using Feature<PointInT, PointOutT>::surface_;
00093       using Feature<PointInT, PointOutT>::input_;
00094       using FeatureFromNormals<PointInT, PointNT, PointOutT>::normals_;
00095 
00096       typedef typename Feature<PointInT, PointOutT>::PointCloudOut PointCloudOut;
00097       typedef typename Feature<PointInT, PointOutT>::PointCloudIn  PointCloudIn;
00098 
00102       PFHEstimation () : 
00103         nr_subdiv_ (5), 
00104         pfh_histogram_ (),
00105         pfh_tuple_ (),
00106         d_pi_ (1.0f / (2.0f * static_cast<float> (M_PI))), 
00107         feature_map_ (),
00108         key_list_ (),
00109         // Default 1GB memory size. Need to set it to something more conservative.
00110         max_cache_size_ ((1ul*1024ul*1024ul*1024ul) / sizeof (std::pair<std::pair<int, int>, Eigen::Vector4f>)),
00111         use_cache_ (false)
00112       {
00113         feature_name_ = "PFHEstimation";
00114       };
00115 
00119       inline void
00120       setMaximumCacheSize (unsigned int cache_size)
00121       {
00122         max_cache_size_ = cache_size;
00123       }
00124 
00126       inline unsigned int 
00127       getMaximumCacheSize ()
00128       {
00129         return (max_cache_size_);
00130       }
00131 
00143       inline void
00144       setUseInternalCache (bool use_cache)
00145       {
00146         use_cache_ = use_cache;
00147       }
00148 
00150       inline bool
00151       getUseInternalCache ()
00152       {
00153         return (use_cache_);
00154       }
00155 
00170       bool 
00171       computePairFeatures (const pcl::PointCloud<PointInT> &cloud, const pcl::PointCloud<PointNT> &normals, 
00172                            int p_idx, int q_idx, float &f1, float &f2, float &f3, float &f4);
00173 
00182       void 
00183       computePointPFHSignature (const pcl::PointCloud<PointInT> &cloud, const pcl::PointCloud<PointNT> &normals, 
00184                                 const std::vector<int> &indices, int nr_split, Eigen::VectorXf &pfh_histogram);
00185 
00186     protected:
00192       void 
00193       computeFeature (PointCloudOut &output);
00194 
00196       int nr_subdiv_;
00197 
00199       Eigen::VectorXf pfh_histogram_;
00200 
00202       Eigen::Vector4f pfh_tuple_;
00203 
00205       int f_index_[3];
00206 
00208       float d_pi_; 
00209 
00211       std::map<std::pair<int, int>, Eigen::Vector4f, std::less<std::pair<int, int> >, Eigen::aligned_allocator<Eigen::Vector4f> > feature_map_;
00212 
00214       std::queue<std::pair<int, int> > key_list_;
00215 
00217       unsigned int max_cache_size_;
00218 
00220       bool use_cache_;
00221   };
00222 }
00223 
00224 #ifdef PCL_NO_PRECOMPILE
00225 #include <pcl/features/impl/pfh.hpp>
00226 #endif
00227 
00228 #endif  //#ifndef PCL_PFH_H_
00229 


pcl
Author(s): Open Perception
autogenerated on Wed Aug 26 2015 15:28:14