Point Cloud Library (PCL)  1.11.1-dev
sac_model_sphere.hpp
1 /*
2  * Software License Agreement (BSD License)
3  *
4  * Point Cloud Library (PCL) - www.pointclouds.org
5  * Copyright (c) 2009, Willow Garage, Inc.
6  * Copyright (c) 2012-, Open Perception, Inc.
7  *
8  * All rights reserved.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  *
14  * * Redistributions of source code must retain the above copyright
15  * notice, this list of conditions and the following disclaimer.
16  * * Redistributions in binary form must reproduce the above
17  * copyright notice, this list of conditions and the following
18  * disclaimer in the documentation and/or other materials provided
19  * with the distribution.
20  * * Neither the name of the copyright holder(s) nor the names of its
21  * contributors may be used to endorse or promote products derived
22  * from this software without specific prior written permission.
23  *
24  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
27  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
28  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
29  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
30  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
31  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
32  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
34  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35  * POSSIBILITY OF SUCH DAMAGE.
36  *
37  * $Id$
38  *
39  */
40 
41 #ifndef PCL_SAMPLE_CONSENSUS_IMPL_SAC_MODEL_SPHERE_H_
42 #define PCL_SAMPLE_CONSENSUS_IMPL_SAC_MODEL_SPHERE_H_
43 
44 #include <pcl/sample_consensus/eigen.h>
45 #include <pcl/sample_consensus/sac_model_sphere.h>
46 
47 //////////////////////////////////////////////////////////////////////////
48 template <typename PointT> bool
50 {
51  if (samples.size () != sample_size_)
52  {
53  PCL_ERROR ("[pcl::SampleConsensusModelSphere::isSampleGood] Wrong number of samples (is %lu, should be %lu)!\n", samples.size (), sample_size_);
54  return (false);
55  }
56  return (true);
57 }
58 
59 //////////////////////////////////////////////////////////////////////////
60 template <typename PointT> bool
62  const Indices &samples, Eigen::VectorXf &model_coefficients) const
63 {
64  // Need 4 samples
65  if (samples.size () != sample_size_)
66  {
67  PCL_ERROR ("[pcl::SampleConsensusModelSphere::computeModelCoefficients] Invalid set of samples given (%lu)!\n", samples.size ());
68  return (false);
69  }
70 
71  Eigen::Matrix4f temp;
72  for (int i = 0; i < 4; i++)
73  {
74  temp (i, 0) = (*input_)[samples[i]].x;
75  temp (i, 1) = (*input_)[samples[i]].y;
76  temp (i, 2) = (*input_)[samples[i]].z;
77  temp (i, 3) = 1;
78  }
79  float m11 = temp.determinant ();
80  if (m11 == 0)
81  {
82  return (false); // the points don't define a sphere!
83  }
84 
85  for (int i = 0; i < 4; ++i)
86  {
87  temp (i, 0) = ((*input_)[samples[i]].x) * ((*input_)[samples[i]].x) +
88  ((*input_)[samples[i]].y) * ((*input_)[samples[i]].y) +
89  ((*input_)[samples[i]].z) * ((*input_)[samples[i]].z);
90  }
91  float m12 = temp.determinant ();
92 
93  for (int i = 0; i < 4; ++i)
94  {
95  temp (i, 1) = temp (i, 0);
96  temp (i, 0) = (*input_)[samples[i]].x;
97  }
98  float m13 = temp.determinant ();
99 
100  for (int i = 0; i < 4; ++i)
101  {
102  temp (i, 2) = temp (i, 1);
103  temp (i, 1) = (*input_)[samples[i]].y;
104  }
105  float m14 = temp.determinant ();
106 
107  for (int i = 0; i < 4; ++i)
108  {
109  temp (i, 0) = temp (i, 2);
110  temp (i, 1) = (*input_)[samples[i]].x;
111  temp (i, 2) = (*input_)[samples[i]].y;
112  temp (i, 3) = (*input_)[samples[i]].z;
113  }
114  float m15 = temp.determinant ();
115 
116  // Center (x , y, z)
117  model_coefficients.resize (model_size_);
118  model_coefficients[0] = 0.5f * m12 / m11;
119  model_coefficients[1] = 0.5f * m13 / m11;
120  model_coefficients[2] = 0.5f * m14 / m11;
121  // Radius
122  model_coefficients[3] = std::sqrt (model_coefficients[0] * model_coefficients[0] +
123  model_coefficients[1] * model_coefficients[1] +
124  model_coefficients[2] * model_coefficients[2] - m15 / m11);
125 
126  return (true);
127 }
128 
129 #define AT(POS) ((*input_)[(*indices_)[(POS)]])
130 
131 #ifdef __AVX__
132 // This function computes the squared distances (i.e. the distances without the square root) of 8 points to the center of the sphere
133 template <typename PointT> inline __m256 pcl::SampleConsensusModelSphere<PointT>::sqr_dist8 (const std::size_t i, const __m256 a_vec, const __m256 b_vec, const __m256 c_vec) const
134 {
135  const __m256 tmp1 = _mm256_sub_ps (_mm256_set_ps (AT(i ).x, AT(i+1).x, AT(i+2).x, AT(i+3).x, AT(i+4).x, AT(i+5).x, AT(i+6).x, AT(i+7).x), a_vec);
136  const __m256 tmp2 = _mm256_sub_ps (_mm256_set_ps (AT(i ).y, AT(i+1).y, AT(i+2).y, AT(i+3).y, AT(i+4).y, AT(i+5).y, AT(i+6).y, AT(i+7).y), b_vec);
137  const __m256 tmp3 = _mm256_sub_ps (_mm256_set_ps (AT(i ).z, AT(i+1).z, AT(i+2).z, AT(i+3).z, AT(i+4).z, AT(i+5).z, AT(i+6).z, AT(i+7).z), c_vec);
138  return _mm256_add_ps (_mm256_add_ps (_mm256_mul_ps (tmp1, tmp1), _mm256_mul_ps (tmp2, tmp2)), _mm256_mul_ps(tmp3, tmp3));
139 }
140 #endif // ifdef __AVX__
141 
142 #ifdef __SSE__
143 // This function computes the squared distances (i.e. the distances without the square root) of 4 points to the center of the sphere
144 template <typename PointT> inline __m128 pcl::SampleConsensusModelSphere<PointT>::sqr_dist4 (const std::size_t i, const __m128 a_vec, const __m128 b_vec, const __m128 c_vec) const
145 {
146  const __m128 tmp1 = _mm_sub_ps (_mm_set_ps (AT(i ).x, AT(i+1).x, AT(i+2).x, AT(i+3).x), a_vec);
147  const __m128 tmp2 = _mm_sub_ps (_mm_set_ps (AT(i ).y, AT(i+1).y, AT(i+2).y, AT(i+3).y), b_vec);
148  const __m128 tmp3 = _mm_sub_ps (_mm_set_ps (AT(i ).z, AT(i+1).z, AT(i+2).z, AT(i+3).z), c_vec);
149  return _mm_add_ps (_mm_add_ps (_mm_mul_ps (tmp1, tmp1), _mm_mul_ps (tmp2, tmp2)), _mm_mul_ps(tmp3, tmp3));
150 }
151 #endif // ifdef __SSE__
152 
153 #undef AT
154 
155 //////////////////////////////////////////////////////////////////////////
156 template <typename PointT> void
158  const Eigen::VectorXf &model_coefficients, std::vector<double> &distances) const
159 {
160  // Check if the model is valid given the user constraints
161  if (!isModelValid (model_coefficients))
162  {
163  distances.clear ();
164  return;
165  }
166  distances.resize (indices_->size ());
167 
168  // Iterate through the 3d points and calculate the distances from them to the sphere
169  for (std::size_t i = 0; i < indices_->size (); ++i)
170  {
171  // Calculate the distance from the point to the sphere as the difference between
172  //dist(point,sphere_origin) and sphere_radius
173  distances[i] = std::abs (std::sqrt (
174  ( (*input_)[(*indices_)[i]].x - model_coefficients[0] ) *
175  ( (*input_)[(*indices_)[i]].x - model_coefficients[0] ) +
176 
177  ( (*input_)[(*indices_)[i]].y - model_coefficients[1] ) *
178  ( (*input_)[(*indices_)[i]].y - model_coefficients[1] ) +
179 
180  ( (*input_)[(*indices_)[i]].z - model_coefficients[2] ) *
181  ( (*input_)[(*indices_)[i]].z - model_coefficients[2] )
182  ) - model_coefficients[3]);
183  }
184 }
185 
186 //////////////////////////////////////////////////////////////////////////
187 template <typename PointT> void
189  const Eigen::VectorXf &model_coefficients, const double threshold, Indices &inliers)
190 {
191  // Check if the model is valid given the user constraints
192  if (!isModelValid (model_coefficients))
193  {
194  inliers.clear ();
195  return;
196  }
197 
198  inliers.clear ();
199  error_sqr_dists_.clear ();
200  inliers.reserve (indices_->size ());
201  error_sqr_dists_.reserve (indices_->size ());
202 
203  // Iterate through the 3d points and calculate the distances from them to the sphere
204  for (std::size_t i = 0; i < indices_->size (); ++i)
205  {
206  double distance = std::abs (std::sqrt (
207  ( (*input_)[(*indices_)[i]].x - model_coefficients[0] ) *
208  ( (*input_)[(*indices_)[i]].x - model_coefficients[0] ) +
209 
210  ( (*input_)[(*indices_)[i]].y - model_coefficients[1] ) *
211  ( (*input_)[(*indices_)[i]].y - model_coefficients[1] ) +
212 
213  ( (*input_)[(*indices_)[i]].z - model_coefficients[2] ) *
214  ( (*input_)[(*indices_)[i]].z - model_coefficients[2] )
215  ) - model_coefficients[3]);
216  // Calculate the distance from the point to the sphere as the difference between
217  // dist(point,sphere_origin) and sphere_radius
218  if (distance < threshold)
219  {
220  // Returns the indices of the points whose distances are smaller than the threshold
221  inliers.push_back ((*indices_)[i]);
222  error_sqr_dists_.push_back (static_cast<double> (distance));
223  }
224  }
225 }
226 
227 //////////////////////////////////////////////////////////////////////////
228 template <typename PointT> std::size_t
230  const Eigen::VectorXf &model_coefficients, const double threshold) const
231 {
232  // Check if the model is valid given the user constraints
233  if (!isModelValid (model_coefficients))
234  return (0);
235 
236 #if defined (__AVX__) && defined (__AVX2__)
237  return countWithinDistanceAVX (model_coefficients, threshold);
238 #elif defined (__SSE__) && defined (__SSE2__) && defined (__SSE4_1__)
239  return countWithinDistanceSSE (model_coefficients, threshold);
240 #else
241  return countWithinDistanceStandard (model_coefficients, threshold);
242 #endif
243 }
244 
245 //////////////////////////////////////////////////////////////////////////
246 template <typename PointT> std::size_t
248  const Eigen::VectorXf &model_coefficients, const double threshold, std::size_t i) const
249 {
250  std::size_t nr_p = 0;
251  // Iterate through the 3d points and calculate the distances from them to the sphere
252  for (; i < indices_->size (); ++i)
253  {
254  // Calculate the distance from the point to the sphere as the difference between
255  // dist(point,sphere_origin) and sphere_radius
256  if (std::abs (std::sqrt (
257  ( (*input_)[(*indices_)[i]].x - model_coefficients[0] ) *
258  ( (*input_)[(*indices_)[i]].x - model_coefficients[0] ) +
259 
260  ( (*input_)[(*indices_)[i]].y - model_coefficients[1] ) *
261  ( (*input_)[(*indices_)[i]].y - model_coefficients[1] ) +
262 
263  ( (*input_)[(*indices_)[i]].z - model_coefficients[2] ) *
264  ( (*input_)[(*indices_)[i]].z - model_coefficients[2] )
265  ) - model_coefficients[3]) < threshold)
266  nr_p++;
267  }
268  return (nr_p);
269 }
270 
271 //////////////////////////////////////////////////////////////////////////
272 #if defined (__SSE__) && defined (__SSE2__) && defined (__SSE4_1__)
273 template <typename PointT> std::size_t
275  const Eigen::VectorXf &model_coefficients, const double threshold, std::size_t i) const
276 {
277  std::size_t nr_p = 0;
278  const __m128 a_vec = _mm_set1_ps (model_coefficients[0]);
279  const __m128 b_vec = _mm_set1_ps (model_coefficients[1]);
280  const __m128 c_vec = _mm_set1_ps (model_coefficients[2]);
281  // To avoid sqrt computation: consider one larger sphere (radius + threshold) and one smaller sphere (radius - threshold). Valid if point is in larger sphere, but not in smaller sphere.
282  const __m128 sqr_inner_sphere = _mm_set1_ps ((model_coefficients[3] <= threshold ? 0.0 : (model_coefficients[3]-threshold)*(model_coefficients[3]-threshold)));
283  const __m128 sqr_outer_sphere = _mm_set1_ps ((model_coefficients[3]+threshold)*(model_coefficients[3]+threshold));
284  __m128i res = _mm_set1_epi32(0); // This corresponds to nr_p: 4 32bit integers that, summed together, hold the number of inliers
285  for (; (i + 4) <= indices_->size (); i += 4)
286  {
287  const __m128 sqr_dist = sqr_dist4 (i, a_vec, b_vec, c_vec);
288  const __m128 mask = _mm_and_ps (_mm_cmplt_ps (sqr_inner_sphere, sqr_dist), _mm_cmplt_ps (sqr_dist, sqr_outer_sphere)); // The mask contains 1 bits if the corresponding points are inliers, else 0 bits
289  res = _mm_add_epi32 (res, _mm_and_si128 (_mm_set1_epi32 (1), _mm_castps_si128 (mask))); // The latter part creates a vector with ones (as 32bit integers) where the points are inliers
290  //const int res = _mm_movemask_ps (mask);
291  //if (res & 1) nr_p++;
292  //if (res & 2) nr_p++;
293  //if (res & 4) nr_p++;
294  //if (res & 8) nr_p++;
295  }
296  nr_p += _mm_extract_epi32 (res, 0);
297  nr_p += _mm_extract_epi32 (res, 1);
298  nr_p += _mm_extract_epi32 (res, 2);
299  nr_p += _mm_extract_epi32 (res, 3);
300 
301  // Process the remaining points (at most 3)
302  nr_p += countWithinDistanceStandard (model_coefficients, threshold, i);
303  return (nr_p);
304 }
305 #endif
306 
307 //////////////////////////////////////////////////////////////////////////
308 #if defined (__AVX__) && defined (__AVX2__)
309 template <typename PointT> std::size_t
311  const Eigen::VectorXf &model_coefficients, const double threshold, std::size_t i) const
312 {
313  std::size_t nr_p = 0;
314  const __m256 a_vec = _mm256_set1_ps (model_coefficients[0]);
315  const __m256 b_vec = _mm256_set1_ps (model_coefficients[1]);
316  const __m256 c_vec = _mm256_set1_ps (model_coefficients[2]);
317  // To avoid sqrt computation: consider one larger sphere (radius + threshold) and one smaller sphere (radius - threshold). Valid if point is in larger sphere, but not in smaller sphere.
318  const __m256 sqr_inner_sphere = _mm256_set1_ps ((model_coefficients[3] <= threshold ? 0.0 : (model_coefficients[3]-threshold)*(model_coefficients[3]-threshold)));
319  const __m256 sqr_outer_sphere = _mm256_set1_ps ((model_coefficients[3]+threshold)*(model_coefficients[3]+threshold));
320  __m256i res = _mm256_set1_epi32(0); // This corresponds to nr_p: 8 32bit integers that, summed together, hold the number of inliers
321  for (; (i + 8) <= indices_->size (); i += 8)
322  {
323  const __m256 sqr_dist = sqr_dist8 (i, a_vec, b_vec, c_vec);
324  const __m256 mask = _mm256_and_ps (_mm256_cmp_ps (sqr_inner_sphere, sqr_dist, _CMP_LT_OQ), _mm256_cmp_ps (sqr_dist, sqr_outer_sphere, _CMP_LT_OQ)); // The mask contains 1 bits if the corresponding points are inliers, else 0 bits
325  res = _mm256_add_epi32 (res, _mm256_and_si256 (_mm256_set1_epi32 (1), _mm256_castps_si256 (mask))); // The latter part creates a vector with ones (as 32bit integers) where the points are inliers
326  //const int res = _mm256_movemask_ps (mask);
327  //if (res & 1) nr_p++;
328  //if (res & 2) nr_p++;
329  //if (res & 4) nr_p++;
330  //if (res & 8) nr_p++;
331  //if (res & 16) nr_p++;
332  //if (res & 32) nr_p++;
333  //if (res & 64) nr_p++;
334  //if (res & 128) nr_p++;
335  }
336  nr_p += _mm256_extract_epi32 (res, 0);
337  nr_p += _mm256_extract_epi32 (res, 1);
338  nr_p += _mm256_extract_epi32 (res, 2);
339  nr_p += _mm256_extract_epi32 (res, 3);
340  nr_p += _mm256_extract_epi32 (res, 4);
341  nr_p += _mm256_extract_epi32 (res, 5);
342  nr_p += _mm256_extract_epi32 (res, 6);
343  nr_p += _mm256_extract_epi32 (res, 7);
344 
345  // Process the remaining points (at most 7)
346  nr_p += countWithinDistanceStandard (model_coefficients, threshold, i);
347  return (nr_p);
348 }
349 #endif
350 
351 //////////////////////////////////////////////////////////////////////////
352 template <typename PointT> void
354  const Indices &inliers, const Eigen::VectorXf &model_coefficients, Eigen::VectorXf &optimized_coefficients) const
355 {
356  optimized_coefficients = model_coefficients;
357 
358  // Needs a set of valid model coefficients
359  if (!isModelValid (model_coefficients))
360  {
361  PCL_ERROR ("[pcl::SampleConsensusModelSphere::optimizeModelCoefficients] Given model is invalid!\n");
362  return;
363  }
364 
365  // Need more than the minimum sample size to make a difference
366  if (inliers.size () <= sample_size_)
367  {
368  PCL_ERROR ("[pcl::SampleConsensusModelSphere::optimizeModelCoefficients] Not enough inliers to refine/optimize the model's coefficients (%lu)! Returning the same coefficients.\n", inliers.size ());
369  return;
370  }
371 
372  OptimizationFunctor functor (this, inliers);
373  Eigen::NumericalDiff<OptimizationFunctor> num_diff (functor);
374  Eigen::LevenbergMarquardt<Eigen::NumericalDiff<OptimizationFunctor>, float> lm (num_diff);
375  int info = lm.minimize (optimized_coefficients);
376 
377  // Compute the L2 norm of the residuals
378  PCL_DEBUG ("[pcl::SampleConsensusModelSphere::optimizeModelCoefficients] LM solver finished with exit code %i, having a residual norm of %g. \nInitial solution: %g %g %g %g \nFinal solution: %g %g %g %g\n",
379  info, lm.fvec.norm (), model_coefficients[0], model_coefficients[1], model_coefficients[2], model_coefficients[3], optimized_coefficients[0], optimized_coefficients[1], optimized_coefficients[2], optimized_coefficients[3]);
380 }
381 
382 //////////////////////////////////////////////////////////////////////////
383 template <typename PointT> void
385  const Indices &, const Eigen::VectorXf &model_coefficients, PointCloud &projected_points, bool) const
386 {
387  // Needs a valid model coefficients
388  if (!isModelValid (model_coefficients))
389  {
390  PCL_ERROR ("[pcl::SampleConsensusModelSphere::projectPoints] Given model is invalid!\n");
391  return;
392  }
393 
394  // Allocate enough space and copy the basics
395  projected_points.resize (input_->size ());
396  projected_points.header = input_->header;
397  projected_points.width = input_->width;
398  projected_points.height = input_->height;
399  projected_points.is_dense = input_->is_dense;
400 
401  PCL_WARN ("[pcl::SampleConsensusModelSphere::projectPoints] Not implemented yet.\n");
402  projected_points.points = input_->points;
403 }
404 
405 //////////////////////////////////////////////////////////////////////////
406 template <typename PointT> bool
408  const std::set<index_t> &indices, const Eigen::VectorXf &model_coefficients, const double threshold) const
409 {
410  // Needs a valid model coefficients
411  if (!isModelValid (model_coefficients))
412  {
413  PCL_ERROR ("[pcl::SampleConsensusModelSphere::doSamplesVerifyModel] Given model is invalid!\n");
414  return (false);
415  }
416 
417  for (const auto &index : indices)
418  {
419  // Calculate the distance from the point to the sphere as the difference between
420  //dist(point,sphere_origin) and sphere_radius
421  if (std::abs (sqrt (
422  ( (*input_)[index].x - model_coefficients[0] ) *
423  ( (*input_)[index].x - model_coefficients[0] ) +
424  ( (*input_)[index].y - model_coefficients[1] ) *
425  ( (*input_)[index].y - model_coefficients[1] ) +
426  ( (*input_)[index].z - model_coefficients[2] ) *
427  ( (*input_)[index].z - model_coefficients[2] )
428  ) - model_coefficients[3]) > threshold)
429  {
430  return (false);
431  }
432  }
433 
434  return (true);
435 }
436 
437 #define PCL_INSTANTIATE_SampleConsensusModelSphere(T) template class PCL_EXPORTS pcl::SampleConsensusModelSphere<T>;
438 
439 #endif // PCL_SAMPLE_CONSENSUS_IMPL_SAC_MODEL_SPHERE_H_
440 
pcl::SampleConsensusModelSphere::countWithinDistance
std::size_t countWithinDistance(const Eigen::VectorXf &model_coefficients, const double threshold) const override
Count all the points which respect the given model coefficients as inliers.
Definition: sac_model_sphere.hpp:229
pcl::PointCloud::height
std::uint32_t height
The point cloud height (if organized as an image-structure).
Definition: point_cloud.h:393
pcl::geometry::distance
float distance(const PointT &p1, const PointT &p2)
Definition: geometry.h:60
pcl::SampleConsensusModelSphere::isSampleGood
bool isSampleGood(const Indices &samples) const override
Check if a sample of indices results in a good sample of points indices.
Definition: sac_model_sphere.hpp:49
pcl::PointCloud::points
std::vector< PointT, Eigen::aligned_allocator< PointT > > points
The point data.
Definition: point_cloud.h:388
pcl::PointCloud< pcl::PointXYZRGB >
pcl::SampleConsensusModelSphere::getDistancesToModel
void getDistancesToModel(const Eigen::VectorXf &model_coefficients, std::vector< double > &distances) const override
Compute all distances from the cloud data to a given sphere model.
Definition: sac_model_sphere.hpp:157
pcl::SampleConsensusModelSphere::optimizeModelCoefficients
void optimizeModelCoefficients(const Indices &inliers, const Eigen::VectorXf &model_coefficients, Eigen::VectorXf &optimized_coefficients) const override
Recompute the sphere coefficients using the given inlier set and return them to the user.
Definition: sac_model_sphere.hpp:353
pcl::PointCloud::width
std::uint32_t width
The point cloud width (if organized as an image-structure).
Definition: point_cloud.h:391
pcl::SampleConsensusModelSphere::countWithinDistanceStandard
std::size_t countWithinDistanceStandard(const Eigen::VectorXf &model_coefficients, const double threshold, std::size_t i=0) const
This implementation uses no SIMD instructions.
Definition: sac_model_sphere.hpp:247
pcl::SampleConsensusModelSphere::computeModelCoefficients
bool computeModelCoefficients(const Indices &samples, Eigen::VectorXf &model_coefficients) const override
Check whether the given index samples can form a valid sphere model, compute the model coefficients f...
Definition: sac_model_sphere.hpp:61
pcl::PointCloud::is_dense
bool is_dense
True if no points are invalid (e.g., have NaN or Inf values in any of their floating point fields).
Definition: point_cloud.h:396
pcl::PointCloud::resize
void resize(std::size_t count)
Resizes the container to contain count elements.
Definition: point_cloud.h:455
pcl::PointCloud::header
pcl::PCLHeader header
The point cloud header.
Definition: point_cloud.h:385
pcl::Indices
IndicesAllocator<> Indices
Type used for indices in PCL.
Definition: types.h:131
pcl::SampleConsensusModelSphere::doSamplesVerifyModel
bool doSamplesVerifyModel(const std::set< index_t > &indices, const Eigen::VectorXf &model_coefficients, const double threshold) const override
Verify whether a subset of indices verifies the given sphere model coefficients.
Definition: sac_model_sphere.hpp:407
pcl::SampleConsensusModelSphere::projectPoints
void projectPoints(const Indices &inliers, const Eigen::VectorXf &model_coefficients, PointCloud &projected_points, bool copy_data_fields=true) const override
Create a new point cloud with inliers projected onto the sphere model.
Definition: sac_model_sphere.hpp:384
pcl::SampleConsensusModelSphere::selectWithinDistance
void selectWithinDistance(const Eigen::VectorXf &model_coefficients, const double threshold, Indices &inliers) override
Select all the points which respect the given model coefficients as inliers.
Definition: sac_model_sphere.hpp:188
pcl::SampleConsensusModelSphere
SampleConsensusModelSphere defines a model for 3D sphere segmentation.
Definition: sac_model_sphere.h:59