|
Point Cloud Library (PCL)
1.4.0
|
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 3755 2011-12-31 23:45:30Z rusu $ 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 { 00075 template <typename PointInT, typename PointNT, typename PointOutT> 00076 class SpinImageEstimation : public FeatureFromNormals<PointInT, PointNT, PointOutT> 00077 { 00078 public: 00079 using Feature<PointInT, PointOutT>::feature_name_; 00080 using Feature<PointInT, PointOutT>::getClassName; 00081 using Feature<PointInT, PointOutT>::indices_; 00082 using Feature<PointInT, PointOutT>::search_radius_; 00083 using Feature<PointInT, PointOutT>::surface_; 00084 using Feature<PointInT, PointOutT>::fake_surface_; 00085 using FeatureFromNormals<PointInT, PointNT, PointOutT>::normals_; 00086 using PCLBase<PointInT>::input_; 00087 00088 typedef typename Feature<PointInT, PointOutT>::PointCloudOut PointCloudOut; 00089 00090 typedef typename pcl::PointCloud<PointNT> PointCloudN; 00091 typedef typename PointCloudN::Ptr PointCloudNPtr; 00092 typedef typename PointCloudN::ConstPtr PointCloudNConstPtr; 00093 00094 typedef typename pcl::PointCloud<PointInT> PointCloudIn; 00095 typedef typename PointCloudIn::Ptr PointCloudInPtr; 00096 typedef typename PointCloudIn::ConstPtr PointCloudInConstPtr; 00097 00107 SpinImageEstimation (unsigned int image_width = 8, 00108 double support_angle_cos = 0.0, // when 0, this is bogus, so not applied 00109 unsigned int min_pts_neighb = 0); 00110 00115 void 00116 setImageWidth (unsigned int bin_count) 00117 { 00118 image_width_ = bin_count; 00119 } 00120 00127 void 00128 setSupportAngle (double support_angle_cos) 00129 { 00130 if (0.0 > support_angle_cos || support_angle_cos > 1.0) // may be permit negative cosine? 00131 { 00132 throw PCLException ("Cosine of support angle should be between 0 and 1", 00133 "spin_image.h", "setSupportAngle"); 00134 } 00135 00136 support_angle_cos_ = support_angle_cos; 00137 } 00138 00144 void 00145 setMinPointCountInNeighbourhood (unsigned int min_pts_neighb) 00146 { 00147 min_pts_neighb_ = min_pts_neighb; 00148 } 00149 00150 00158 void 00159 setInputWithNormals (const PointCloudInConstPtr& input, 00160 const PointCloudNConstPtr& normals) 00161 { 00162 this->setInputCloud (input); 00163 input_normals_ = normals; 00164 } 00165 00175 void 00176 setSearchSurfaceWithNormals (const PointCloudInConstPtr& surface, 00177 const PointCloudNConstPtr& normals) 00178 { 00179 this->setSearchSurface (surface); 00180 this->setInputNormals (normals); 00181 } 00182 00188 void 00189 setRotationAxis (const PointNT& axis) 00190 { 00191 rotation_axis_ = axis; 00192 use_custom_axis_ = true; 00193 use_custom_axes_cloud_ = false; 00194 } 00195 00202 void 00203 setInputRotationAxes (const PointCloudNConstPtr& axes) 00204 { 00205 rotation_axes_cloud_ = axes; 00206 00207 use_custom_axes_cloud_ = true; 00208 use_custom_axis_ = false; 00209 } 00210 00214 void 00215 useNormalsAsRotationAxis () 00216 { 00217 use_custom_axis_ = false; 00218 use_custom_axes_cloud_ = false; 00219 } 00220 00232 void 00233 setAngularDomain (bool is_angular = true) { is_angular_ = is_angular; } 00234 00242 void 00243 setRadialStructure (bool is_radial = true) { is_radial_ = is_radial; } 00244 00245 protected: 00250 virtual void 00251 computeFeature (PointCloudOut &output); 00252 00257 virtual bool 00258 initCompute (); 00259 00260 00266 Eigen::ArrayXXd 00267 computeSiForPoint (int index) const; 00268 00269 private: 00270 PointCloudNConstPtr input_normals_; 00271 PointCloudNConstPtr rotation_axes_cloud_; 00272 00273 bool is_angular_; 00274 00275 PointNT rotation_axis_; 00276 bool use_custom_axis_; 00277 bool use_custom_axes_cloud_; 00278 00279 bool is_radial_; 00280 00281 unsigned int image_width_; 00282 double support_angle_cos_; 00283 unsigned int min_pts_neighb_; 00284 00285 00286 static const double PI; 00287 00291 void 00292 computeFeature (pcl::PointCloud<Eigen::MatrixXf> &output) {} 00293 }; 00294 00323 template <typename PointInT, typename PointNT> 00324 class SpinImageEstimation<PointInT, PointNT, Eigen::MatrixXf> : public SpinImageEstimation<PointInT, PointNT, pcl::Histogram<153> > 00325 { 00326 public: 00327 using SpinImageEstimation<PointInT, PointNT, pcl::Histogram<153> >::indices_; 00328 using SpinImageEstimation<PointInT, PointNT, pcl::Histogram<153> >::search_radius_; 00329 using SpinImageEstimation<PointInT, PointNT, pcl::Histogram<153> >::surface_; 00330 using SpinImageEstimation<PointInT, PointNT, pcl::Histogram<153> >::fake_surface_; 00331 using SpinImageEstimation<PointInT, PointNT, pcl::Histogram<153> >::compute; 00332 00342 SpinImageEstimation (unsigned int image_width = 8, 00343 double support_angle_cos = 0.0, // when 0, this is bogus, so not applied 00344 unsigned int min_pts_neighb = 0) : 00345 SpinImageEstimation<PointInT, PointNT, pcl::Histogram<153> > (image_width, support_angle_cos, min_pts_neighb) {} 00346 00347 private: 00352 virtual void 00353 computeFeature (pcl::PointCloud<Eigen::MatrixXf> &output); 00354 00358 void 00359 compute (pcl::PointCloud<pcl::Normal> &output) {} 00360 }; 00361 } 00362 00363 #endif //#ifndef PCL_SPIN_IMAGE_H_ 00364 00365
1.7.6.1