Point Cloud Library (PCL)  1.11.1-dev
sac_model_circle.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_CIRCLE_H_
42 #define PCL_SAMPLE_CONSENSUS_IMPL_SAC_MODEL_CIRCLE_H_
43 
44 #include <pcl/sample_consensus/eigen.h>
45 #include <pcl/sample_consensus/sac_model_circle.h>
46 #include <pcl/common/concatenate.h>
47 
48 //////////////////////////////////////////////////////////////////////////
49 template <typename PointT> bool
51 {
52  if (samples.size () != sample_size_)
53  {
54  PCL_ERROR ("[pcl::SampleConsensusModelCircle2D::isSampleGood] Wrong number of samples (is %lu, should be %lu)!\n", samples.size (), sample_size_);
55  return (false);
56  }
57  // Get the values at the two points
58  Eigen::Array2d p0 ((*input_)[samples[0]].x, (*input_)[samples[0]].y);
59  Eigen::Array2d p1 ((*input_)[samples[1]].x, (*input_)[samples[1]].y);
60  Eigen::Array2d p2 ((*input_)[samples[2]].x, (*input_)[samples[2]].y);
61 
62  // Compute the segment values (in 2d) between p1 and p0
63  p1 -= p0;
64  // Compute the segment values (in 2d) between p2 and p0
65  p2 -= p0;
66 
67  Eigen::Array2d dy1dy2 = p1 / p2;
68 
69  return (dy1dy2[0] != dy1dy2[1]);
70 }
71 
72 //////////////////////////////////////////////////////////////////////////
73 template <typename PointT> bool
74 pcl::SampleConsensusModelCircle2D<PointT>::computeModelCoefficients (const Indices &samples, Eigen::VectorXf &model_coefficients) const
75 {
76  // Need 3 samples
77  if (samples.size () != sample_size_)
78  {
79  PCL_ERROR ("[pcl::SampleConsensusModelCircle2D::computeModelCoefficients] Invalid set of samples given (%lu)!\n", samples.size ());
80  return (false);
81  }
82 
83  model_coefficients.resize (model_size_);
84 
85  Eigen::Vector2d p0 ((*input_)[samples[0]].x, (*input_)[samples[0]].y);
86  Eigen::Vector2d p1 ((*input_)[samples[1]].x, (*input_)[samples[1]].y);
87  Eigen::Vector2d p2 ((*input_)[samples[2]].x, (*input_)[samples[2]].y);
88 
89  Eigen::Vector2d u = (p0 + p1) / 2.0;
90  Eigen::Vector2d v = (p1 + p2) / 2.0;
91 
92  Eigen::Vector2d p1p0dif = p1 - p0;
93  Eigen::Vector2d p2p1dif = p2 - p1;
94  Eigen::Vector2d uvdif = u - v;
95 
96  Eigen::Vector2d m (- p1p0dif[0] / p1p0dif[1], - p2p1dif[0] / p2p1dif[1]);
97 
98  // Center (x, y)
99  model_coefficients[0] = static_cast<float> ((m[0] * u[0] - m[1] * v[0] - uvdif[1] ) / (m[0] - m[1]));
100  model_coefficients[1] = static_cast<float> ((m[0] * m[1] * uvdif[0] + m[0] * v[1] - m[1] * u[1]) / (m[0] - m[1]));
101 
102  // Radius
103  model_coefficients[2] = static_cast<float> (sqrt ((model_coefficients[0] - p0[0]) * (model_coefficients[0] - p0[0]) +
104  (model_coefficients[1] - p0[1]) * (model_coefficients[1] - p0[1])));
105  return (true);
106 }
107 
108 #define AT(POS) ((*input_)[(*indices_)[(POS)]])
109 
110 #ifdef __AVX__
111 // This function computes the squared distances (i.e. the distances without the square root) of 8 points to the center of the circle
112 template <typename PointT> inline __m256 pcl::SampleConsensusModelCircle2D<PointT>::sqr_dist8 (const std::size_t i, const __m256 a_vec, const __m256 b_vec) const
113 {
114  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);
115  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);
116  return _mm256_add_ps (_mm256_mul_ps (tmp1, tmp1), _mm256_mul_ps (tmp2, tmp2));
117 }
118 #endif // ifdef __AVX__
119 
120 #ifdef __SSE__
121 // This function computes the squared distances (i.e. the distances without the square root) of 4 points to the center of the circle
122 template <typename PointT> inline __m128 pcl::SampleConsensusModelCircle2D<PointT>::sqr_dist4 (const std::size_t i, const __m128 a_vec, const __m128 b_vec) const
123 {
124  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);
125  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);
126  return _mm_add_ps (_mm_mul_ps (tmp1, tmp1), _mm_mul_ps (tmp2, tmp2));
127 }
128 #endif // ifdef __SSE__
129 
130 #undef AT
131 
132 //////////////////////////////////////////////////////////////////////////
133 template <typename PointT> void
134 pcl::SampleConsensusModelCircle2D<PointT>::getDistancesToModel (const Eigen::VectorXf &model_coefficients, std::vector<double> &distances) const
135 {
136  // Check if the model is valid given the user constraints
137  if (!isModelValid (model_coefficients))
138  {
139  distances.clear ();
140  return;
141  }
142  distances.resize (indices_->size ());
143 
144  // Iterate through the 3d points and calculate the distances from them to the circle
145  for (std::size_t i = 0; i < indices_->size (); ++i)
146  // Calculate the distance from the point to the circle as the difference between
147  // dist(point,circle_origin) and circle_radius
148  distances[i] = std::abs (std::sqrt (
149  ( (*input_)[(*indices_)[i]].x - model_coefficients[0] ) *
150  ( (*input_)[(*indices_)[i]].x - model_coefficients[0] ) +
151 
152  ( (*input_)[(*indices_)[i]].y - model_coefficients[1] ) *
153  ( (*input_)[(*indices_)[i]].y - model_coefficients[1] )
154  ) - model_coefficients[2]);
155 }
156 
157 //////////////////////////////////////////////////////////////////////////
158 template <typename PointT> void
160  const Eigen::VectorXf &model_coefficients, const double threshold,
161  Indices &inliers)
162 {
163  // Check if the model is valid given the user constraints
164  if (!isModelValid (model_coefficients))
165  {
166  inliers.clear ();
167  return;
168  }
169  inliers.clear ();
170  error_sqr_dists_.clear ();
171  inliers.reserve (indices_->size ());
172  error_sqr_dists_.reserve (indices_->size ());
173 
174  const float sqr_inner_radius = (model_coefficients[2] <= threshold ? 0.0f : (model_coefficients[2] - threshold) * (model_coefficients[2] - threshold));
175  const float sqr_outer_radius = (model_coefficients[2] + threshold) * (model_coefficients[2] + threshold);
176  // Iterate through the 3d points and calculate the distances from them to the circle
177  for (std::size_t i = 0; i < indices_->size (); ++i)
178  {
179  // To avoid sqrt computation: consider one larger circle (radius + threshold) and one smaller circle (radius - threshold).
180  // Valid if point is in larger circle, but not in smaller circle.
181  const float sqr_dist = ( (*input_)[(*indices_)[i]].x - model_coefficients[0] ) *
182  ( (*input_)[(*indices_)[i]].x - model_coefficients[0] ) +
183  ( (*input_)[(*indices_)[i]].y - model_coefficients[1] ) *
184  ( (*input_)[(*indices_)[i]].y - model_coefficients[1] );
185  if ((sqr_dist <= sqr_outer_radius) && (sqr_dist >= sqr_inner_radius))
186  {
187  // Returns the indices of the points whose distances are smaller than the threshold
188  inliers.push_back ((*indices_)[i]);
189  // Only compute exact distance if necessary (if point is inlier)
190  error_sqr_dists_.push_back (static_cast<double> (std::abs (std::sqrt (sqr_dist) - model_coefficients[2])));
191  }
192  }
193 }
194 
195 //////////////////////////////////////////////////////////////////////////
196 template <typename PointT> std::size_t
198  const Eigen::VectorXf &model_coefficients, const double threshold) const
199 {
200  // Check if the model is valid given the user constraints
201  if (!isModelValid (model_coefficients))
202  return (0);
203 
204 #if defined (__AVX__) && defined (__AVX2__)
205  return countWithinDistanceAVX (model_coefficients, threshold);
206 #elif defined (__SSE__) && defined (__SSE2__) && defined (__SSE4_1__)
207  return countWithinDistanceSSE (model_coefficients, threshold);
208 #else
209  return countWithinDistanceStandard (model_coefficients, threshold);
210 #endif
211 }
212 
213 //////////////////////////////////////////////////////////////////////////
214 template <typename PointT> std::size_t
216  const Eigen::VectorXf &model_coefficients, const double threshold, std::size_t i) const
217 {
218  std::size_t nr_p = 0;
219  const float sqr_inner_radius = (model_coefficients[2] <= threshold ? 0.0f : (model_coefficients[2] - threshold) * (model_coefficients[2] - threshold));
220  const float sqr_outer_radius = (model_coefficients[2] + threshold) * (model_coefficients[2] + threshold);
221  // Iterate through the 3d points and calculate the distances from them to the circle
222  for (; i < indices_->size (); ++i)
223  {
224  // To avoid sqrt computation: consider one larger circle (radius + threshold) and one smaller circle (radius - threshold).
225  // Valid if point is in larger circle, but not in smaller circle.
226  const float sqr_dist = ( (*input_)[(*indices_)[i]].x - model_coefficients[0] ) *
227  ( (*input_)[(*indices_)[i]].x - model_coefficients[0] ) +
228  ( (*input_)[(*indices_)[i]].y - model_coefficients[1] ) *
229  ( (*input_)[(*indices_)[i]].y - model_coefficients[1] );
230  if ((sqr_dist <= sqr_outer_radius) && (sqr_dist >= sqr_inner_radius))
231  nr_p++;
232  }
233  return (nr_p);
234 }
235 
236 //////////////////////////////////////////////////////////////////////////
237 #if defined (__SSE__) && defined (__SSE2__) && defined (__SSE4_1__)
238 template <typename PointT> std::size_t
240  const Eigen::VectorXf &model_coefficients, const double threshold, std::size_t i) const
241 {
242  std::size_t nr_p = 0;
243  const __m128 a_vec = _mm_set1_ps (model_coefficients[0]);
244  const __m128 b_vec = _mm_set1_ps (model_coefficients[1]);
245  // To avoid sqrt computation: consider one larger circle (radius + threshold) and one smaller circle (radius - threshold). Valid if point is in larger circle, but not in smaller circle.
246  const __m128 sqr_inner_radius = _mm_set1_ps ((model_coefficients[2] <= threshold ? 0.0 : (model_coefficients[2]-threshold)*(model_coefficients[2]-threshold)));
247  const __m128 sqr_outer_radius = _mm_set1_ps ((model_coefficients[2]+threshold)*(model_coefficients[2]+threshold));
248  __m128i res = _mm_set1_epi32(0); // This corresponds to nr_p: 4 32bit integers that, summed together, hold the number of inliers
249  for (; (i + 4) <= indices_->size (); i += 4)
250  {
251  const __m128 sqr_dist = sqr_dist4 (i, a_vec, b_vec);
252  const __m128 mask = _mm_and_ps (_mm_cmplt_ps (sqr_inner_radius, sqr_dist), _mm_cmplt_ps (sqr_dist, sqr_outer_radius)); // The mask contains 1 bits if the corresponding points are inliers, else 0 bits
253  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
254  //const int res = _mm_movemask_ps (mask);
255  //if (res & 1) nr_p++;
256  //if (res & 2) nr_p++;
257  //if (res & 4) nr_p++;
258  //if (res & 8) nr_p++;
259  }
260  nr_p += _mm_extract_epi32 (res, 0);
261  nr_p += _mm_extract_epi32 (res, 1);
262  nr_p += _mm_extract_epi32 (res, 2);
263  nr_p += _mm_extract_epi32 (res, 3);
264 
265  // Process the remaining points (at most 3)
266  nr_p += countWithinDistanceStandard (model_coefficients, threshold, i);
267  return (nr_p);
268 }
269 #endif
270 
271 //////////////////////////////////////////////////////////////////////////
272 #if defined (__AVX__) && defined (__AVX2__)
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 __m256 a_vec = _mm256_set1_ps (model_coefficients[0]);
279  const __m256 b_vec = _mm256_set1_ps (model_coefficients[1]);
280  // To avoid sqrt computation: consider one larger circle (radius + threshold) and one smaller circle (radius - threshold). Valid if point is in larger circle, but not in smaller circle.
281  const __m256 sqr_inner_radius = _mm256_set1_ps ((model_coefficients[2] <= threshold ? 0.0 : (model_coefficients[2]-threshold)*(model_coefficients[2]-threshold)));
282  const __m256 sqr_outer_radius = _mm256_set1_ps ((model_coefficients[2]+threshold)*(model_coefficients[2]+threshold));
283  __m256i res = _mm256_set1_epi32(0); // This corresponds to nr_p: 8 32bit integers that, summed together, hold the number of inliers
284  for (; (i + 8) <= indices_->size (); i += 8)
285  {
286  const __m256 sqr_dist = sqr_dist8 (i, a_vec, b_vec);
287  const __m256 mask = _mm256_and_ps (_mm256_cmp_ps (sqr_inner_radius, sqr_dist, _CMP_LT_OQ), _mm256_cmp_ps (sqr_dist, sqr_outer_radius, _CMP_LT_OQ)); // The mask contains 1 bits if the corresponding points are inliers, else 0 bits
288  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
289  //const int res = _mm256_movemask_ps (mask);
290  //if (res & 1) nr_p++;
291  //if (res & 2) nr_p++;
292  //if (res & 4) nr_p++;
293  //if (res & 8) nr_p++;
294  //if (res & 16) nr_p++;
295  //if (res & 32) nr_p++;
296  //if (res & 64) nr_p++;
297  //if (res & 128) nr_p++;
298  }
299  nr_p += _mm256_extract_epi32 (res, 0);
300  nr_p += _mm256_extract_epi32 (res, 1);
301  nr_p += _mm256_extract_epi32 (res, 2);
302  nr_p += _mm256_extract_epi32 (res, 3);
303  nr_p += _mm256_extract_epi32 (res, 4);
304  nr_p += _mm256_extract_epi32 (res, 5);
305  nr_p += _mm256_extract_epi32 (res, 6);
306  nr_p += _mm256_extract_epi32 (res, 7);
307 
308  // Process the remaining points (at most 7)
309  nr_p += countWithinDistanceStandard (model_coefficients, threshold, i);
310  return (nr_p);
311 }
312 #endif
313 
314 //////////////////////////////////////////////////////////////////////////
315 template <typename PointT> void
317  const Indices &inliers, const Eigen::VectorXf &model_coefficients, Eigen::VectorXf &optimized_coefficients) const
318 {
319  optimized_coefficients = model_coefficients;
320 
321  // Needs a set of valid model coefficients
322  if (!isModelValid (model_coefficients))
323  {
324  PCL_ERROR ("[pcl::SampleConsensusModelCircle2D::optimizeModelCoefficients] Given model is invalid!\n");
325  return;
326  }
327 
328  // Need more than the minimum sample size to make a difference
329  if (inliers.size () <= sample_size_)
330  {
331  PCL_ERROR ("[pcl::SampleConsensusModelCircle2D::optimizeModelCoefficients] Not enough inliers to refine/optimize the model's coefficients (%lu)! Returning the same coefficients.\n", inliers.size ());
332  return;
333  }
334 
335  OptimizationFunctor functor (this, inliers);
336  Eigen::NumericalDiff<OptimizationFunctor> num_diff (functor);
337  Eigen::LevenbergMarquardt<Eigen::NumericalDiff<OptimizationFunctor>, float> lm (num_diff);
338  int info = lm.minimize (optimized_coefficients);
339 
340  // Compute the L2 norm of the residuals
341  PCL_DEBUG ("[pcl::SampleConsensusModelCircle2D::optimizeModelCoefficients] LM solver finished with exit code %i, having a residual norm of %g. \nInitial solution: %g %g %g \nFinal solution: %g %g %g\n",
342  info, lm.fvec.norm (), model_coefficients[0], model_coefficients[1], model_coefficients[2], optimized_coefficients[0], optimized_coefficients[1], optimized_coefficients[2]);
343 }
344 
345 //////////////////////////////////////////////////////////////////////////
346 template <typename PointT> void
348  const Indices &inliers, const Eigen::VectorXf &model_coefficients,
349  PointCloud &projected_points, bool copy_data_fields) const
350 {
351  // Needs a valid set of model coefficients
352  if (!isModelValid (model_coefficients))
353  {
354  PCL_ERROR ("[pcl::SampleConsensusModelCircle2D::projectPoints] Given model is invalid!\n");
355  return;
356  }
357 
358  projected_points.header = input_->header;
359  projected_points.is_dense = input_->is_dense;
360 
361  // Copy all the data fields from the input cloud to the projected one?
362  if (copy_data_fields)
363  {
364  // Allocate enough space and copy the basics
365  projected_points.resize (input_->size ());
366  projected_points.width = input_->width;
367  projected_points.height = input_->height;
368 
369  using FieldList = typename pcl::traits::fieldList<PointT>::type;
370  // Iterate over each point
371  for (std::size_t i = 0; i < projected_points.size (); ++i)
372  // Iterate over each dimension
373  pcl::for_each_type <FieldList> (NdConcatenateFunctor <PointT, PointT> ((*input_)[i], projected_points[i]));
374 
375  // Iterate through the points and project them to the circle
376  for (const auto &inlier : inliers)
377  {
378  float dx = (*input_)[inlier].x - model_coefficients[0];
379  float dy = (*input_)[inlier].y - model_coefficients[1];
380  float a = std::sqrt ( (model_coefficients[2] * model_coefficients[2]) / (dx * dx + dy * dy) );
381 
382  projected_points[inlier].x = a * dx + model_coefficients[0];
383  projected_points[inlier].y = a * dy + model_coefficients[1];
384  }
385  }
386  else
387  {
388  // Allocate enough space and copy the basics
389  projected_points.resize (inliers.size ());
390  projected_points.width = inliers.size ();
391  projected_points.height = 1;
392 
393  using FieldList = typename pcl::traits::fieldList<PointT>::type;
394  // Iterate over each point
395  for (std::size_t i = 0; i < inliers.size (); ++i)
396  // Iterate over each dimension
397  pcl::for_each_type <FieldList> (NdConcatenateFunctor <PointT, PointT> ((*input_)[inliers[i]], projected_points[i]));
398 
399  // Iterate through the points and project them to the circle
400  for (std::size_t i = 0; i < inliers.size (); ++i)
401  {
402  float dx = (*input_)[inliers[i]].x - model_coefficients[0];
403  float dy = (*input_)[inliers[i]].y - model_coefficients[1];
404  float a = std::sqrt ( (model_coefficients[2] * model_coefficients[2]) / (dx * dx + dy * dy) );
405 
406  projected_points[i].x = a * dx + model_coefficients[0];
407  projected_points[i].y = a * dy + model_coefficients[1];
408  }
409  }
410 }
411 
412 //////////////////////////////////////////////////////////////////////////
413 template <typename PointT> bool
415  const std::set<index_t> &indices, const Eigen::VectorXf &model_coefficients, const double threshold) const
416 {
417  // Needs a valid model coefficients
418  if (!isModelValid (model_coefficients))
419  {
420  PCL_ERROR ("[pcl::SampleConsensusModelCircle2D::doSamplesVerifyModel] Given model is invalid!\n");
421  return (false);
422  }
423 
424  const float sqr_inner_radius = (model_coefficients[2] <= threshold ? 0.0f : (model_coefficients[2] - threshold) * (model_coefficients[2] - threshold));
425  const float sqr_outer_radius = (model_coefficients[2] + threshold) * (model_coefficients[2] + threshold);
426  for (const auto &index : indices)
427  {
428  // To avoid sqrt computation: consider one larger circle (radius + threshold) and one smaller circle (radius - threshold).
429  // Valid if point is in larger circle, but not in smaller circle.
430  const float sqr_dist = ( (*input_)[index].x - model_coefficients[0] ) *
431  ( (*input_)[index].x - model_coefficients[0] ) +
432  ( (*input_)[index].y - model_coefficients[1] ) *
433  ( (*input_)[index].y - model_coefficients[1] );
434  if ((sqr_dist > sqr_outer_radius) || (sqr_dist < sqr_inner_radius))
435  return (false);
436  }
437  return (true);
438 }
439 
440 //////////////////////////////////////////////////////////////////////////
441 template <typename PointT> bool
442 pcl::SampleConsensusModelCircle2D<PointT>::isModelValid (const Eigen::VectorXf &model_coefficients) const
443 {
444  if (!SampleConsensusModel<PointT>::isModelValid (model_coefficients))
445  return (false);
446 
447  if (radius_min_ != -std::numeric_limits<double>::max() && model_coefficients[2] < radius_min_)
448  return (false);
449  if (radius_max_ != std::numeric_limits<double>::max() && model_coefficients[2] > radius_max_)
450  return (false);
451 
452  return (true);
453 }
454 
455 #define PCL_INSTANTIATE_SampleConsensusModelCircle2D(T) template class PCL_EXPORTS pcl::SampleConsensusModelCircle2D<T>;
456 
457 #endif // PCL_SAMPLE_CONSENSUS_IMPL_SAC_MODEL_CIRCLE_H_
458 
pcl::PointCloud::height
std::uint32_t height
The point cloud height (if organized as an image-structure).
Definition: point_cloud.h:394
pcl::SampleConsensusModelCircle2D::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 2d circle model coefficients.
Definition: sac_model_circle.hpp:414
pcl::SampleConsensusModelCircle2D::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_circle.hpp:50
pcl::SampleConsensusModelCircle2D::selectWithinDistance
void selectWithinDistance(const Eigen::VectorXf &model_coefficients, const double threshold, Indices &inliers) override
Compute all distances from the cloud data to a given 2D circle model.
Definition: sac_model_circle.hpp:159
pcl::NdConcatenateFunctor
Helper functor structure for concatenate.
Definition: concatenate.h:49
pcl::PointCloud< pcl::PointXYZRGB >
pcl::SampleConsensusModelCircle2D::computeModelCoefficients
bool computeModelCoefficients(const Indices &samples, Eigen::VectorXf &model_coefficients) const override
Check whether the given index samples can form a valid 2D circle model, compute the model coefficient...
Definition: sac_model_circle.hpp:74
pcl::SampleConsensusModelCircle2D::isModelValid
bool isModelValid(const Eigen::VectorXf &model_coefficients) const override
Check whether a model is valid given the user constraints.
Definition: sac_model_circle.hpp:442
pcl::PointCloud::width
std::uint32_t width
The point cloud width (if organized as an image-structure).
Definition: point_cloud.h:392
pcl::SampleConsensusModelCircle2D::optimizeModelCoefficients
void optimizeModelCoefficients(const Indices &inliers, const Eigen::VectorXf &model_coefficients, Eigen::VectorXf &optimized_coefficients) const override
Recompute the 2d circle coefficients using the given inlier set and return them to the user.
Definition: sac_model_circle.hpp:316
pcl::SampleConsensusModelCircle2D::getDistancesToModel
void getDistancesToModel(const Eigen::VectorXf &model_coefficients, std::vector< double > &distances) const override
Compute all distances from the cloud data to a given 2D circle model.
Definition: sac_model_circle.hpp:134
pcl::SampleConsensusModelCircle2D::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_circle.hpp:215
pcl::SampleConsensusModelCircle2D
SampleConsensusModelCircle2D defines a model for 2D circle segmentation on the X-Y plane.
Definition: sac_model_circle.h:59
pcl::SampleConsensusModelCircle2D::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_circle.hpp:197
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:397
pcl::PointCloud::resize
void resize(std::size_t count)
Resizes the container to contain count elements.
Definition: point_cloud.h:456
pcl::PointCloud::header
pcl::PCLHeader header
The point cloud header.
Definition: point_cloud.h:386
pcl::Indices
IndicesAllocator<> Indices
Type used for indices in PCL.
Definition: types.h:131
pcl::PointCloud::size
std::size_t size() const
Definition: point_cloud.h:437
pcl::SampleConsensusModel
SampleConsensusModel represents the base model class.
Definition: sac_model.h:69
pcl::SampleConsensusModelCircle2D::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 2d circle model.
Definition: sac_model_circle.hpp:347