Point Cloud Library (PCL)  1.3.1
3dsc.h
Go to the documentation of this file.
00001 /*
00002  * Software License Agreement (BSD License)
00003  *
00004  *  Copyright (c) 2011, www.pointclouds.org
00005  *  All rights reserved.
00006  *
00007  *  Redistribution and use in source and binary forms, with or without
00008  *  modification, are permitted provided that the following conditions
00009  *  are met:
00010  *
00011  *   * Redistributions of source code must retain the above copyright
00012  *     notice, this list of conditions and the following disclaimer.
00013  *   * Redistributions in binary form must reproduce the above
00014  *     copyright notice, this list of conditions and the following
00015  *     disclaimer in the documentation and/or other materials provided
00016  *     with the distribution.
00017  *   * Neither the name of Willow Garage, Inc. nor the names of its
00018  *     contributors may be used to endorse or promote products derived
00019  *     from this software without specific prior written permission.
00020  *
00021  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00022  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00023  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00024  *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00025  *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00026  *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00027  *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00028  *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00029  *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00030  *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00031  *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00032  *  POSSIBILITY OF SUCH DAMAGE.
00033  *
00034  *  $Id: 3dsc.h 3023 2011-11-01 03:42:32Z svn $
00035  *
00036  */
00037 
00038 #ifndef PCL_FEATURES_3DSC_H_
00039 #define PCL_FEATURES_3DSC_H_
00040 
00041 #include <pcl/point_types.h>
00042 #include <pcl/features/feature.h>
00043 
00044 namespace pcl
00045 {
00046   /* namespace features */
00047   /* { */
00069     template <typename PointInT, typename PointNT, typename PointOutT> 
00070     class ShapeContext3DEstimation : public FeatureFromNormals<PointInT, PointNT, PointOutT>
00071     {
00072       public:
00073          using Feature<PointInT, PointOutT>::feature_name_;
00074          using Feature<PointInT, PointOutT>::getClassName;
00075          using Feature<PointInT, PointOutT>::indices_;
00076          using Feature<PointInT, PointOutT>::search_parameter_;
00077          using Feature<PointInT, PointOutT>::search_radius_;
00078          using Feature<PointInT, PointOutT>::surface_;
00079          using Feature<PointInT, PointOutT>::input_;
00080          using Feature<PointInT, PointOutT>::searchForNeighbors;
00081          using FeatureFromNormals<PointInT, PointNT, PointOutT>::normals_;
00082          
00083          typedef typename Feature<PointInT, PointOutT>::PointCloudOut PointCloudOut;
00084          typedef typename Feature<PointInT, PointOutT>::PointCloudIn PointCloudIn;
00085          
00092          ShapeContext3DEstimation(bool shift = false, bool random = false) :
00093            radii_interval_(0), theta_divisions_(0), phi_divisions_(0), volume_lut_(0),
00094            azimuth_bins_(12), elevation_bins_(11), radius_bins_(15), 
00095            min_radius_(0.1), point_density_radius_(0.2), shift_(shift)
00096          {
00097            feature_name_ = "ShapeContext3DEstimation";
00098            search_radius_ = 2.5;
00099            if(random)
00100              srand(time(NULL));
00101            else
00102              srand(12345); 
00103          }
00104 
00105         virtual ~ShapeContext3DEstimation() {}
00106 
00108         inline void setAzimuthBins(size_t bins) { azimuth_bins_ = bins; }
00110         inline size_t getAzimuthBins(size_t bins) { return (azimuth_bins_); } 
00112         inline void setElevationBins(size_t bins) { elevation_bins_ = bins; }
00114         inline size_t getElevationBins(size_t bins) { return (elevation_bins_); } 
00116         inline void setRadiusBins(size_t bins) { radius_bins_ = bins; }
00118         inline size_t getRadiusBins(size_t bins) { return (radius_bins_); } 
00122         inline void setMinimalRadius(float radius) { min_radius_ = radius; }
00124         inline float getMinimalRadius() { return (min_radius_); }
00129         inline void setPointDensityRadius(double radius) { point_density_radius_ = radius; }
00131         inline double getPointDensityRadius() { return (point_density_radius_); }
00132         
00133       protected:
00137         bool initCompute() ;
00138 
00139         void
00140         computePoint(size_t index, const pcl::PointCloud<PointInT> &input, const pcl::PointCloud<PointNT> &normals, float rf[9], std::vector<float> &desc);
00141 
00142         void
00143         computeFeature(PointCloudOut &output);
00144         
00145       private:
00147         std::vector<float> radii_interval_;
00149         std::vector<float> theta_divisions_;
00151         std::vector<float> phi_divisions_;
00153         std::vector<float> volume_lut_;
00155         size_t azimuth_bins_;
00157         size_t elevation_bins_;
00159         size_t radius_bins_;
00161         double min_radius_;
00163         double point_density_radius_;
00165         size_t descriptor_length_;
00167         bool shift_;
00168 
00169       private:
00175         void shiftAlongAzimuth(size_t block_size, std::vector<float>& desc);
00176     };
00177   /* }; */
00178 }
00179 
00180 #endif  //#ifndef PCL_3DSC_H_
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines