|
Point Cloud Library (PCL)
1.5.1
|
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 4702 2012-02-23 09:39:33Z gedikli $ 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 { 00076 template <typename PointInT, typename PointNT, typename PointOutT = pcl::ShapeContext> 00077 class ShapeContext3DEstimation : public FeatureFromNormals<PointInT, PointNT, PointOutT> 00078 { 00079 public: 00080 using Feature<PointInT, PointOutT>::feature_name_; 00081 using Feature<PointInT, PointOutT>::getClassName; 00082 using Feature<PointInT, PointOutT>::indices_; 00083 using Feature<PointInT, PointOutT>::search_parameter_; 00084 using Feature<PointInT, PointOutT>::search_radius_; 00085 using Feature<PointInT, PointOutT>::surface_; 00086 using Feature<PointInT, PointOutT>::input_; 00087 using Feature<PointInT, PointOutT>::searchForNeighbors; 00088 using FeatureFromNormals<PointInT, PointNT, PointOutT>::normals_; 00089 00090 typedef typename Feature<PointInT, PointOutT>::PointCloudOut PointCloudOut; 00091 typedef typename Feature<PointInT, PointOutT>::PointCloudIn PointCloudIn; 00092 00097 ShapeContext3DEstimation (bool random = false) : 00098 radii_interval_(0), theta_divisions_(0), phi_divisions_(0), volume_lut_(0), 00099 azimuth_bins_(12), elevation_bins_(11), radius_bins_(15), 00100 min_radius_(0.1), point_density_radius_(0.2) 00101 { 00102 feature_name_ = "ShapeContext3DEstimation"; 00103 search_radius_ = 2.5; 00104 00105 // Create a random number generator object 00106 rng_.reset (new boost::uniform_01<boost::mt19937> (rng_alg_)); 00107 if (random) 00108 rng_->base ().seed (static_cast<unsigned> (std::time(0))); 00109 else 00110 rng_->base ().seed (12345u); 00111 } 00112 00113 virtual ~ShapeContext3DEstimation() {} 00114 00118 inline void 00119 setAzimuthBins (size_t bins) { azimuth_bins_ = bins; } 00120 00122 inline size_t 00123 getAzimuthBins () { return (azimuth_bins_); } 00124 00128 inline void 00129 setElevationBins (size_t bins) { elevation_bins_ = bins; } 00130 00132 inline size_t 00133 getElevationBins () { return (elevation_bins_); } 00134 00138 inline void 00139 setRadiusBins (size_t bins) { radius_bins_ = bins; } 00140 00142 inline size_t 00143 getRadiusBins () { return (radius_bins_); } 00144 00148 inline void 00149 setMinimalRadius (float radius) { min_radius_ = radius; } 00150 00152 inline float 00153 getMinimalRadius () { return (min_radius_); } 00154 00159 inline void 00160 setPointDensityRadius (double radius) { point_density_radius_ = radius; } 00161 00163 inline double 00164 getPointDensityRadius () { return (point_density_radius_); } 00165 00166 protected: 00168 bool 00169 initCompute (); 00170 00179 bool 00180 computePoint (size_t index, const pcl::PointCloud<PointNT> &normals, float rf[9], std::vector<float> &desc); 00181 00185 void 00186 computeFeature (PointCloudOut &output); 00187 00189 std::vector<float> radii_interval_; 00190 00192 std::vector<float> theta_divisions_; 00193 00195 std::vector<float> phi_divisions_; 00196 00198 std::vector<float> volume_lut_; 00199 00201 size_t azimuth_bins_; 00202 00204 size_t elevation_bins_; 00205 00207 size_t radius_bins_; 00208 00210 double min_radius_; 00211 00213 double point_density_radius_; 00214 00216 size_t descriptor_length_; 00217 00219 boost::mt19937 rng_alg_; 00220 00222 boost::shared_ptr<boost::uniform_01<boost::mt19937> > rng_; 00223 00229 void 00230 shiftAlongAzimuth (size_t block_size, std::vector<float>& desc); 00231 00233 inline double 00234 rnd () 00235 { 00236 return ((*rng_) ()); 00237 } 00238 private: 00242 void 00243 computeFeatureEigen (pcl::PointCloud<Eigen::MatrixXf> &output) {} 00244 }; 00245 00271 template <typename PointInT, typename PointNT> 00272 class ShapeContext3DEstimation<PointInT, PointNT, Eigen::MatrixXf> : public ShapeContext3DEstimation<PointInT, PointNT, pcl::SHOT> 00273 { 00274 public: 00275 using ShapeContext3DEstimation<PointInT, PointNT, pcl::SHOT>::feature_name_; 00276 using ShapeContext3DEstimation<PointInT, PointNT, pcl::SHOT>::indices_; 00277 using ShapeContext3DEstimation<PointInT, PointNT, pcl::SHOT>::descriptor_length_; 00278 using ShapeContext3DEstimation<PointInT, PointNT, pcl::SHOT>::normals_; 00279 using ShapeContext3DEstimation<PointInT, PointNT, pcl::SHOT>::input_; 00280 using ShapeContext3DEstimation<PointInT, PointNT, pcl::SHOT>::compute; 00281 00282 private: 00286 void 00287 computeFeatureEigen (pcl::PointCloud<Eigen::MatrixXf> &output); 00288 00292 void 00293 compute (pcl::PointCloud<pcl::SHOT> &output) {} 00294 }; 00295 } 00296 00297 #endif //#ifndef PCL_3DSC_H_
1.8.0