38 #ifndef PCL_FEATURES_IMPL_PFHRGB_H_
39 #define PCL_FEATURES_IMPL_PFHRGB_H_
44 template <
typename Po
intInT,
typename Po
intNT,
typename Po
intOutT>
bool
48 float &f1,
float &f2,
float &f3,
float &f4,
float &f5,
float &f6,
float &f7)
50 Eigen::Vector4i colors1 (cloud.
points[p_idx].r, cloud.
points[p_idx].g, cloud.
points[p_idx].b, 0),
54 cloud.
points[q_idx].getVector4fMap (), normals.
points[q_idx].getNormalVector4fMap (),
56 f1, f2, f3, f4, f5, f6, f7);
61 template <
typename Po
intInT,
typename Po
intNT,
typename Po
intOutT>
void
64 const std::vector<int> &indices,
int nr_split, Eigen::VectorXf &pfhrgb_histogram)
69 pfhrgb_histogram.setZero ();
72 float hist_incr = 100.0f /
static_cast<float> (indices.size () * indices.size () - 1);
75 for (
size_t i_idx = 0; i_idx < indices.size (); ++i_idx)
77 for (
size_t j_idx = 0; j_idx < indices.size (); ++j_idx)
85 pfhrgb_tuple_[0], pfhrgb_tuple_[1], pfhrgb_tuple_[2], pfhrgb_tuple_[3],
86 pfhrgb_tuple_[4], pfhrgb_tuple_[5], pfhrgb_tuple_[6]))
90 f_index_[0] =
static_cast<int> (floor (nr_split * ((pfhrgb_tuple_[0] + M_PI) * d_pi_)));
91 if (f_index_[0] < 0) f_index_[0] = 0;
92 if (f_index_[0] >= nr_split) f_index_[0] = nr_split - 1;
94 f_index_[1] =
static_cast<int> (floor (nr_split * ((pfhrgb_tuple_[1] + 1.0) * 0.5)));
95 if (f_index_[1] < 0) f_index_[1] = 0;
96 if (f_index_[1] >= nr_split) f_index_[1] = nr_split - 1;
98 f_index_[2] =
static_cast<int> (floor (nr_split * ((pfhrgb_tuple_[2] + 1.0) * 0.5)));
99 if (f_index_[2] < 0) f_index_[2] = 0;
100 if (f_index_[2] >= nr_split) f_index_[2] = nr_split - 1;
103 f_index_[4] =
static_cast<int> (floor (nr_split * ((pfhrgb_tuple_[4] + 1.0) * 0.5)));
104 if (f_index_[4] < 0) f_index_[4] = 0;
105 if (f_index_[4] >= nr_split) f_index_[4] = nr_split - 1;
107 f_index_[5] =
static_cast<int> (floor (nr_split * ((pfhrgb_tuple_[5] + 1.0) * 0.5)));
108 if (f_index_[5] < 0) f_index_[5] = 0;
109 if (f_index_[5] >= nr_split) f_index_[5] = nr_split - 1;
111 f_index_[6] =
static_cast<int> (floor (nr_split * ((pfhrgb_tuple_[6] + 1.0) * 0.5)));
112 if (f_index_[6] < 0) f_index_[6] = 0;
113 if (f_index_[6] >= nr_split) f_index_[6] = nr_split - 1;
119 for (
int d = 0; d < 3; ++d)
121 h_index += h_p * f_index_[d];
124 pfhrgb_histogram[h_index] += hist_incr;
129 for (
int d = 4; d < 7; ++d)
131 h_index += h_p * f_index_[d];
134 pfhrgb_histogram[h_index] += hist_incr;
140 template <
typename Po
intInT,
typename Po
intNT,
typename Po
intOutT>
void
144 pfhrgb_histogram_.setZero (2 * nr_subdiv_ * nr_subdiv_ * nr_subdiv_);
145 pfhrgb_tuple_.setZero (7);
149 std::vector<int> nn_indices (k_);
150 std::vector<float> nn_dists (k_);
153 for (
size_t idx = 0; idx < indices_->size (); ++idx)
155 this->searchForNeighbors ((*indices_)[idx], search_parameter_, nn_indices, nn_dists);
158 computePointPFHRGBSignature (*surface_, *normals_, nn_indices, nr_subdiv_, pfhrgb_histogram_);
161 for (
int d = 0; d < pfhrgb_histogram_.size (); ++d) {
162 output.points[idx].histogram[d] = pfhrgb_histogram_[d];
169 #define PCL_INSTANTIATE_PFHRGBEstimation(T,NT,OutT) template class PCL_EXPORTS pcl::PFHRGBEstimation<T,NT,OutT>;