|
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: spin_image.h 4702 2012-02-23 09:39:33Z gedikli $ 00037 */ 00038 00039 #ifndef PCL_SPIN_IMAGE_H_ 00040 #define PCL_SPIN_IMAGE_H_ 00041 00042 #include <pcl/point_types.h> 00043 #include <pcl/features/feature.h> 00044 00045 namespace pcl 00046 { 00086 template <typename PointInT, typename PointNT, typename PointOutT> 00087 class SpinImageEstimation : public Feature<PointInT, PointOutT> 00088 { 00089 public: 00090 using Feature<PointInT, PointOutT>::feature_name_; 00091 using Feature<PointInT, PointOutT>::getClassName; 00092 using Feature<PointInT, PointOutT>::indices_; 00093 using Feature<PointInT, PointOutT>::search_radius_; 00094 using Feature<PointInT, PointOutT>::k_; 00095 using Feature<PointInT, PointOutT>::surface_; 00096 using Feature<PointInT, PointOutT>::fake_surface_; 00097 using PCLBase<PointInT>::input_; 00098 00099 typedef typename Feature<PointInT, PointOutT>::PointCloudOut PointCloudOut; 00100 00101 typedef typename pcl::PointCloud<PointNT> PointCloudN; 00102 typedef typename PointCloudN::Ptr PointCloudNPtr; 00103 typedef typename PointCloudN::ConstPtr PointCloudNConstPtr; 00104 00105 typedef typename pcl::PointCloud<PointInT> PointCloudIn; 00106 typedef typename PointCloudIn::Ptr PointCloudInPtr; 00107 typedef typename PointCloudIn::ConstPtr PointCloudInConstPtr; 00108 00118 SpinImageEstimation (unsigned int image_width = 8, 00119 double support_angle_cos = 0.0, // when 0, this is bogus, so not applied 00120 unsigned int min_pts_neighb = 0); 00121 00126 void 00127 setImageWidth (unsigned int bin_count) 00128 { 00129 image_width_ = bin_count; 00130 } 00131 00138 void 00139 setSupportAngle (double support_angle_cos) 00140 { 00141 if (0.0 > support_angle_cos || support_angle_cos > 1.0) // may be permit negative cosine? 00142 { 00143 throw PCLException ("Cosine of support angle should be between 0 and 1", 00144 "spin_image.h", "setSupportAngle"); 00145 } 00146 00147 support_angle_cos_ = support_angle_cos; 00148 } 00149 00155 void 00156 setMinPointCountInNeighbourhood (unsigned int min_pts_neighb) 00157 { 00158 min_pts_neighb_ = min_pts_neighb; 00159 } 00160 00171 inline void 00172 setInputNormals (const PointCloudNConstPtr &normals) 00173 { 00174 input_normals_ = normals; 00175 } 00176 00182 void 00183 setRotationAxis (const PointNT& axis) 00184 { 00185 rotation_axis_ = axis; 00186 use_custom_axis_ = true; 00187 use_custom_axes_cloud_ = false; 00188 } 00189 00196 void 00197 setInputRotationAxes (const PointCloudNConstPtr& axes) 00198 { 00199 rotation_axes_cloud_ = axes; 00200 00201 use_custom_axes_cloud_ = true; 00202 use_custom_axis_ = false; 00203 } 00204 00206 void 00207 useNormalsAsRotationAxis () 00208 { 00209 use_custom_axis_ = false; 00210 use_custom_axes_cloud_ = false; 00211 } 00212 00224 void 00225 setAngularDomain (bool is_angular = true) { is_angular_ = is_angular; } 00226 00234 void 00235 setRadialStructure (bool is_radial = true) { is_radial_ = is_radial; } 00236 00237 protected: 00242 virtual void 00243 computeFeature (PointCloudOut &output); 00244 00249 virtual bool 00250 initCompute (); 00251 00256 Eigen::ArrayXXd 00257 computeSiForPoint (int index) const; 00258 00259 private: 00260 PointCloudNConstPtr input_normals_; 00261 PointCloudNConstPtr rotation_axes_cloud_; 00262 00263 bool is_angular_; 00264 00265 PointNT rotation_axis_; 00266 bool use_custom_axis_; 00267 bool use_custom_axes_cloud_; 00268 00269 bool is_radial_; 00270 00271 unsigned int image_width_; 00272 double support_angle_cos_; 00273 unsigned int min_pts_neighb_; 00274 00275 00276 static const double PI; 00277 00281 void 00282 computeFeatureEigen (pcl::PointCloud<Eigen::MatrixXf> &output) {} 00283 }; 00284 00315 template <typename PointInT, typename PointNT> 00316 class SpinImageEstimation<PointInT, PointNT, Eigen::MatrixXf> : public SpinImageEstimation<PointInT, PointNT, pcl::Histogram<153> > 00317 { 00318 public: 00319 using SpinImageEstimation<PointInT, PointNT, pcl::Histogram<153> >::indices_; 00320 using SpinImageEstimation<PointInT, PointNT, pcl::Histogram<153> >::search_radius_; 00321 using SpinImageEstimation<PointInT, PointNT, pcl::Histogram<153> >::k_; 00322 using SpinImageEstimation<PointInT, PointNT, pcl::Histogram<153> >::surface_; 00323 using SpinImageEstimation<PointInT, PointNT, pcl::Histogram<153> >::fake_surface_; 00324 using SpinImageEstimation<PointInT, PointNT, pcl::Histogram<153> >::compute; 00325 00335 SpinImageEstimation (unsigned int image_width = 8, 00336 double support_angle_cos = 0.0, // when 0, this is bogus, so not applied 00337 unsigned int min_pts_neighb = 0) : 00338 SpinImageEstimation<PointInT, PointNT, pcl::Histogram<153> > (image_width, support_angle_cos, min_pts_neighb) {} 00339 00340 private: 00345 virtual void 00346 computeFeatureEigen (pcl::PointCloud<Eigen::MatrixXf> &output); 00347 00351 void 00352 compute (pcl::PointCloud<pcl::Normal> &output) {} 00353 }; 00354 } 00355 00356 #endif //#ifndef PCL_SPIN_IMAGE_H_ 00357 00358
1.8.0