41 #ifndef PCL_COMMON_IMPL_CENTROID_H_
42 #define PCL_COMMON_IMPL_CENTROID_H_
44 #include <pcl/common/centroid.h>
45 #include <pcl/conversions.h>
46 #include <boost/mpl/size.hpp>
49 template <
typename Po
intT,
typename Scalar>
inline unsigned int
51 Eigen::Matrix<Scalar, 4, 1> ¢roid)
60 while (cloud_iterator.
isValid ())
63 if (!pcl_isfinite (cloud_iterator->x) ||
64 !pcl_isfinite (cloud_iterator->y) ||
65 !pcl_isfinite (cloud_iterator->z))
67 centroid[0] += cloud_iterator->x;
68 centroid[1] += cloud_iterator->y;
69 centroid[2] += cloud_iterator->z;
73 centroid /=
static_cast<Scalar
> (cp);
79 template <
typename Po
intT,
typename Scalar>
inline unsigned int
81 Eigen::Matrix<Scalar, 4, 1> ¢roid)
92 for (
size_t i = 0; i < cloud.
size (); ++i)
94 centroid[0] += cloud[i].x;
95 centroid[1] += cloud[i].y;
96 centroid[2] += cloud[i].z;
98 centroid /=
static_cast<Scalar
> (cloud.
size ());
101 return (static_cast<unsigned int> (cloud.
size ()));
107 for (
size_t i = 0; i < cloud.
size (); ++i)
113 centroid[0] += cloud[i].x;
114 centroid[1] += cloud[i].y;
115 centroid[2] += cloud[i].z;
118 centroid /=
static_cast<Scalar
> (cp);
126 template <
typename Po
intT,
typename Scalar>
inline unsigned int
128 const std::vector<int> &indices,
129 Eigen::Matrix<Scalar, 4, 1> ¢roid)
131 if (indices.empty ())
139 for (
size_t i = 0; i < indices.size (); ++i)
141 centroid[0] += cloud[indices[i]].x;
142 centroid[1] += cloud[indices[i]].y;
143 centroid[2] += cloud[indices[i]].z;
145 centroid /=
static_cast<Scalar
> (indices.size ());
147 return (static_cast<unsigned int> (indices.size ()));
153 for (
size_t i = 0; i < indices.size (); ++i)
159 centroid[0] += cloud[indices[i]].x;
160 centroid[1] += cloud[indices[i]].y;
161 centroid[2] += cloud[indices[i]].z;
164 centroid /=
static_cast<Scalar
> (cp);
171 template <
typename Po
intT,
typename Scalar>
inline unsigned int
174 Eigen::Matrix<Scalar, 4, 1> ¢roid)
180 template <
typename Po
intT,
typename Scalar>
inline unsigned
182 const Eigen::Matrix<Scalar, 4, 1> ¢roid,
183 Eigen::Matrix<Scalar, 3, 3> &covariance_matrix)
189 covariance_matrix.setZero ();
191 unsigned point_count;
195 point_count =
static_cast<unsigned> (cloud.
size ());
197 for (
size_t i = 0; i < point_count; ++i)
199 Eigen::Matrix<Scalar, 4, 1> pt;
200 pt[0] = cloud[i].x - centroid[0];
201 pt[1] = cloud[i].y - centroid[1];
202 pt[2] = cloud[i].z - centroid[2];
204 covariance_matrix (1, 1) += pt.y () * pt.y ();
205 covariance_matrix (1, 2) += pt.y () * pt.z ();
207 covariance_matrix (2, 2) += pt.z () * pt.z ();
210 covariance_matrix (0, 0) += pt.x ();
211 covariance_matrix (0, 1) += pt.y ();
212 covariance_matrix (0, 2) += pt.z ();
220 for (
size_t i = 0; i < cloud.
size (); ++i)
223 if (!isFinite (cloud [i]))
226 Eigen::Matrix<Scalar, 4, 1> pt;
227 pt[0] = cloud[i].x - centroid[0];
228 pt[1] = cloud[i].y - centroid[1];
229 pt[2] = cloud[i].z - centroid[2];
231 covariance_matrix (1, 1) += pt.y () * pt.y ();
232 covariance_matrix (1, 2) += pt.y () * pt.z ();
234 covariance_matrix (2, 2) += pt.z () * pt.z ();
237 covariance_matrix (0, 0) += pt.x ();
238 covariance_matrix (0, 1) += pt.y ();
239 covariance_matrix (0, 2) += pt.z ();
243 covariance_matrix (1, 0) = covariance_matrix (0, 1);
244 covariance_matrix (2, 0) = covariance_matrix (0, 2);
245 covariance_matrix (2, 1) = covariance_matrix (1, 2);
247 return (point_count);
251 template <
typename Po
intT,
typename Scalar>
inline unsigned int
253 const Eigen::Matrix<Scalar, 4, 1> ¢roid,
254 Eigen::Matrix<Scalar, 3, 3> &covariance_matrix)
257 if (point_count != 0)
258 covariance_matrix /=
static_cast<Scalar
> (point_count);
259 return (point_count);
263 template <
typename Po
intT,
typename Scalar>
inline unsigned int
265 const std::vector<int> &indices,
266 const Eigen::Matrix<Scalar, 4, 1> ¢roid,
267 Eigen::Matrix<Scalar, 3, 3> &covariance_matrix)
269 if (indices.empty ())
273 covariance_matrix.setZero ();
279 point_count = indices.size ();
281 for (
size_t i = 0; i < point_count; ++i)
283 Eigen::Matrix<Scalar, 4, 1> pt;
284 pt[0] = cloud[indices[i]].x - centroid[0];
285 pt[1] = cloud[indices[i]].y - centroid[1];
286 pt[2] = cloud[indices[i]].z - centroid[2];
288 covariance_matrix (1, 1) += pt.y () * pt.y ();
289 covariance_matrix (1, 2) += pt.y () * pt.z ();
291 covariance_matrix (2, 2) += pt.z () * pt.z ();
294 covariance_matrix (0, 0) += pt.x ();
295 covariance_matrix (0, 1) += pt.y ();
296 covariance_matrix (0, 2) += pt.z ();
304 for (
size_t i = 0; i < indices.size (); ++i)
310 Eigen::Matrix<Scalar, 4, 1> pt;
311 pt[0] = cloud[indices[i]].x - centroid[0];
312 pt[1] = cloud[indices[i]].y - centroid[1];
313 pt[2] = cloud[indices[i]].z - centroid[2];
315 covariance_matrix (1, 1) += pt.y () * pt.y ();
316 covariance_matrix (1, 2) += pt.y () * pt.z ();
318 covariance_matrix (2, 2) += pt.z () * pt.z ();
321 covariance_matrix (0, 0) += pt.x ();
322 covariance_matrix (0, 1) += pt.y ();
323 covariance_matrix (0, 2) += pt.z ();
327 covariance_matrix (1, 0) = covariance_matrix (0, 1);
328 covariance_matrix (2, 0) = covariance_matrix (0, 2);
329 covariance_matrix (2, 1) = covariance_matrix (1, 2);
330 return (static_cast<unsigned int> (point_count));
334 template <
typename Po
intT,
typename Scalar>
inline unsigned int
337 const Eigen::Matrix<Scalar, 4, 1> ¢roid,
338 Eigen::Matrix<Scalar, 3, 3> &covariance_matrix)
344 template <
typename Po
intT,
typename Scalar>
inline unsigned int
346 const std::vector<int> &indices,
347 const Eigen::Matrix<Scalar, 4, 1> ¢roid,
348 Eigen::Matrix<Scalar, 3, 3> &covariance_matrix)
351 if (point_count != 0)
352 covariance_matrix /=
static_cast<Scalar
> (point_count);
354 return (point_count);
358 template <
typename Po
intT,
typename Scalar>
inline unsigned int
361 const Eigen::Matrix<Scalar, 4, 1> ¢roid,
362 Eigen::Matrix<Scalar, 3, 3> &covariance_matrix)
365 if (point_count != 0)
366 covariance_matrix /=
static_cast<Scalar
> (point_count);
372 template <
typename Po
intT,
typename Scalar>
inline unsigned int
374 Eigen::Matrix<Scalar, 3, 3> &covariance_matrix)
377 Eigen::Matrix<Scalar, 1, 6, Eigen::RowMajor> accu = Eigen::Matrix<Scalar, 1, 6, Eigen::RowMajor>::Zero ();
379 unsigned int point_count;
382 point_count =
static_cast<unsigned int> (cloud.
size ());
384 for (
size_t i = 0; i < point_count; ++i)
386 accu [0] += cloud[i].x * cloud[i].x;
387 accu [1] += cloud[i].x * cloud[i].y;
388 accu [2] += cloud[i].x * cloud[i].z;
389 accu [3] += cloud[i].y * cloud[i].y;
390 accu [4] += cloud[i].y * cloud[i].z;
391 accu [5] += cloud[i].z * cloud[i].z;
397 for (
size_t i = 0; i < cloud.
size (); ++i)
402 accu [0] += cloud[i].x * cloud[i].x;
403 accu [1] += cloud[i].x * cloud[i].y;
404 accu [2] += cloud[i].x * cloud[i].z;
405 accu [3] += cloud[i].y * cloud[i].y;
406 accu [4] += cloud[i].y * cloud[i].z;
407 accu [5] += cloud[i].z * cloud[i].z;
412 if (point_count != 0)
414 accu /=
static_cast<Scalar
> (point_count);
415 covariance_matrix.coeffRef (0) = accu [0];
416 covariance_matrix.coeffRef (1) = covariance_matrix.coeffRef (3) = accu [1];
417 covariance_matrix.coeffRef (2) = covariance_matrix.coeffRef (6) = accu [2];
418 covariance_matrix.coeffRef (4) = accu [3];
419 covariance_matrix.coeffRef (5) = covariance_matrix.coeffRef (7) = accu [4];
420 covariance_matrix.coeffRef (8) = accu [5];
422 return (point_count);
426 template <
typename Po
intT,
typename Scalar>
inline unsigned int
428 const std::vector<int> &indices,
429 Eigen::Matrix<Scalar, 3, 3> &covariance_matrix)
432 Eigen::Matrix<Scalar, 1, 6, Eigen::RowMajor> accu = Eigen::Matrix<Scalar, 1, 6, Eigen::RowMajor>::Zero ();
434 unsigned int point_count;
437 point_count =
static_cast<unsigned int> (indices.size ());
438 for (std::vector<int>::const_iterator iIt = indices.begin (); iIt != indices.end (); ++iIt)
441 accu [0] += cloud[*iIt].x * cloud[*iIt].x;
442 accu [1] += cloud[*iIt].x * cloud[*iIt].y;
443 accu [2] += cloud[*iIt].x * cloud[*iIt].z;
444 accu [3] += cloud[*iIt].y * cloud[*iIt].y;
445 accu [4] += cloud[*iIt].y * cloud[*iIt].z;
446 accu [5] += cloud[*iIt].z * cloud[*iIt].z;
452 for (std::vector<int>::const_iterator iIt = indices.begin (); iIt != indices.end (); ++iIt)
458 accu [0] += cloud[*iIt].x * cloud[*iIt].x;
459 accu [1] += cloud[*iIt].x * cloud[*iIt].y;
460 accu [2] += cloud[*iIt].x * cloud[*iIt].z;
461 accu [3] += cloud[*iIt].y * cloud[*iIt].y;
462 accu [4] += cloud[*iIt].y * cloud[*iIt].z;
463 accu [5] += cloud[*iIt].z * cloud[*iIt].z;
466 if (point_count != 0)
468 accu /=
static_cast<Scalar
> (point_count);
469 covariance_matrix.coeffRef (0) = accu [0];
470 covariance_matrix.coeffRef (1) = covariance_matrix.coeffRef (3) = accu [1];
471 covariance_matrix.coeffRef (2) = covariance_matrix.coeffRef (6) = accu [2];
472 covariance_matrix.coeffRef (4) = accu [3];
473 covariance_matrix.coeffRef (5) = covariance_matrix.coeffRef (7) = accu [4];
474 covariance_matrix.coeffRef (8) = accu [5];
476 return (point_count);
480 template <
typename Po
intT,
typename Scalar>
inline unsigned int
483 Eigen::Matrix<Scalar, 3, 3> &covariance_matrix)
489 template <
typename Po
intT,
typename Scalar>
inline unsigned int
491 Eigen::Matrix<Scalar, 3, 3> &covariance_matrix,
492 Eigen::Matrix<Scalar, 4, 1> ¢roid)
495 Eigen::Matrix<Scalar, 1, 9, Eigen::RowMajor> accu = Eigen::Matrix<Scalar, 1, 9, Eigen::RowMajor>::Zero ();
499 point_count = cloud.
size ();
501 for (
size_t i = 0; i < point_count; ++i)
503 accu [0] += cloud[i].x * cloud[i].x;
504 accu [1] += cloud[i].x * cloud[i].y;
505 accu [2] += cloud[i].x * cloud[i].z;
506 accu [3] += cloud[i].y * cloud[i].y;
507 accu [4] += cloud[i].y * cloud[i].z;
508 accu [5] += cloud[i].z * cloud[i].z;
509 accu [6] += cloud[i].x;
510 accu [7] += cloud[i].y;
511 accu [8] += cloud[i].z;
517 for (
size_t i = 0; i < cloud.
size (); ++i)
522 accu [0] += cloud[i].x * cloud[i].x;
523 accu [1] += cloud[i].x * cloud[i].y;
524 accu [2] += cloud[i].x * cloud[i].z;
525 accu [3] += cloud[i].y * cloud[i].y;
526 accu [4] += cloud[i].y * cloud[i].z;
527 accu [5] += cloud[i].z * cloud[i].z;
528 accu [6] += cloud[i].x;
529 accu [7] += cloud[i].y;
530 accu [8] += cloud[i].z;
534 accu /=
static_cast<Scalar
> (point_count);
535 if (point_count != 0)
538 centroid[0] = accu[6]; centroid[1] = accu[7]; centroid[2] = accu[8];
540 covariance_matrix.coeffRef (0) = accu [0] - accu [6] * accu [6];
541 covariance_matrix.coeffRef (1) = accu [1] - accu [6] * accu [7];
542 covariance_matrix.coeffRef (2) = accu [2] - accu [6] * accu [8];
543 covariance_matrix.coeffRef (4) = accu [3] - accu [7] * accu [7];
544 covariance_matrix.coeffRef (5) = accu [4] - accu [7] * accu [8];
545 covariance_matrix.coeffRef (8) = accu [5] - accu [8] * accu [8];
546 covariance_matrix.coeffRef (3) = covariance_matrix.coeff (1);
547 covariance_matrix.coeffRef (6) = covariance_matrix.coeff (2);
548 covariance_matrix.coeffRef (7) = covariance_matrix.coeff (5);
550 return (static_cast<unsigned int> (point_count));
554 template <
typename Po
intT,
typename Scalar>
inline unsigned int
556 const std::vector<int> &indices,
557 Eigen::Matrix<Scalar, 3, 3> &covariance_matrix,
558 Eigen::Matrix<Scalar, 4, 1> ¢roid)
561 Eigen::Matrix<Scalar, 1, 9, Eigen::RowMajor> accu = Eigen::Matrix<Scalar, 1, 9, Eigen::RowMajor>::Zero ();
565 point_count = indices.size ();
566 for (std::vector<int>::const_iterator iIt = indices.begin (); iIt != indices.end (); ++iIt)
569 accu [0] += cloud[*iIt].x * cloud[*iIt].x;
570 accu [1] += cloud[*iIt].x * cloud[*iIt].y;
571 accu [2] += cloud[*iIt].x * cloud[*iIt].z;
572 accu [3] += cloud[*iIt].y * cloud[*iIt].y;
573 accu [4] += cloud[*iIt].y * cloud[*iIt].z;
574 accu [5] += cloud[*iIt].z * cloud[*iIt].z;
575 accu [6] += cloud[*iIt].x;
576 accu [7] += cloud[*iIt].y;
577 accu [8] += cloud[*iIt].z;
583 for (std::vector<int>::const_iterator iIt = indices.begin (); iIt != indices.end (); ++iIt)
589 accu [0] += cloud[*iIt].x * cloud[*iIt].x;
590 accu [1] += cloud[*iIt].x * cloud[*iIt].y;
591 accu [2] += cloud[*iIt].x * cloud[*iIt].z;
592 accu [3] += cloud[*iIt].y * cloud[*iIt].y;
593 accu [4] += cloud[*iIt].y * cloud[*iIt].z;
594 accu [5] += cloud[*iIt].z * cloud[*iIt].z;
595 accu [6] += cloud[*iIt].x;
596 accu [7] += cloud[*iIt].y;
597 accu [8] += cloud[*iIt].z;
601 accu /=
static_cast<Scalar
> (point_count);
605 centroid[0] = accu[6]; centroid[1] = accu[7]; centroid[2] = accu[8];
607 covariance_matrix.coeffRef (0) = accu [0] - accu [6] * accu [6];
608 covariance_matrix.coeffRef (1) = accu [1] - accu [6] * accu [7];
609 covariance_matrix.coeffRef (2) = accu [2] - accu [6] * accu [8];
610 covariance_matrix.coeffRef (4) = accu [3] - accu [7] * accu [7];
611 covariance_matrix.coeffRef (5) = accu [4] - accu [7] * accu [8];
612 covariance_matrix.coeffRef (8) = accu [5] - accu [8] * accu [8];
613 covariance_matrix.coeffRef (3) = covariance_matrix.coeff (1);
614 covariance_matrix.coeffRef (6) = covariance_matrix.coeff (2);
615 covariance_matrix.coeffRef (7) = covariance_matrix.coeff (5);
617 return (static_cast<unsigned int> (point_count));
621 template <
typename Po
intT,
typename Scalar>
inline unsigned int
624 Eigen::Matrix<Scalar, 3, 3> &covariance_matrix,
625 Eigen::Matrix<Scalar, 4, 1> ¢roid)
631 template <
typename Po
intT,
typename Scalar>
void
633 const Eigen::Matrix<Scalar, 4, 1> ¢roid,
640 while (cloud_iterator.
isValid ())
645 cloud_iterator.
reset ();
651 while (cloud_iterator.
isValid ())
653 cloud_out[i].x = cloud_iterator->x - centroid[0];
654 cloud_out[i].y = cloud_iterator->y - centroid[1];
655 cloud_out[i].z = cloud_iterator->z - centroid[2];
664 template <
typename Po
intT,
typename Scalar>
void
666 const Eigen::Matrix<Scalar, 4, 1> ¢roid,
669 cloud_out = cloud_in;
672 for (
size_t i = 0; i < cloud_in.
points.size (); ++i)
674 cloud_out[i].x -=
static_cast<float> (centroid[0]);
675 cloud_out[i].y -=
static_cast<float> (centroid[1]);
676 cloud_out[i].z -=
static_cast<float> (centroid[2]);
681 template <
typename Po
intT,
typename Scalar>
void
683 const std::vector<int> &indices,
684 const Eigen::Matrix<Scalar, 4, 1> ¢roid,
689 if (indices.size () == cloud_in.
points.size ())
696 cloud_out.
width =
static_cast<uint32_t
> (indices.size ());
699 cloud_out.
resize (indices.size ());
702 for (
size_t i = 0; i < indices.size (); ++i)
704 cloud_out[i].x =
static_cast<float> (cloud_in[indices[i]].x - centroid[0]);
705 cloud_out[i].y =
static_cast<float> (cloud_in[indices[i]].y - centroid[1]);
706 cloud_out[i].z =
static_cast<float> (cloud_in[indices[i]].z - centroid[2]);
711 template <
typename Po
intT,
typename Scalar>
void
714 const Eigen::Matrix<Scalar, 4, 1> ¢roid,
721 template <
typename Po
intT,
typename Scalar>
void
723 const Eigen::Matrix<Scalar, 4, 1> ¢roid,
724 Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic> &cloud_out,
730 while (cloud_iterator.
isValid ())
735 cloud_iterator.
reset ();
738 cloud_out = Eigen::Matrix<Scalar, 4, Eigen::Dynamic>::Zero (4, npts);
741 while (cloud_iterator.
isValid ())
743 cloud_out (0, i) = cloud_iterator->x - centroid[0];
744 cloud_out (1, i) = cloud_iterator->y - centroid[1];
745 cloud_out (2, i) = cloud_iterator->z - centroid[2];
752 template <
typename Po
intT,
typename Scalar>
void
754 const Eigen::Matrix<Scalar, 4, 1> ¢roid,
755 Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic> &cloud_out)
757 size_t npts = cloud_in.
size ();
759 cloud_out = Eigen::Matrix<Scalar, 4, Eigen::Dynamic>::Zero (4, npts);
761 for (
size_t i = 0; i < npts; ++i)
763 cloud_out (0, i) = cloud_in[i].x - centroid[0];
764 cloud_out (1, i) = cloud_in[i].y - centroid[1];
765 cloud_out (2, i) = cloud_in[i].z - centroid[2];
775 template <
typename Po
intT,
typename Scalar>
void
777 const std::vector<int> &indices,
778 const Eigen::Matrix<Scalar, 4, 1> ¢roid,
779 Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic> &cloud_out)
781 size_t npts = indices.size ();
783 cloud_out = Eigen::Matrix<Scalar, 4, Eigen::Dynamic>::Zero (4, npts);
785 for (
size_t i = 0; i < npts; ++i)
787 cloud_out (0, i) = cloud_in[indices[i]].x - centroid[0];
788 cloud_out (1, i) = cloud_in[indices[i]].y - centroid[1];
789 cloud_out (2, i) = cloud_in[indices[i]].z - centroid[2];
799 template <
typename Po
intT,
typename Scalar>
void
802 const Eigen::Matrix<Scalar, 4, 1> ¢roid,
803 Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic> &cloud_out)
809 template <
typename Po
intT,
typename Scalar>
inline void
811 Eigen::Matrix<Scalar, Eigen::Dynamic, 1> ¢roid)
816 centroid.setZero (boost::mpl::size<FieldList>::value);
821 int size =
static_cast<int> (cloud.
size ());
822 for (
int i = 0; i < size; ++i)
827 centroid /=
static_cast<Scalar
> (size);
831 template <
typename Po
intT,
typename Scalar>
inline void
833 const std::vector<int> &indices,
834 Eigen::Matrix<Scalar, Eigen::Dynamic, 1> ¢roid)
839 centroid.setZero (boost::mpl::size<FieldList>::value);
841 if (indices.empty ())
844 int nr_points =
static_cast<int> (indices.size ());
845 for (
int i = 0; i < nr_points; ++i)
850 centroid /=
static_cast<Scalar
> (nr_points);
854 template <
typename Po
intT,
typename Scalar>
inline void
857 Eigen::Matrix<Scalar, Eigen::Dynamic, 1> ¢roid)
863 template <
typename Po
intInT,
typename Po
intOutT>
size_t
870 for (
size_t i = 0; i < cloud.
size (); ++i)
873 for (
size_t i = 0; i < cloud.
size (); ++i)
882 template <
typename Po
intInT,
typename Po
intOutT>
size_t
884 const std::vector<int>& indices,
890 for (
size_t i = 0; i < indices.size (); ++i)
891 cp.
add (cloud[indices[i]]);
893 for (
size_t i = 0; i < indices.size (); ++i)
895 cp.
add (cloud[indices[i]]);
901 #endif //#ifndef PCL_COMMON_IMPL_CENTROID_H_
bool isFinite(const PointT &pt)
Tests if the 3D components of a point are all finite param[in] pt point to be tested.
Iterator class for point clouds with or without given indices.
size_t computeCentroid(const pcl::PointCloud< PointInT > &cloud, PointOutT ¢roid)
Compute the centroid of a set of points and return it as a point.
unsigned int computeMeanAndCovarianceMatrix(const pcl::PointCloud< PointT > &cloud, Eigen::Matrix< Scalar, 3, 3 > &covariance_matrix, Eigen::Matrix< Scalar, 4, 1 > ¢roid)
Compute the normalized 3x3 covariance matrix and the centroid of a given set of points in a single lo...
std::vector< int > indices
uint32_t width
The point cloud width (if organized as an image-structure).
Helper functor structure for n-D centroid estimation.
size_t getSize() const
Get the total number of points that were added.
pcl::PCLHeader header
The point cloud header.
std::vector< PointT, Eigen::aligned_allocator< PointT > > points
The point data.
void add(const PointT &point)
Add a new point to the centroid computation.
void demeanPointCloud(ConstCloudIterator< PointT > &cloud_iterator, const Eigen::Matrix< Scalar, 4, 1 > ¢roid, pcl::PointCloud< PointT > &cloud_out, int npts=0)
Subtract a centroid from a point cloud and return the de-meaned representation.
void resize(size_t n)
Resize the cloud.
unsigned int computeCovarianceMatrix(const pcl::PointCloud< PointT > &cloud, const Eigen::Matrix< Scalar, 4, 1 > ¢roid, Eigen::Matrix< Scalar, 3, 3 > &covariance_matrix)
Compute the 3x3 covariance matrix of a given set of points.
void computeNDCentroid(const pcl::PointCloud< PointT > &cloud, Eigen::Matrix< Scalar, Eigen::Dynamic, 1 > ¢roid)
General, all purpose nD centroid estimation for a set of points using their indices.
unsigned int computeCovarianceMatrixNormalized(const pcl::PointCloud< PointT > &cloud, const Eigen::Matrix< Scalar, 4, 1 > ¢roid, Eigen::Matrix< Scalar, 3, 3 > &covariance_matrix)
Compute normalized the 3x3 covariance matrix of a given set of points.
void get(PointOutT &point) const
Retrieve the current centroid.
unsigned int compute3DCentroid(ConstCloudIterator< PointT > &cloud_iterator, Eigen::Matrix< Scalar, 4, 1 > ¢roid)
Compute the 3D (X-Y-Z) centroid of a set of points and return it as a 3D vector.
A generic class that computes the centroid of points fed to it.
bool is_dense
True if no points are invalid (e.g., have NaN or Inf values).
uint32_t height
The point cloud height (if organized as an image-structure).