38 #ifndef PCL_FEATURES_IMPL_PPFRGB_H_
39 #define PCL_FEATURES_IMPL_PPFRGB_H_
41 #include <pcl/features/ppfrgb.h>
42 #include <pcl/features/pfhrgb.h>
43 #include <pcl/search/kdtree.h>
46 template <
typename Po
intInT,
typename Po
intNT,
typename Po
intOutT>
58 template <
typename Po
intInT,
typename Po
intNT,
typename Po
intOutT>
void
62 output.resize (indices_->size () * input_->size ());
64 output.width = output.size ();
67 for (std::size_t index_i = 0; index_i < indices_->size (); ++index_i)
69 std::size_t i = (*indices_)[index_i];
70 for (std::size_t j = 0 ; j < input_->size (); ++j)
76 ((*input_)[i].getVector4fMap (), (*normals_)[i].getNormalVector4fMap (), (*input_)[i].getRGBVector4i (),
77 (*input_)[j].getVector4fMap (), (*normals_)[j].getNormalVector4fMap (), (*input_)[j].getRGBVector4i (),
78 p.f1, p.f2, p.f3, p.f4, p.r_ratio, p.g_ratio, p.b_ratio))
81 Eigen::Vector3f model_reference_point = (*input_)[i].getVector3fMap (),
82 model_reference_normal = (*normals_)[i].getNormalVector3fMap (),
83 model_point = (*input_)[j].getVector3fMap ();
84 Eigen::AngleAxisf rotation_mg (std::acos (model_reference_normal.dot (Eigen::Vector3f::UnitX ())),
85 model_reference_normal.cross (Eigen::Vector3f::UnitX ()).normalized ());
86 Eigen::Affine3f transform_mg = Eigen::Translation3f ( rotation_mg * ((-1) * model_reference_point)) * rotation_mg;
88 Eigen::Vector3f model_point_transformed = transform_mg * model_point;
89 float angle = std::atan2 ( -model_point_transformed(2), model_point_transformed(1));
90 if (std::sin (angle) * model_point_transformed(2) < 0.0f)
96 PCL_ERROR (
"[pcl::%s::computeFeature] Computing pair feature vector between points %lu and %lu went wrong.\n", getClassName ().c_str (), i, j);
97 p.f1 = p.f2 = p.f3 = p.f4 = p.alpha_m = p.r_ratio = p.g_ratio = p.b_ratio = 0.f;
103 p.f1 = p.f2 = p.f3 = p.f4 = p.alpha_m = p.r_ratio = p.g_ratio = p.b_ratio = 0.f;
105 output[index_i*input_->size () + j] = p;
114 template <
typename Po
intInT,
typename Po
intNT,
typename Po
intOutT>
122 template <
typename Po
intInT,
typename Po
intNT,
typename Po
intOutT>
void
125 PCL_INFO (
"before computing output size: %u\n", output.size ());
126 output.resize (indices_->size ());
127 for (std::size_t index_i = 0; index_i < indices_->size (); ++index_i)
129 auto i = (*indices_)[index_i];
131 std::vector<float> nn_distances;
132 tree_->radiusSearch (i,
static_cast<float> (search_radius_), nn_indices, nn_distances);
134 PointOutT average_feature_nn;
135 average_feature_nn.alpha_m = 0;
136 average_feature_nn.f1 = average_feature_nn.f2 = average_feature_nn.f3 = average_feature_nn.f4 =
137 average_feature_nn.r_ratio = average_feature_nn.g_ratio = average_feature_nn.b_ratio = 0.0f;
139 for (
const auto &j : nn_indices)
143 float f1, f2, f3, f4, r_ratio, g_ratio, b_ratio;
145 ((*input_)[i].getVector4fMap (), (*normals_)[i].getNormalVector4fMap (), (*input_)[i].getRGBVector4i (),
146 (*input_)[j].getVector4fMap (), (*normals_)[j].getNormalVector4fMap (), (*input_)[j].getRGBVector4i (),
147 f1, f2, f3, f4, r_ratio, g_ratio, b_ratio))
149 average_feature_nn.f1 += f1;
150 average_feature_nn.f2 += f2;
151 average_feature_nn.f3 += f3;
152 average_feature_nn.f4 += f4;
153 average_feature_nn.r_ratio += r_ratio;
154 average_feature_nn.g_ratio += g_ratio;
155 average_feature_nn.b_ratio += b_ratio;
159 PCL_ERROR (
"[pcl::%s::computeFeature] Computing pair feature vector between points %lu and %lu went wrong.\n", getClassName ().c_str (), i, j);
164 float normalization_factor =
static_cast<float> (nn_indices.size ());
165 average_feature_nn.f1 /= normalization_factor;
166 average_feature_nn.f2 /= normalization_factor;
167 average_feature_nn.f3 /= normalization_factor;
168 average_feature_nn.f4 /= normalization_factor;
169 average_feature_nn.r_ratio /= normalization_factor;
170 average_feature_nn.g_ratio /= normalization_factor;
171 average_feature_nn.b_ratio /= normalization_factor;
172 output[index_i] = average_feature_nn;
174 PCL_INFO (
"Output size: %zu\n",
static_cast<std::size_t
>(output.size ()));
178 #define PCL_INSTANTIATE_PPFRGBEstimation(T,NT,OutT) template class PCL_EXPORTS pcl::PPFRGBEstimation<T,NT,OutT>;
179 #define PCL_INSTANTIATE_PPFRGBRegionEstimation(T,NT,OutT) template class PCL_EXPORTS pcl::PPFRGBRegionEstimation<T,NT,OutT>;
Feature represents the base feature class.
std::string feature_name_
The feature name.
PPFRGBEstimation()
Empty Constructor.
search::KdTree is a wrapper class which inherits the pcl::KdTree class for performing search function...
PCL_EXPORTS bool computeRGBPairFeatures(const Eigen::Vector4f &p1, const Eigen::Vector4f &n1, const Eigen::Vector4i &colors1, const Eigen::Vector4f &p2, const Eigen::Vector4f &n2, const Eigen::Vector4i &colors2, float &f1, float &f2, float &f3, float &f4, float &f5, float &f6, float &f7)
IndicesAllocator<> Indices
Type used for indices in PCL.