43#include <pcl/features/fpfh.h>
45#include <pcl/common/point_tests.h>
46#include <pcl/features/pfh_tools.h>
51template <
typename Po
intInT,
typename Po
intNT,
typename Po
intOutT>
bool
54 int p_idx,
int q_idx,
float &f1,
float &f2,
float &f3,
float &f4)
63template <
typename Po
intInT,
typename Po
intNT,
typename Po
intOutT>
void
77 float hist_incr = 100.0f /
static_cast<float>(indices.size () - 1);
80 for (
const auto &index : indices)
109template <
typename Po
intInT,
typename Po
intNT,
typename Po
intOutT>
void
114 assert (indices.size () == dists.size ());
129 for (std::size_t idx = 0; idx < indices.size (); ++idx)
136 weight = 1.0f / dists[idx];
162 sum_f1 = 100.0 / sum_f1;
164 sum_f2 = 100.0 / sum_f2;
166 sum_f3 = 100.0 / sum_f3;
169 const auto denormalize_with = [](
auto factor)
171 return [=](
const auto& data) {
return data * factor; };
174 auto last = fpfh_histogram.data ();
175 last = std::transform(last, last + nr_bins_f1, last, denormalize_with (sum_f1));
176 last = std::transform(last, last + nr_bins_f2, last, denormalize_with (sum_f2));
177 std::transform(last, last + nr_bins_f3, last, denormalize_with (sum_f3));
181template <
typename Po
intInT,
typename Po
intNT,
typename Po
intOutT>
void
195 if (surface_ != input_ ||
196 indices_->size () != surface_->size ())
198 for (
const auto&
p_idx: *indices_)
209 for (std::size_t idx = 0; idx < indices_->size (); ++idx)
214 std::size_t data_size = spfh_indices.
size ();
215 hist_f1.setZero (data_size, nr_bins_f1_);
216 hist_f2.setZero (data_size, nr_bins_f2_);
217 hist_f3.setZero (data_size, nr_bins_f3_);
221 for (
const auto& p_idx: spfh_indices)
224 if (this->searchForNeighbors (*surface_, p_idx, search_parameter_, nn_indices, nn_dists) == 0)
228 computePointSPFHSignature (*surface_, *normals_, p_idx, i, nn_indices, hist_f1, hist_f2, hist_f3);
231 spfh_hist_lookup[p_idx] = i;
237template <
typename Po
intInT,
typename Po
intNT,
typename Po
intOutT>
void
250 if (input_->is_dense)
253 for (std::size_t idx = 0; idx < indices_->size (); ++idx)
255 if (this->searchForNeighbors ((*indices_)[idx], search_parameter_,
nn_indices,
nn_dists) == 0)
257 for (Eigen::Index d = 0; d < fpfh_histogram_.size (); ++d)
258 output[idx].histogram[d] = std::numeric_limits<float>::quiet_NaN ();
270 weightPointSPFHSignature (hist_f1_, hist_f2_, hist_f3_,
nn_indices,
nn_dists, fpfh_histogram_);
273 std::copy_n(fpfh_histogram_.data (), fpfh_histogram_.size (),
output[idx].histogram);
279 for (std::size_t idx = 0; idx < indices_->size (); ++idx)
281 if (!
isFinite ((*input_)[(*indices_)[idx]]) ||
282 this->searchForNeighbors ((*indices_)[idx], search_parameter_,
nn_indices,
nn_dists) == 0)
284 for (Eigen::Index d = 0; d < fpfh_histogram_.size (); ++d)
285 output[idx].histogram[d] = std::numeric_limits<float>::quiet_NaN ();
297 weightPointSPFHSignature (hist_f1_, hist_f2_, hist_f3_,
nn_indices,
nn_dists, fpfh_histogram_);
300 std::copy_n(fpfh_histogram_.data (), fpfh_histogram_.size (),
output[idx].histogram);
305#define PCL_INSTANTIATE_FPFHEstimation(T,NT,OutT) template class PCL_EXPORTS pcl::FPFHEstimation<T,NT,OutT>;
Iterator class for point clouds with or without given indices.
std::size_t size() const
Size of the range the iterator is going through.
typename Feature< PointInT, PointOutT >::PointCloudOut PointCloudOut
void computeSPFHSignatures(std::vector< int > &spf_hist_lookup, Eigen::MatrixXf &hist_f1, Eigen::MatrixXf &hist_f2, Eigen::MatrixXf &hist_f3)
Estimate the set of all SPFH (Simple Point Feature Histograms) signatures for the input cloud.
void computePointSPFHSignature(const pcl::PointCloud< PointInT > &cloud, const pcl::PointCloud< PointNT > &normals, pcl::index_t p_idx, int row, const pcl::Indices &indices, Eigen::MatrixXf &hist_f1, Eigen::MatrixXf &hist_f2, Eigen::MatrixXf &hist_f3)
Estimate the SPFH (Simple Point Feature Histograms) individual signatures of the three angular (f1,...
void computeFeature(PointCloudOut &output) override
Estimate the Fast Point Feature Histograms (FPFH) descriptors at a set of points given by <setInputCl...
bool computePairFeatures(const pcl::PointCloud< PointInT > &cloud, const pcl::PointCloud< PointNT > &normals, int p_idx, int q_idx, float &f1, float &f2, float &f3, float &f4)
Compute the 4-tuple representation containing the three angles and one distance between two points re...
void weightPointSPFHSignature(const Eigen::MatrixXf &hist_f1, const Eigen::MatrixXf &hist_f2, const Eigen::MatrixXf &hist_f3, const pcl::Indices &indices, const std::vector< float > &dists, Eigen::VectorXf &fpfh_histogram)
Weight the SPFH (Simple Point Feature Histograms) individual histograms to create the final FPFH (Fas...
PCL_EXPORTS bool computePairFeatures(const Eigen::Vector4f &p1, const Eigen::Vector4f &n1, const Eigen::Vector4f &p2, const Eigen::Vector4f &n2, float &f1, float &f2, float &f3, float &f4)
Compute the 4-tuple representation containing the three angles and one distance between two points re...
bool isFinite(const PointT &pt)
Tests if the 3D components of a point are all finite param[in] pt point to be tested return true if f...
detail::int_type_t< detail::index_type_size, detail::index_type_signed > index_t
Type used for an index in PCL.
IndicesAllocator<> Indices
Type used for indices in PCL.