Point Cloud Library (PCL)
1.3.1
|
00001 /* 00002 * Software License Agreement (BSD License) 00003 * 00004 * Copyright (c) 2009, Willow Garage, Inc. 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 * 00035 */ 00036 00037 #ifndef PCL_SHOT_H_ 00038 #define PCL_SHOT_H_ 00039 00040 #include <pcl/point_types.h> 00041 #include <pcl/features/feature.h> 00042 00043 namespace pcl 00044 { 00066 template <typename PointInT, typename PointNT, typename PointOutT> 00067 class SHOTEstimationBase : public FeatureFromNormals<PointInT, PointNT, PointOutT> 00068 { 00069 public: 00070 using Feature<PointInT, PointOutT>::feature_name_; 00071 using Feature<PointInT, PointOutT>::getClassName; 00072 using Feature<PointInT, PointOutT>::indices_; 00073 using Feature<PointInT, PointOutT>::k_; 00074 using Feature<PointInT, PointOutT>::search_parameter_; 00075 using Feature<PointInT, PointOutT>::search_radius_; 00076 using Feature<PointInT, PointOutT>::surface_; 00077 using FeatureFromNormals<PointInT, PointNT, PointOutT>::normals_; 00078 00079 typedef typename Feature<PointInT, PointOutT>::PointCloudOut PointCloudOut; 00080 typedef typename Feature<PointInT, PointOutT>::PointCloudIn PointCloudIn; 00081 00082 protected: 00084 SHOTEstimationBase (int nr_shape_bins = 10) : 00085 nr_shape_bins_ (nr_shape_bins), 00086 rf_ (3), // Initialize the placeholder for the point's RF 00087 nr_grid_sector_ (32), 00088 maxAngularSectors_ (28), 00089 descLength_ (0) 00090 { 00091 feature_name_ = "SHOTEstimation"; 00092 }; 00093 00094 public: 00101 virtual void 00102 computePointSHOT (const int index, 00103 const std::vector<int> &indices, 00104 const std::vector<float> &dists, 00105 Eigen::VectorXf &shot, 00106 std::vector<Eigen::Vector4f, Eigen::aligned_allocator<Eigen::Vector4f> > &rf) = 0; 00107 00108 protected: 00109 00115 void 00116 computeFeature (PointCloudOut &output); 00117 00118 void 00119 interpolateSingleChannel (const std::vector<int> &indices, 00120 const std::vector<float> &dists, 00121 const Eigen::Vector4f ¢ralPoint, 00122 const std::vector<Eigen::Vector4f, Eigen::aligned_allocator<Eigen::Vector4f> > &rf 00123 , 00124 std::vector<double> &binDistance, 00125 const int nr_bins, 00126 Eigen::VectorXf &shot); 00127 00129 const int nr_shape_bins_; 00130 00132 Eigen::VectorXf shot_; 00133 00135 std::vector<Eigen::Vector4f, Eigen::aligned_allocator<Eigen::Vector4f> > rf_; 00136 00138 double sqradius_; 00139 00141 double radius3_4_; 00142 00144 double radius1_4_; 00145 00147 double radius1_2_; 00148 00150 const int nr_grid_sector_; 00151 00153 const int maxAngularSectors_; 00154 00156 int descLength_; 00157 }; 00158 00180 template <typename PointInT, typename PointNT, typename PointOutT> 00181 class SHOTEstimation : public SHOTEstimationBase<PointInT, PointNT, PointOutT> 00182 { 00183 public: 00184 using Feature<PointInT, PointOutT>::feature_name_; 00185 using Feature<PointInT, PointOutT>::getClassName; 00186 using Feature<PointInT, PointOutT>::indices_; 00187 using Feature<PointInT, PointOutT>::k_; 00188 using Feature<PointInT, PointOutT>::search_parameter_; 00189 using Feature<PointInT, PointOutT>::search_radius_; 00190 using Feature<PointInT, PointOutT>::surface_; 00191 using Feature<PointInT, PointOutT>::input_; 00192 using FeatureFromNormals<PointInT, PointNT, PointOutT>::normals_; 00193 using SHOTEstimationBase<PointInT, PointNT, PointOutT>::descLength_; 00194 using SHOTEstimationBase<PointInT, PointNT, PointOutT>::nr_grid_sector_; 00195 using SHOTEstimationBase<PointInT, PointNT, PointOutT>::nr_shape_bins_; 00196 using SHOTEstimationBase<PointInT, PointNT, PointOutT>::sqradius_; 00197 using SHOTEstimationBase<PointInT, PointNT, PointOutT>::radius3_4_; 00198 using SHOTEstimationBase<PointInT, PointNT, PointOutT>::radius1_4_; 00199 using SHOTEstimationBase<PointInT, PointNT, PointOutT>::radius1_2_; 00200 using SHOTEstimationBase<PointInT, PointNT, PointOutT>::rf_; 00201 using SHOTEstimationBase<PointInT, PointNT, PointOutT>::maxAngularSectors_; 00202 using SHOTEstimationBase<PointInT, PointNT, PointOutT>::interpolateSingleChannel; 00203 using SHOTEstimationBase<PointInT, PointNT, PointOutT>::shot_; 00204 00205 typedef typename Feature<PointInT, PointOutT>::PointCloudOut PointCloudOut; 00206 typedef typename Feature<PointInT, PointOutT>::PointCloudIn PointCloudIn; 00207 00209 SHOTEstimation (int nr_shape_bins = 10) : SHOTEstimationBase<PointInT, PointNT, PointOutT> (nr_shape_bins) 00210 { 00211 feature_name_ = "SHOTEstimation"; 00212 }; 00213 00220 void 00221 computePointSHOT (const int index, 00222 const std::vector<int> &indices, 00223 const std::vector<float> &dists, 00224 Eigen::VectorXf &shot, 00225 std::vector<Eigen::Vector4f, Eigen::aligned_allocator<Eigen::Vector4f> > &rf); 00226 }; 00227 00249 template <typename PointNT, typename PointOutT> 00250 class SHOTEstimation<pcl::PointXYZRGBA, PointNT, PointOutT> : public SHOTEstimationBase<pcl::PointXYZRGBA, PointNT, PointOutT> 00251 { 00252 public: 00253 using Feature<pcl::PointXYZRGBA, PointOutT>::feature_name_; 00254 using Feature<pcl::PointXYZRGBA, PointOutT>::getClassName; 00255 using Feature<pcl::PointXYZRGBA, PointOutT>::indices_; 00256 using Feature<pcl::PointXYZRGBA, PointOutT>::k_; 00257 using Feature<pcl::PointXYZRGBA, PointOutT>::search_parameter_; 00258 using Feature<pcl::PointXYZRGBA, PointOutT>::search_radius_; 00259 using Feature<pcl::PointXYZRGBA, PointOutT>::surface_; 00260 using Feature<pcl::PointXYZRGBA, PointOutT>::input_; 00261 using FeatureFromNormals<pcl::PointXYZRGBA, PointNT, PointOutT>::normals_; 00262 using SHOTEstimationBase<pcl::PointXYZRGBA, PointNT, PointOutT>::descLength_; 00263 using SHOTEstimationBase<pcl::PointXYZRGBA, PointNT, PointOutT>::nr_grid_sector_; 00264 using SHOTEstimationBase<pcl::PointXYZRGBA, PointNT, PointOutT>::nr_shape_bins_; 00265 using SHOTEstimationBase<pcl::PointXYZRGBA, PointNT, PointOutT>::sqradius_; 00266 using SHOTEstimationBase<pcl::PointXYZRGBA, PointNT, PointOutT>::radius3_4_; 00267 using SHOTEstimationBase<pcl::PointXYZRGBA, PointNT, PointOutT>::radius1_4_; 00268 using SHOTEstimationBase<pcl::PointXYZRGBA, PointNT, PointOutT>::radius1_2_; 00269 using SHOTEstimationBase<pcl::PointXYZRGBA, PointNT, PointOutT>::rf_; 00270 using SHOTEstimationBase<pcl::PointXYZRGBA, PointNT, PointOutT>::maxAngularSectors_; 00271 using SHOTEstimationBase<pcl::PointXYZRGBA, PointNT, PointOutT>::interpolateSingleChannel; 00272 using SHOTEstimationBase<pcl::PointXYZRGBA, PointNT, PointOutT>::shot_; 00273 00274 typedef typename Feature<pcl::PointXYZRGBA, PointOutT>::PointCloudOut PointCloudOut; 00275 typedef typename Feature<pcl::PointXYZRGBA, PointOutT>::PointCloudIn PointCloudIn; 00276 00278 SHOTEstimation (bool describeShape = true, 00279 bool describeColor = false, 00280 const int nr_shape_bins = 10, 00281 const int nr_color_bins = 30) 00282 : SHOTEstimationBase<pcl::PointXYZRGBA, PointNT, PointOutT> (nr_shape_bins), 00283 b_describe_shape_ (describeShape), 00284 b_describe_color_ (describeColor), 00285 nr_color_bins_ (nr_color_bins) 00286 { 00287 feature_name_ = "SHOTEstimation"; 00288 }; 00289 00296 void 00297 computePointSHOT (const int index, 00298 const std::vector<int> &indices, 00299 const std::vector<float> &dists, 00300 Eigen::VectorXf &shot, 00301 std::vector<Eigen::Vector4f, Eigen::aligned_allocator<Eigen::Vector4f> > &rf); 00302 00303 protected: 00304 00310 void 00311 computeFeature (PointCloudOut &output); 00312 00315 void 00316 interpolateDoubleChannel (const std::vector<int> &indices, 00317 const std::vector<float> &dists, 00318 const Eigen::Vector4f ¢ralPoint, 00319 const std::vector<Eigen::Vector4f, Eigen::aligned_allocator<Eigen::Vector4f> > &rf, 00320 std::vector<double> &binDistanceShape, 00321 std::vector<double> &binDistanceColor, 00322 const int nr_bins_shape, 00323 const int nr_bins_color, 00324 Eigen::VectorXf &shot); 00325 00328 static void 00329 RGB2CIELAB (unsigned char R, unsigned char G, unsigned char B, float &L, float &A, float &B2); 00330 00332 bool b_describe_shape_; 00333 00335 bool b_describe_color_; 00336 00338 int nr_color_bins_; 00339 00340 public: 00341 static float sRGB_LUT[256]; 00342 static float sXYZ_LUT[4000]; 00343 }; 00344 } 00345 00346 #endif //#ifndef PCL_SHOT_H_ 00347 00348