40 #ifndef PCL_FEATURES_IMPL_MOMENT_INVARIANTS_H_
41 #define PCL_FEATURES_IMPL_MOMENT_INVARIANTS_H_
46 template <
typename Po
intInT,
typename Po
intOutT>
void
49 float &j1,
float &j2,
float &j3)
55 float mu200 = 0, mu020 = 0, mu002 = 0, mu110 = 0, mu101 = 0, mu011 = 0;
58 for (
size_t nn_idx = 0; nn_idx < indices.size (); ++nn_idx)
61 temp_pt_[0] = cloud.
points[indices[nn_idx]].x - xyz_centroid_[0];
62 temp_pt_[1] = cloud.
points[indices[nn_idx]].y - xyz_centroid_[1];
63 temp_pt_[2] = cloud.
points[indices[nn_idx]].z - xyz_centroid_[2];
65 mu200 += temp_pt_[0] * temp_pt_[0];
66 mu020 += temp_pt_[1] * temp_pt_[1];
67 mu002 += temp_pt_[2] * temp_pt_[2];
68 mu110 += temp_pt_[0] * temp_pt_[1];
69 mu101 += temp_pt_[0] * temp_pt_[2];
70 mu011 += temp_pt_[1] * temp_pt_[2];
74 j1 = mu200 + mu020 + mu002;
75 j2 = mu200*mu020 + mu200*mu002 + mu020*mu002 - mu110*mu110 - mu101*mu101 - mu011*mu011;
76 j3 = mu200*mu020*mu002 + 2*mu110*mu101*mu011 - mu002*mu110*mu110 - mu020*mu101*mu101 - mu200*mu011*mu011;
80 template <
typename Po
intInT,
typename Po
intOutT>
void
88 float mu200 = 0, mu020 = 0, mu002 = 0, mu110 = 0, mu101 = 0, mu011 = 0;
91 for (
size_t nn_idx = 0; nn_idx < cloud.
points.size (); ++nn_idx )
94 temp_pt_[0] = cloud.
points[nn_idx].x - xyz_centroid_[0];
95 temp_pt_[1] = cloud.
points[nn_idx].y - xyz_centroid_[1];
96 temp_pt_[2] = cloud.
points[nn_idx].z - xyz_centroid_[2];
98 mu200 += temp_pt_[0] * temp_pt_[0];
99 mu020 += temp_pt_[1] * temp_pt_[1];
100 mu002 += temp_pt_[2] * temp_pt_[2];
101 mu110 += temp_pt_[0] * temp_pt_[1];
102 mu101 += temp_pt_[0] * temp_pt_[2];
103 mu011 += temp_pt_[1] * temp_pt_[2];
107 j1 = mu200 + mu020 + mu002;
108 j2 = mu200*mu020 + mu200*mu002 + mu020*mu002 - mu110*mu110 - mu101*mu101 - mu011*mu011;
109 j3 = mu200*mu020*mu002 + 2*mu110*mu101*mu011 - mu002*mu110*mu110 - mu020*mu101*mu101 - mu200*mu011*mu011;
113 template <
typename Po
intInT,
typename Po
intOutT>
void
118 std::vector<int> nn_indices (k_);
119 std::vector<float> nn_dists (k_);
121 output.is_dense =
true;
123 if (input_->is_dense)
126 for (
size_t idx = 0; idx < indices_->size (); ++idx)
128 if (this->searchForNeighbors ((*indices_)[idx], search_parameter_, nn_indices, nn_dists) == 0)
130 output.points[idx].j1 = output.points[idx].j2 = output.points[idx].j3 = std::numeric_limits<float>::quiet_NaN ();
131 output.is_dense =
false;
135 computePointMomentInvariants (*surface_, nn_indices,
136 output.points[idx].j1, output.points[idx].j2, output.points[idx].j3);
142 for (
size_t idx = 0; idx < indices_->size (); ++idx)
144 if (!
isFinite ((*input_)[(*indices_)[idx]]) ||
145 this->searchForNeighbors ((*indices_)[idx], search_parameter_, nn_indices, nn_dists) == 0)
147 output.points[idx].j1 = output.points[idx].j2 = output.points[idx].j3 = std::numeric_limits<float>::quiet_NaN ();
148 output.is_dense =
false;
152 computePointMomentInvariants (*surface_, nn_indices,
153 output.points[idx].j1, output.points[idx].j2, output.points[idx].j3);
159 template <
typename Po
intInT>
void
163 output.
points.resize (indices_->size (), 3);
167 std::vector<int> nn_indices (k_);
168 std::vector<float> nn_dists (k_);
172 if (input_->is_dense)
175 for (
size_t idx = 0; idx < indices_->size (); ++idx)
177 if (this->searchForNeighbors ((*indices_)[idx], search_parameter_, nn_indices, nn_dists) == 0)
179 output.
points (idx, 0) = output.
points (idx, 1) = output.
points (idx, 2) = std::numeric_limits<float>::quiet_NaN ();
191 for (
size_t idx = 0; idx < indices_->size (); ++idx)
193 if (!
isFinite ((*input_)[(*indices_)[idx]]) ||
194 this->searchForNeighbors ((*indices_)[idx], search_parameter_, nn_indices, nn_dists) == 0)
196 output.
points (idx, 0) = output.
points (idx, 1) = output.
points (idx, 2) = std::numeric_limits<float>::quiet_NaN ();
208 #define PCL_INSTANTIATE_MomentInvariantsEstimation(T,NT) template class PCL_EXPORTS pcl::MomentInvariantsEstimation<T,NT>;
210 #endif // PCL_FEATURES_IMPL_MOMENT_INVARIANTS_H_