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>
45 template <
typename Po
intInT,
typename Po
intNT,
typename Po
intOutT>
57 template <
typename Po
intInT,
typename Po
intNT,
typename Po
intOutT>
void
61 output.resize (indices_->size () * input_->size ());
63 output.width = output.size ();
66 for (std::size_t index_i = 0; index_i < indices_->size (); ++index_i)
68 std::size_t i = (*indices_)[index_i];
69 for (std::size_t j = 0 ; j < input_->size (); ++j)
75 ((*input_)[i].getVector4fMap (), (*normals_)[i].getNormalVector4fMap (), (*input_)[i].getRGBVector4i (),
76 (*input_)[j].getVector4fMap (), (*normals_)[j].getNormalVector4fMap (), (*input_)[j].getRGBVector4i (),
77 p.f1, p.f2, p.f3, p.f4, p.r_ratio, p.g_ratio, p.b_ratio))
80 Eigen::Vector3f model_reference_point = (*input_)[i].getVector3fMap (),
81 model_reference_normal = (*normals_)[i].getNormalVector3fMap (),
82 model_point = (*input_)[j].getVector3fMap ();
83 Eigen::AngleAxisf rotation_mg (std::acos (model_reference_normal.dot (Eigen::Vector3f::UnitX ())),
84 model_reference_normal.cross (Eigen::Vector3f::UnitX ()).normalized ());
85 Eigen::Affine3f transform_mg = Eigen::Translation3f ( rotation_mg * ((-1) * model_reference_point)) * rotation_mg;
87 Eigen::Vector3f model_point_transformed = transform_mg * model_point;
88 float angle = std::atan2 ( -model_point_transformed(2), model_point_transformed(1));
89 if (std::sin (angle) * model_point_transformed(2) < 0.0f)
95 PCL_ERROR (
"[pcl::%s::computeFeature] Computing pair feature vector between points %lu and %lu went wrong.\n", getClassName ().c_str (), i, j);
96 p.f1 = p.f2 = p.f3 = p.f4 = p.alpha_m = p.r_ratio = p.g_ratio = p.b_ratio = 0.f;
102 p.f1 = p.f2 = p.f3 = p.f4 = p.alpha_m = p.r_ratio = p.g_ratio = p.b_ratio = 0.f;
104 output[index_i*input_->size () + j] = p;
113 template <
typename Po
intInT,
typename Po
intNT,
typename Po
intOutT>
121 template <
typename Po
intInT,
typename Po
intNT,
typename Po
intOutT>
void
124 PCL_INFO (
"before computing output size: %u\n", output.size ());
125 output.resize (indices_->size ());
126 for (std::size_t index_i = 0; index_i < indices_->size (); ++index_i)
128 auto i = (*indices_)[index_i];
130 std::vector<float> nn_distances;
131 tree_->radiusSearch (i,
static_cast<float> (search_radius_), nn_indices, nn_distances);
133 PointOutT average_feature_nn;
134 average_feature_nn.alpha_m = 0;
135 average_feature_nn.f1 = average_feature_nn.f2 = average_feature_nn.f3 = average_feature_nn.f4 =
136 average_feature_nn.r_ratio = average_feature_nn.g_ratio = average_feature_nn.b_ratio = 0.0f;
138 for (
const auto &j : nn_indices)
142 float f1, f2, f3, f4, r_ratio, g_ratio, b_ratio;
144 ((*input_)[i].getVector4fMap (), (*normals_)[i].getNormalVector4fMap (), (*input_)[i].getRGBVector4i (),
145 (*input_)[j].getVector4fMap (), (*normals_)[j].getNormalVector4fMap (), (*input_)[j].getRGBVector4i (),
146 f1, f2, f3, f4, r_ratio, g_ratio, b_ratio))
148 average_feature_nn.f1 += f1;
149 average_feature_nn.f2 += f2;
150 average_feature_nn.f3 += f3;
151 average_feature_nn.f4 += f4;
152 average_feature_nn.r_ratio += r_ratio;
153 average_feature_nn.g_ratio += g_ratio;
154 average_feature_nn.b_ratio += b_ratio;
158 PCL_ERROR (
"[pcl::%s::computeFeature] Computing pair feature vector between points %lu and %lu went wrong.\n", getClassName ().c_str (), i, j);
163 float normalization_factor =
static_cast<float> (nn_indices.size ());
164 average_feature_nn.f1 /= normalization_factor;
165 average_feature_nn.f2 /= normalization_factor;
166 average_feature_nn.f3 /= normalization_factor;
167 average_feature_nn.f4 /= normalization_factor;
168 average_feature_nn.r_ratio /= normalization_factor;
169 average_feature_nn.g_ratio /= normalization_factor;
170 average_feature_nn.b_ratio /= normalization_factor;
171 output[index_i] = average_feature_nn;
173 PCL_INFO (
"Output size: %zu\n",
static_cast<std::size_t
>(output.size ()));
177 #define PCL_INSTANTIATE_PPFRGBEstimation(T,NT,OutT) template class PCL_EXPORTS pcl::PPFRGBEstimation<T,NT,OutT>;
178 #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.