52 PCL_ERROR (
"[pcl::%s::initCompute] Init failed.\n", getClassName ().c_str ());
56 if (tangent_radius_ == 0.0f)
58 PCL_ERROR (
"[pcl::%s::initCompute] tangent_radius_ not set.\n", getClassName ().c_str ());
63 if (!sampled_surface_)
65 fake_sampled_surface_ =
true;
66 sampled_surface_ = surface_;
70 PCL_WARN (
"[pcl::%s::initCompute] sampled_surface_ is not set even if sampled_tree_ is already set.", getClassName ().c_str ());
71 PCL_WARN (
"sampled_tree_ will be rebuilt from surface_. Use sampled_surface_.\n");
81 if (sampled_tree_->getInputCloud () != sampled_surface_)
82 sampled_tree_->setInputCloud (sampled_surface_);
109 Eigen::Matrix3f &lrf)
111 Eigen::Vector3f x_axis, y_axis;
112 Eigen::Vector3f fitted_normal;
118 std::vector<float> neighbours_distances;
120 const std::size_t n_normal_neighbours =
121 this->searchForNeighbors (index, search_parameter_, neighbours_indices, neighbours_distances);
122 if (n_normal_neighbours <
static_cast<std::size_t
>(min_neighbors_for_normal_axis_))
128 lrf.setConstant (std::numeric_limits<float>::quiet_NaN ());
129 return (std::numeric_limits<SignedDistanceT>::max ());
133 fitted_normal = (*normals_)[index].getNormalVector3fMap ();
137 float plane_curvature;
138 normal_estimation_.computePointNormal (*surface_, neighbours_indices, fitted_normal (0), fitted_normal (1), fitted_normal (2), plane_curvature);
141 if (!pcl::flipNormalTowardsNormalsMean<PointNT> (*normals_, neighbours_indices, fitted_normal))
145 lrf.setConstant (std::numeric_limits<float>::quiet_NaN ());
146 return (std::numeric_limits<SignedDistanceT>::max ());
151 lrf.row (2).matrix () = fitted_normal;
156 const std::size_t n_tangent_neighbours =
157 sampled_tree_->radiusSearch ((*input_)[index], tangent_radius_, neighbours_indices, neighbours_distances);
159 if (n_tangent_neighbours <
static_cast<std::size_t
>(min_neighbors_for_tangent_axis_))
163 y_axis = fitted_normal.cross (x_axis);
165 lrf.row (0).matrix () = x_axis;
166 lrf.row (1).matrix () = y_axis;
168 return (std::numeric_limits<SignedDistanceT>::max ());
173 SignedDistanceT shape_score;
174 SignedDistanceT best_shape_score = -std::numeric_limits<SignedDistanceT>::max ();
175 int best_shape_index = -1;
177 const float radius2 = tangent_radius_ * tangent_radius_;
178 const float margin_distance2 = margin_thresh_ * margin_thresh_ * radius2;
182 for (std::size_t curr_neigh = 0; curr_neigh < n_tangent_neighbours; ++curr_neigh)
184 const int& curr_neigh_idx = neighbours_indices[curr_neigh];
185 const float& neigh_distance_sqr = neighbours_distances[curr_neigh];
187 if (neigh_distance_sqr <= margin_distance2)
194 shape_score = fitted_normal.dot ((*sampled_surface_)[curr_neigh_idx].getVector3fMap ());
196 if (shape_score > best_shape_score)
198 best_shape_index = curr_neigh_idx;
199 best_shape_score = shape_score;
203 if (best_shape_index == -1)
206 y_axis = fitted_normal.cross (x_axis);
208 lrf.row (0).matrix () = x_axis;
209 lrf.row (1).matrix () = y_axis;
211 return (std::numeric_limits<SignedDistanceT>::max ());
217 y_axis = fitted_normal.cross (x_axis);
219 lrf.row (0).matrix () = x_axis;
220 lrf.row (1).matrix () = y_axis;
223 best_shape_score -= fitted_normal.dot (feature_point);
224 return (best_shape_score);
232 if (this->getKSearch () != 0)
235 "[pcl::%s::computeFeature] Error! Search method set to k-neighborhood. Call setKSearch (0) and setRadiusSearch (radius) to use this class.\n",
236 getClassName ().c_str ());
240 signed_distances_from_highest_points_.resize (indices_->size ());
242 for (std::size_t point_idx = 0; point_idx < indices_->size (); ++point_idx)
244 Eigen::Matrix3f currentLrf;
245 PointOutT &rf = output[point_idx];
247 signed_distances_from_highest_points_[point_idx] = computePointLRF ((*indices_)[point_idx], currentLrf);
248 if (signed_distances_from_highest_points_[point_idx] == std::numeric_limits<SignedDistanceT>::max ())
250 output.is_dense =
false;
253 rf.getXAxisVector3fMap () = currentLrf.row (0);
254 rf.getYAxisVector3fMap () = currentLrf.row (1);
255 rf.getZAxisVector3fMap () = currentLrf.row (2);