40 #ifndef PCL_FEATURES_IMPL_PPF_H_
41 #define PCL_FEATURES_IMPL_PPF_H_
43 #include <pcl/features/ppf.h>
44 #include <pcl/features/pfh.h>
45 #include <pcl/features/pfh_tools.h>
46 #include <pcl/search/kdtree.h>
49 template <
typename Po
intInT,
typename Po
intNT,
typename Po
intOutT>
61 template <
typename Po
intInT,
typename Po
intNT,
typename Po
intOutT>
void
65 output.resize (indices_->size () * input_->size ());
67 output.width = output.size ();
68 output.is_dense =
true;
71 for (std::size_t index_i = 0; index_i < indices_->size (); ++index_i)
73 std::size_t i = (*indices_)[index_i];
74 for (std::size_t j = 0 ; j < input_->size (); ++j)
81 (*normals_)[i].getNormalVector4fMap (),
82 (*input_)[j].getVector4fMap (),
83 (*normals_)[j].getNormalVector4fMap (),
84 p.f1, p.f2, p.f3, p.f4))
87 Eigen::Vector3f model_reference_point = (*input_)[i].getVector3fMap (),
88 model_reference_normal = (*normals_)[i].getNormalVector3fMap (),
89 model_point = (*input_)[j].getVector3fMap ();
90 float rotation_angle = std::acos (model_reference_normal.dot (Eigen::Vector3f::UnitX ()));
91 bool parallel_to_x = (model_reference_normal.y() == 0.0f && model_reference_normal.z() == 0.0f);
92 Eigen::Vector3f rotation_axis = (parallel_to_x)?(Eigen::Vector3f::UnitY ()):(model_reference_normal.cross (Eigen::Vector3f::UnitX ()). normalized());
93 Eigen::AngleAxisf rotation_mg (rotation_angle, rotation_axis);
94 Eigen::Affine3f transform_mg (Eigen::Translation3f ( rotation_mg * ((-1) * model_reference_point)) * rotation_mg);
96 Eigen::Vector3f model_point_transformed = transform_mg * model_point;
97 float angle = std::atan2 ( -model_point_transformed(2), model_point_transformed(1));
98 if (std::sin (angle) * model_point_transformed(2) < 0.0f)
104 PCL_ERROR (
"[pcl::%s::computeFeature] Computing pair feature vector between points %u and %u went wrong.\n", getClassName ().c_str (), i, j);
105 p.f1 = p.f2 = p.f3 = p.f4 = p.alpha_m = std::numeric_limits<float>::quiet_NaN ();
106 output.is_dense =
false;
113 p.f1 = p.f2 = p.f3 = p.f4 = p.alpha_m = std::numeric_limits<float>::quiet_NaN ();
114 output.is_dense =
false;
117 output[index_i*input_->size () + j] = p;
122 #define PCL_INSTANTIATE_PPFEstimation(T,NT,OutT) template class PCL_EXPORTS pcl::PPFEstimation<T,NT,OutT>;
Feature represents the base feature class.
std::string feature_name_
The feature name.
Class that calculates the "surflet" features for each pair in the given pointcloud.
PPFEstimation()
Empty Constructor.
search::KdTree is a wrapper class which inherits the pcl::KdTree class for performing search function...
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...