|
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 * 00037 */ 00038 00039 #ifndef PCL_SHOT_H_ 00040 #define PCL_SHOT_H_ 00041 00042 #include <pcl/point_types.h> 00043 #include <pcl/features/feature.h> 00044 00045 namespace pcl 00046 { 00064 template <typename PointInT, typename PointNT, typename PointOutT> 00065 class SHOTEstimationBase : public FeatureFromNormals<PointInT, PointNT, PointOutT> 00066 { 00067 public: 00068 using Feature<PointInT, PointOutT>::feature_name_; 00069 using Feature<PointInT, PointOutT>::getClassName; 00070 using Feature<PointInT, PointOutT>::input_; 00071 using Feature<PointInT, PointOutT>::indices_; 00072 using Feature<PointInT, PointOutT>::k_; 00073 using Feature<PointInT, PointOutT>::search_parameter_; 00074 using Feature<PointInT, PointOutT>::search_radius_; 00075 using Feature<PointInT, PointOutT>::surface_; 00076 using FeatureFromNormals<PointInT, PointNT, PointOutT>::normals_; 00077 00078 typedef typename Feature<PointInT, PointOutT>::PointCloudIn PointCloudIn; 00079 00080 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: 00102 virtual void 00103 computePointSHOT (const int index, 00104 const std::vector<int> &indices, 00105 const std::vector<float> &sqr_dists, 00106 Eigen::VectorXf &shot, 00107 std::vector<Eigen::Vector4f, Eigen::aligned_allocator<Eigen::Vector4f> > &rf) = 0; 00108 00109 protected: 00110 00116 void 00117 computeFeature (pcl::PointCloud<PointOutT> &output); 00118 00129 void 00130 interpolateSingleChannel (const std::vector<int> &indices, 00131 const std::vector<float> &sqr_dists, 00132 const Eigen::Vector4f ¢ralPoint, 00133 const std::vector<Eigen::Vector4f, Eigen::aligned_allocator<Eigen::Vector4f> > &rf, 00134 std::vector<double> &binDistance, 00135 const int nr_bins, 00136 Eigen::VectorXf &shot); 00137 00142 void 00143 normalizeHistogram (Eigen::VectorXf &shot, int desc_length); 00144 00145 00157 void 00158 createBinDistanceShape (int index, const std::vector<int> &indices, const std::vector<float> &sqr_dists, 00159 const pcl::PointCloud<PointInT> &input, 00160 const pcl::PointCloud<PointNT> &normals, 00161 const pcl::PointCloud<PointInT> &surface, 00162 double search_radius, 00163 std::vector<double> &bin_distance_shape, 00164 std::vector<Eigen::Vector4f, Eigen::aligned_allocator<Eigen::Vector4f> > &rf); 00165 00167 const int nr_shape_bins_; 00168 00170 Eigen::VectorXf shot_; 00171 00173 std::vector<Eigen::Vector4f, Eigen::aligned_allocator<Eigen::Vector4f> > rf_; 00174 00176 double sqradius_; 00177 00179 double radius3_4_; 00180 00182 double radius1_4_; 00183 00185 double radius1_2_; 00186 00188 const int nr_grid_sector_; 00189 00191 const int maxAngularSectors_; 00192 00194 int descLength_; 00195 00199 void 00200 computeFeature (pcl::PointCloud<Eigen::MatrixXf> &output) {} 00201 }; 00202 00220 template <typename PointInT, typename PointNT> 00221 class SHOTEstimationBase<PointInT, PointNT, Eigen::MatrixXf> : public SHOTEstimationBase<PointInT, PointNT, pcl::SHOT> 00222 { 00223 public: 00224 using SHOTEstimationBase<PointInT, PointNT, pcl::SHOT>::input_; 00225 using SHOTEstimationBase<PointInT, PointNT, pcl::SHOT>::indices_; 00226 using SHOTEstimationBase<PointInT, PointNT, pcl::SHOT>::k_; 00227 using SHOTEstimationBase<PointInT, PointNT, pcl::SHOT>::search_parameter_; 00228 using SHOTEstimationBase<PointInT, PointNT, pcl::SHOT>::search_radius_; 00229 using SHOTEstimationBase<PointInT, PointNT, pcl::SHOT>::surface_; 00230 using SHOTEstimationBase<PointInT, PointNT, pcl::SHOT>::rf_; 00231 using SHOTEstimationBase<PointInT, PointNT, pcl::SHOT>::descLength_; 00232 using SHOTEstimationBase<PointInT, PointNT, pcl::SHOT>::nr_grid_sector_; 00233 using SHOTEstimationBase<PointInT, PointNT, pcl::SHOT>::nr_shape_bins_; 00234 using SHOTEstimationBase<PointInT, PointNT, pcl::SHOT>::sqradius_; 00235 using SHOTEstimationBase<PointInT, PointNT, pcl::SHOT>::radius3_4_; 00236 using SHOTEstimationBase<PointInT, PointNT, pcl::SHOT>::radius1_4_; 00237 using SHOTEstimationBase<PointInT, PointNT, pcl::SHOT>::radius1_2_; 00238 using SHOTEstimationBase<PointInT, PointNT, pcl::SHOT>::shot_; 00239 00243 SHOTEstimationBase (int nr_shape_bins = 10) : SHOTEstimationBase<PointInT, PointNT, pcl::SHOT> (nr_shape_bins) {}; 00244 00250 void 00251 computeFeature (pcl::PointCloud<Eigen::MatrixXf> &output); 00252 00258 void 00259 compute (pcl::PointCloud<Eigen::MatrixXf> &output) 00260 { 00261 pcl::SHOTEstimationBase<PointInT, PointNT, pcl::SHOT>::compute (output); 00262 } 00263 00267 void 00268 compute (pcl::PointCloud<pcl::SHOT> &output) {} 00269 }; 00270 00288 template <typename PointInT, typename PointNT, typename PointOutT> 00289 class SHOTEstimation : public SHOTEstimationBase<PointInT, PointNT, PointOutT> 00290 { 00291 public: 00292 using SHOTEstimationBase<PointInT, PointNT, PointOutT>::feature_name_; 00293 using SHOTEstimationBase<PointInT, PointNT, PointOutT>::getClassName; 00294 using SHOTEstimationBase<PointInT, PointNT, PointOutT>::indices_; 00295 using SHOTEstimationBase<PointInT, PointNT, PointOutT>::k_; 00296 using SHOTEstimationBase<PointInT, PointNT, PointOutT>::search_parameter_; 00297 using SHOTEstimationBase<PointInT, PointNT, PointOutT>::search_radius_; 00298 using SHOTEstimationBase<PointInT, PointNT, PointOutT>::surface_; 00299 using SHOTEstimationBase<PointInT, PointNT, PointOutT>::input_; 00300 using SHOTEstimationBase<PointInT, PointNT, PointOutT>::normals_; 00301 using SHOTEstimationBase<PointInT, PointNT, PointOutT>::descLength_; 00302 using SHOTEstimationBase<PointInT, PointNT, PointOutT>::nr_grid_sector_; 00303 using SHOTEstimationBase<PointInT, PointNT, PointOutT>::nr_shape_bins_; 00304 using SHOTEstimationBase<PointInT, PointNT, PointOutT>::sqradius_; 00305 using SHOTEstimationBase<PointInT, PointNT, PointOutT>::radius3_4_; 00306 using SHOTEstimationBase<PointInT, PointNT, PointOutT>::radius1_4_; 00307 using SHOTEstimationBase<PointInT, PointNT, PointOutT>::radius1_2_; 00308 using SHOTEstimationBase<PointInT, PointNT, PointOutT>::rf_; 00309 using SHOTEstimationBase<PointInT, PointNT, PointOutT>::maxAngularSectors_; 00310 using SHOTEstimationBase<PointInT, PointNT, PointOutT>::interpolateSingleChannel; 00311 using SHOTEstimationBase<PointInT, PointNT, PointOutT>::shot_; 00312 00313 typedef typename Feature<PointInT, PointOutT>::PointCloudIn PointCloudIn; 00314 00318 SHOTEstimation (int nr_shape_bins = 10) : SHOTEstimationBase<PointInT, PointNT, PointOutT> (nr_shape_bins) 00319 { 00320 feature_name_ = "SHOTEstimation"; 00321 }; 00322 00330 void 00331 computePointSHOT (const int index, 00332 const std::vector<int> &indices, 00333 const std::vector<float> &sqr_dists, 00334 Eigen::VectorXf &shot, 00335 std::vector<Eigen::Vector4f, Eigen::aligned_allocator<Eigen::Vector4f> > &rf); 00336 00337 }; 00338 00356 template <typename PointInT, typename PointNT> 00357 class SHOTEstimation<PointInT, PointNT, Eigen::MatrixXf> : public SHOTEstimationBase<PointInT, PointNT, Eigen::MatrixXf> 00358 { 00359 public: 00360 using SHOTEstimationBase<PointInT, PointNT, Eigen::MatrixXf>::feature_name_; 00361 using SHOTEstimationBase<PointInT, PointNT, Eigen::MatrixXf>::getClassName; 00362 using SHOTEstimationBase<PointInT, PointNT, Eigen::MatrixXf>::indices_; 00363 using SHOTEstimationBase<PointInT, PointNT, Eigen::MatrixXf>::k_; 00364 using SHOTEstimationBase<PointInT, PointNT, Eigen::MatrixXf>::search_parameter_; 00365 using SHOTEstimationBase<PointInT, PointNT, Eigen::MatrixXf>::search_radius_; 00366 using SHOTEstimationBase<PointInT, PointNT, Eigen::MatrixXf>::surface_; 00367 using SHOTEstimationBase<PointInT, PointNT, Eigen::MatrixXf>::input_; 00368 using SHOTEstimationBase<PointInT, PointNT, Eigen::MatrixXf>::normals_; 00369 using SHOTEstimationBase<PointInT, PointNT, Eigen::MatrixXf>::descLength_; 00370 using SHOTEstimationBase<PointInT, PointNT, Eigen::MatrixXf>::nr_grid_sector_; 00371 using SHOTEstimationBase<PointInT, PointNT, Eigen::MatrixXf>::nr_shape_bins_; 00372 using SHOTEstimationBase<PointInT, PointNT, Eigen::MatrixXf>::sqradius_; 00373 using SHOTEstimationBase<PointInT, PointNT, Eigen::MatrixXf>::radius3_4_; 00374 using SHOTEstimationBase<PointInT, PointNT, Eigen::MatrixXf>::radius1_4_; 00375 using SHOTEstimationBase<PointInT, PointNT, Eigen::MatrixXf>::radius1_2_; 00376 using SHOTEstimationBase<PointInT, PointNT, Eigen::MatrixXf>::rf_; 00377 using SHOTEstimationBase<PointInT, PointNT, Eigen::MatrixXf>::maxAngularSectors_; 00378 using SHOTEstimationBase<PointInT, PointNT, Eigen::MatrixXf>::interpolateSingleChannel; 00379 using SHOTEstimationBase<PointInT, PointNT, Eigen::MatrixXf>::shot_; 00380 00384 SHOTEstimation (int nr_shape_bins = 10) : SHOTEstimationBase<PointInT, PointNT, Eigen::MatrixXf> (nr_shape_bins) 00385 { 00386 feature_name_ = "SHOTEstimation"; 00387 }; 00388 00396 void 00397 computePointSHOT (const int index, 00398 const std::vector<int> &indices, 00399 const std::vector<float> &sqr_dists, 00400 Eigen::VectorXf &shot, 00401 std::vector<Eigen::Vector4f, Eigen::aligned_allocator<Eigen::Vector4f> > &rf); 00402 }; 00403 00421 template <typename PointNT, typename PointOutT> 00422 class SHOTEstimation<pcl::PointXYZRGBA, PointNT, PointOutT> : public SHOTEstimationBase<pcl::PointXYZRGBA, PointNT, PointOutT> 00423 { 00424 public: 00425 using Feature<pcl::PointXYZRGBA, PointOutT>::feature_name_; 00426 using Feature<pcl::PointXYZRGBA, PointOutT>::getClassName; 00427 using Feature<pcl::PointXYZRGBA, PointOutT>::indices_; 00428 using Feature<pcl::PointXYZRGBA, PointOutT>::k_; 00429 using Feature<pcl::PointXYZRGBA, PointOutT>::search_parameter_; 00430 using Feature<pcl::PointXYZRGBA, PointOutT>::search_radius_; 00431 using Feature<pcl::PointXYZRGBA, PointOutT>::surface_; 00432 using Feature<pcl::PointXYZRGBA, PointOutT>::input_; 00433 using FeatureFromNormals<pcl::PointXYZRGBA, PointNT, PointOutT>::normals_; 00434 using SHOTEstimationBase<pcl::PointXYZRGBA, PointNT, PointOutT>::descLength_; 00435 using SHOTEstimationBase<pcl::PointXYZRGBA, PointNT, PointOutT>::nr_grid_sector_; 00436 using SHOTEstimationBase<pcl::PointXYZRGBA, PointNT, PointOutT>::nr_shape_bins_; 00437 using SHOTEstimationBase<pcl::PointXYZRGBA, PointNT, PointOutT>::sqradius_; 00438 using SHOTEstimationBase<pcl::PointXYZRGBA, PointNT, PointOutT>::radius3_4_; 00439 using SHOTEstimationBase<pcl::PointXYZRGBA, PointNT, PointOutT>::radius1_4_; 00440 using SHOTEstimationBase<pcl::PointXYZRGBA, PointNT, PointOutT>::radius1_2_; 00441 using SHOTEstimationBase<pcl::PointXYZRGBA, PointNT, PointOutT>::rf_; 00442 using SHOTEstimationBase<pcl::PointXYZRGBA, PointNT, PointOutT>::maxAngularSectors_; 00443 using SHOTEstimationBase<pcl::PointXYZRGBA, PointNT, PointOutT>::interpolateSingleChannel; 00444 using SHOTEstimationBase<pcl::PointXYZRGBA, PointNT, PointOutT>::shot_; 00445 00446 typedef typename Feature<pcl::PointXYZRGBA, PointOutT>::PointCloudOut PointCloudOut; 00447 typedef typename Feature<pcl::PointXYZRGBA, PointOutT>::PointCloudIn PointCloudIn; 00448 00455 SHOTEstimation (bool describe_shape = true, 00456 bool describe_color = false, 00457 const int nr_shape_bins = 10, 00458 const int nr_color_bins = 30) 00459 : SHOTEstimationBase<pcl::PointXYZRGBA, PointNT, PointOutT> (nr_shape_bins), 00460 b_describe_shape_ (describe_shape), 00461 b_describe_color_ (describe_color), 00462 nr_color_bins_ (nr_color_bins) 00463 { 00464 feature_name_ = "SHOTEstimation"; 00465 }; 00466 00474 void 00475 computePointSHOT (const int index, 00476 const std::vector<int> &indices, 00477 const std::vector<float> &sqr_dists, 00478 Eigen::VectorXf &shot, 00479 std::vector<Eigen::Vector4f, Eigen::aligned_allocator<Eigen::Vector4f> > &rf); 00480 00481 protected: 00482 00488 void 00489 computeFeature (PointCloudOut &output); 00490 00502 void 00503 interpolateDoubleChannel (const std::vector<int> &indices, 00504 const std::vector<float> &sqr_dists, 00505 const Eigen::Vector4f ¢ralPoint, 00506 const std::vector<Eigen::Vector4f, Eigen::aligned_allocator<Eigen::Vector4f> > &rf, 00507 std::vector<double> &binDistanceShape, 00508 std::vector<double> &binDistanceColor, 00509 const int nr_bins_shape, 00510 const int nr_bins_color, 00511 Eigen::VectorXf &shot); 00512 00521 static void 00522 RGB2CIELAB (unsigned char R, unsigned char G, unsigned char B, float &L, float &A, float &B2); 00523 00525 bool b_describe_shape_; 00526 00528 bool b_describe_color_; 00529 00531 int nr_color_bins_; 00532 00533 public: 00534 static float sRGB_LUT[256]; 00535 static float sXYZ_LUT[4000]; 00536 }; 00537 00555 template <typename PointNT> 00556 class SHOTEstimation<pcl::PointXYZRGBA, PointNT, Eigen::MatrixXf> : public SHOTEstimation<pcl::PointXYZRGBA, PointNT, pcl::SHOT> 00557 { 00558 public: 00559 using SHOTEstimation<pcl::PointXYZRGBA, PointNT, pcl::SHOT>::feature_name_; 00560 using SHOTEstimation<pcl::PointXYZRGBA, PointNT, pcl::SHOT>::getClassName; 00561 using SHOTEstimation<pcl::PointXYZRGBA, PointNT, pcl::SHOT>::indices_; 00562 using SHOTEstimation<pcl::PointXYZRGBA, PointNT, pcl::SHOT>::k_; 00563 using SHOTEstimation<pcl::PointXYZRGBA, PointNT, pcl::SHOT>::search_parameter_; 00564 using SHOTEstimation<pcl::PointXYZRGBA, PointNT, pcl::SHOT>::search_radius_; 00565 using SHOTEstimation<pcl::PointXYZRGBA, PointNT, pcl::SHOT>::surface_; 00566 using SHOTEstimation<pcl::PointXYZRGBA, PointNT, pcl::SHOT>::input_; 00567 using SHOTEstimation<pcl::PointXYZRGBA, PointNT, pcl::SHOT>::rf_; 00568 using SHOTEstimation<pcl::PointXYZRGBA, PointNT, pcl::SHOT>::descLength_; 00569 using SHOTEstimation<pcl::PointXYZRGBA, PointNT, pcl::SHOT>::nr_grid_sector_; 00570 using SHOTEstimation<pcl::PointXYZRGBA, PointNT, pcl::SHOT>::nr_shape_bins_; 00571 using SHOTEstimation<pcl::PointXYZRGBA, PointNT, pcl::SHOT>::sqradius_; 00572 using SHOTEstimation<pcl::PointXYZRGBA, PointNT, pcl::SHOT>::radius3_4_; 00573 using SHOTEstimation<pcl::PointXYZRGBA, PointNT, pcl::SHOT>::radius1_4_; 00574 using SHOTEstimation<pcl::PointXYZRGBA, PointNT, pcl::SHOT>::radius1_2_; 00575 using SHOTEstimation<pcl::PointXYZRGBA, PointNT, pcl::SHOT>::maxAngularSectors_; 00576 using SHOTEstimation<pcl::PointXYZRGBA, PointNT, pcl::SHOT>::interpolateSingleChannel; 00577 using SHOTEstimation<pcl::PointXYZRGBA, PointNT, pcl::SHOT>::shot_; 00578 using SHOTEstimation<pcl::PointXYZRGBA, PointNT, pcl::SHOT>::b_describe_shape_; 00579 using SHOTEstimation<pcl::PointXYZRGBA, PointNT, pcl::SHOT>::b_describe_color_; 00580 using SHOTEstimation<pcl::PointXYZRGBA, PointNT, pcl::SHOT>::nr_color_bins_; 00581 00588 SHOTEstimation (bool describe_shape = true, 00589 bool describe_color = false, 00590 const int nr_shape_bins = 10, 00591 const int nr_color_bins = 30) 00592 : SHOTEstimation<pcl::PointXYZRGBA, PointNT, pcl::SHOT> (describe_shape, describe_color, nr_shape_bins, nr_color_bins) {}; 00593 00594 protected: 00600 void 00601 computeFeature (pcl::PointCloud<Eigen::MatrixXf> &output); 00602 }; 00603 } 00604 00605 #endif //#ifndef PCL_SHOT_H_ 00606 00607
1.7.6.1