Point Cloud Library (PCL)  1.4.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
3dsc.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  *
00007  *  All rights reserved. 
00008  *
00009  *  Redistribution and use in source and binary forms, with or without
00010  *  modification, are permitted provided that the following conditions
00011  *  are met:
00012  *
00013  *   * Redistributions of source code must retain the above copyright
00014  *     notice, this list of conditions and the following disclaimer.
00015  *   * Redistributions in binary form must reproduce the above
00016  *     copyright notice, this list of conditions and the following
00017  *     disclaimer in the documentation and/or other materials provided
00018  *     with the distribution.
00019  *   * Neither the name of Willow Garage, Inc. nor the names of its
00020  *     contributors may be used to endorse or promote products derived
00021  *     from this software without specific prior written permission.
00022  *
00023  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00024  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00025  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00026  *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00027  *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00028  *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00029  *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00030  *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00031  *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00032  *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00033  *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00034  *  POSSIBILITY OF SUCH DAMAGE.
00035  *
00036  *  $Id: 3dsc.h 3755 2011-12-31 23:45:30Z rusu $
00037  *
00038  */
00039 
00040 #ifndef PCL_FEATURES_3DSC_H_
00041 #define PCL_FEATURES_3DSC_H_
00042 
00043 #include <pcl/point_types.h>
00044 #include <pcl/features/feature.h>
00045 #include <boost/random.hpp>
00046 
00047 namespace pcl
00048 {
00074   template <typename PointInT, typename PointNT, typename PointOutT> 
00075   class ShapeContext3DEstimation : public FeatureFromNormals<PointInT, PointNT, PointOutT>
00076   {
00077     public:
00078        using Feature<PointInT, PointOutT>::feature_name_;
00079        using Feature<PointInT, PointOutT>::getClassName;
00080        using Feature<PointInT, PointOutT>::indices_;
00081        using Feature<PointInT, PointOutT>::search_parameter_;
00082        using Feature<PointInT, PointOutT>::search_radius_;
00083        using Feature<PointInT, PointOutT>::surface_;
00084        using Feature<PointInT, PointOutT>::input_;
00085        using Feature<PointInT, PointOutT>::searchForNeighbors;
00086        using FeatureFromNormals<PointInT, PointNT, PointOutT>::normals_;
00087        
00088        typedef typename Feature<PointInT, PointOutT>::PointCloudOut PointCloudOut;
00089        typedef typename Feature<PointInT, PointOutT>::PointCloudIn PointCloudIn;
00090        
00095        ShapeContext3DEstimation (bool random = false) :
00096          radii_interval_(0), theta_divisions_(0), phi_divisions_(0), volume_lut_(0),
00097          azimuth_bins_(12), elevation_bins_(11), radius_bins_(15), 
00098          min_radius_(0.1), point_density_radius_(0.2)
00099        {
00100          feature_name_ = "ShapeContext3DEstimation";
00101          search_radius_ = 2.5;
00102 
00103          // Create a random number generator object
00104          rng_.reset (new boost::uniform_01<boost::mt19937> (rng_alg_));
00105          if (random)
00106            rng_->base ().seed (static_cast<unsigned> (std::time(0)));
00107          else
00108            rng_->base ().seed (12345u);
00109        }
00110 
00111       virtual ~ShapeContext3DEstimation() {}
00112 
00116       inline void 
00117       setAzimuthBins (size_t bins) { azimuth_bins_ = bins; }
00118 
00120       inline size_t 
00121       getAzimuthBins () { return (azimuth_bins_); }
00122 
00126       inline void 
00127       setElevationBins (size_t bins) { elevation_bins_ = bins; }
00128 
00130       inline size_t 
00131       getElevationBins () { return (elevation_bins_); }
00132 
00136       inline void 
00137       setRadiusBins (size_t bins) { radius_bins_ = bins; }
00138 
00140       inline size_t 
00141       getRadiusBins () { return (radius_bins_); } 
00142 
00146       inline void 
00147       setMinimalRadius (float radius) { min_radius_ = radius; }
00148 
00150       inline float 
00151       getMinimalRadius () { return (min_radius_); }
00152 
00157       inline void 
00158       setPointDensityRadius (double radius) { point_density_radius_ = radius; }
00159 
00161       inline double 
00162       getPointDensityRadius () { return (point_density_radius_); }
00163       
00164     protected:
00166       bool 
00167       initCompute ();
00168 
00177       bool
00178       computePoint (size_t index, const pcl::PointCloud<PointNT> &normals, float rf[9], std::vector<float> &desc);
00179 
00183       void
00184       computeFeature (PointCloudOut &output);
00185       
00187       std::vector<float> radii_interval_;
00188 
00190       std::vector<float> theta_divisions_;
00191 
00193       std::vector<float> phi_divisions_;
00194 
00196       std::vector<float> volume_lut_;
00197 
00199       size_t azimuth_bins_;
00200 
00202       size_t elevation_bins_;
00203 
00205       size_t radius_bins_;
00206 
00208       double min_radius_;
00209 
00211       double point_density_radius_;
00212 
00214       size_t descriptor_length_;
00215 
00217       boost::mt19937 rng_alg_;
00218 
00220       boost::shared_ptr<boost::uniform_01<boost::mt19937> > rng_;
00221 
00227       void 
00228       shiftAlongAzimuth (size_t block_size, std::vector<float>& desc);
00229 
00231       inline double
00232       rnd ()
00233       {
00234         return ((*rng_) ());
00235       }
00236     private:
00240       void 
00241       computeFeature (pcl::PointCloud<Eigen::MatrixXf> &output) {}
00242   };
00243 
00269   template <typename PointInT, typename PointNT> 
00270   class ShapeContext3DEstimation<PointInT, PointNT, Eigen::MatrixXf> : public ShapeContext3DEstimation<PointInT, PointNT, pcl::SHOT>
00271   {
00272     public:
00273        using ShapeContext3DEstimation<PointInT, PointNT, pcl::SHOT>::feature_name_;
00274        using ShapeContext3DEstimation<PointInT, PointNT, pcl::SHOT>::indices_;
00275        using ShapeContext3DEstimation<PointInT, PointNT, pcl::SHOT>::descriptor_length_;
00276        using ShapeContext3DEstimation<PointInT, PointNT, pcl::SHOT>::normals_;
00277        using ShapeContext3DEstimation<PointInT, PointNT, pcl::SHOT>::input_;
00278        using ShapeContext3DEstimation<PointInT, PointNT, pcl::SHOT>::compute;
00279 
00280     private:
00284       void
00285       computeFeature (pcl::PointCloud<Eigen::MatrixXf> &output);
00286 
00290       void 
00291       compute (pcl::PointCloud<pcl::SHOT> &output) {}
00292   };
00293 }
00294 
00295 #endif  //#ifndef PCL_3DSC_H_
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines