|
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: fpfh.h 4702 2012-02-23 09:39:33Z gedikli $ 00037 * 00038 */ 00039 00040 #ifndef PCL_FPFH_H_ 00041 #define PCL_FPFH_H_ 00042 00043 #include <pcl/features/feature.h> 00044 #include <set> 00045 00046 namespace pcl 00047 { 00078 template <typename PointInT, typename PointNT, typename PointOutT = pcl::FPFHSignature33> 00079 class FPFHEstimation : public FeatureFromNormals<PointInT, PointNT, PointOutT> 00080 { 00081 public: 00082 using Feature<PointInT, PointOutT>::feature_name_; 00083 using Feature<PointInT, PointOutT>::getClassName; 00084 using Feature<PointInT, PointOutT>::indices_; 00085 using Feature<PointInT, PointOutT>::k_; 00086 using Feature<PointInT, PointOutT>::search_parameter_; 00087 using Feature<PointInT, PointOutT>::input_; 00088 using Feature<PointInT, PointOutT>::surface_; 00089 using FeatureFromNormals<PointInT, PointNT, PointOutT>::normals_; 00090 00091 typedef typename Feature<PointInT, PointOutT>::PointCloudOut PointCloudOut; 00092 00094 FPFHEstimation () : nr_bins_f1_ (11), nr_bins_f2_ (11), nr_bins_f3_ (11), d_pi_ ((float)(1.0 / (2.0 * M_PI))) 00095 { 00096 feature_name_ = "FPFHEstimation"; 00097 }; 00098 00112 bool 00113 computePairFeatures (const pcl::PointCloud<PointInT> &cloud, const pcl::PointCloud<PointNT> &normals, 00114 int p_idx, int q_idx, float &f1, float &f2, float &f3, float &f4); 00115 00127 void 00128 computePointSPFHSignature (const pcl::PointCloud<PointInT> &cloud, 00129 const pcl::PointCloud<PointNT> &normals, int p_idx, int row, 00130 const std::vector<int> &indices, 00131 Eigen::MatrixXf &hist_f1, Eigen::MatrixXf &hist_f2, Eigen::MatrixXf &hist_f3); 00132 00142 void 00143 weightPointSPFHSignature (const Eigen::MatrixXf &hist_f1, 00144 const Eigen::MatrixXf &hist_f2, 00145 const Eigen::MatrixXf &hist_f3, 00146 const std::vector<int> &indices, 00147 const std::vector<float> &dists, 00148 Eigen::VectorXf &fpfh_histogram); 00149 00155 inline void 00156 setNrSubdivisions (int nr_bins_f1, int nr_bins_f2, int nr_bins_f3) 00157 { 00158 nr_bins_f1_ = nr_bins_f1; 00159 nr_bins_f2_ = nr_bins_f2; 00160 nr_bins_f3_ = nr_bins_f3; 00161 } 00162 00168 inline void 00169 getNrSubdivisions (int &nr_bins_f1, int &nr_bins_f2, int &nr_bins_f3) 00170 { 00171 nr_bins_f1 = nr_bins_f1_; 00172 nr_bins_f2 = nr_bins_f2_; 00173 nr_bins_f3 = nr_bins_f3_; 00174 } 00175 00176 protected: 00177 00184 void 00185 computeSPFHSignatures (std::vector<int> &spf_hist_lookup, 00186 Eigen::MatrixXf &hist_f1, Eigen::MatrixXf &hist_f2, Eigen::MatrixXf &hist_f3); 00187 00193 void 00194 computeFeature (PointCloudOut &output); 00195 00197 int nr_bins_f1_, nr_bins_f2_, nr_bins_f3_; 00198 00200 Eigen::MatrixXf hist_f1_; 00201 00203 Eigen::MatrixXf hist_f2_; 00204 00206 Eigen::MatrixXf hist_f3_; 00207 00209 Eigen::VectorXf fpfh_histogram_; 00210 00212 float d_pi_; 00213 00214 private: 00218 void 00219 computeFeatureEigen (pcl::PointCloud<Eigen::MatrixXf> &output) {} 00220 }; 00221 00250 template <typename PointInT, typename PointNT> 00251 class FPFHEstimation<PointInT, PointNT, Eigen::MatrixXf> : public FPFHEstimation<PointInT, PointNT, pcl::FPFHSignature33> 00252 { 00253 public: 00254 using FPFHEstimation<PointInT, PointNT, pcl::FPFHSignature33>::k_; 00255 using FPFHEstimation<PointInT, PointNT, pcl::FPFHSignature33>::nr_bins_f1_; 00256 using FPFHEstimation<PointInT, PointNT, pcl::FPFHSignature33>::nr_bins_f2_; 00257 using FPFHEstimation<PointInT, PointNT, pcl::FPFHSignature33>::nr_bins_f3_; 00258 using FPFHEstimation<PointInT, PointNT, pcl::FPFHSignature33>::hist_f1_; 00259 using FPFHEstimation<PointInT, PointNT, pcl::FPFHSignature33>::hist_f2_; 00260 using FPFHEstimation<PointInT, PointNT, pcl::FPFHSignature33>::hist_f3_; 00261 using FPFHEstimation<PointInT, PointNT, pcl::FPFHSignature33>::indices_; 00262 using FPFHEstimation<PointInT, PointNT, pcl::FPFHSignature33>::search_parameter_; 00263 using FPFHEstimation<PointInT, PointNT, pcl::FPFHSignature33>::input_; 00264 using FPFHEstimation<PointInT, PointNT, pcl::FPFHSignature33>::compute; 00265 using FPFHEstimation<PointInT, PointNT, pcl::FPFHSignature33>::fpfh_histogram_; 00266 00267 private: 00273 void 00274 computeFeatureEigen (pcl::PointCloud<Eigen::MatrixXf> &output); 00275 00279 void 00280 compute (pcl::PointCloud<pcl::FPFHSignature33> &output) {} 00281 }; 00282 } 00283 00284 #endif //#ifndef PCL_FPFH_H_
1.8.0