43 #include <pcl/point_cloud.h>
44 #include <pcl/type_traits.h>
45 #include <pcl/PointIndices.h>
46 #include <pcl/cloud_iterator.h>
65 template <
typename Po
intT,
typename Scalar>
inline unsigned int
67 Eigen::Matrix<Scalar, 4, 1> ¢roid);
69 template <
typename Po
intT>
inline unsigned int
71 Eigen::Vector4f ¢roid)
73 return (compute3DCentroid <PointT, float> (cloud_iterator, centroid));
76 template <
typename Po
intT>
inline unsigned int
78 Eigen::Vector4d ¢roid)
80 return (compute3DCentroid <PointT, double> (cloud_iterator, centroid));
91 template <
typename Po
intT,
typename Scalar>
inline unsigned int
93 Eigen::Matrix<Scalar, 4, 1> ¢roid);
95 template <
typename Po
intT>
inline unsigned int
97 Eigen::Vector4f ¢roid)
99 return (compute3DCentroid <PointT, float> (cloud, centroid));
102 template <
typename Po
intT>
inline unsigned int
104 Eigen::Vector4d ¢roid)
106 return (compute3DCentroid <PointT, double> (cloud, centroid));
119 template <
typename Po
intT,
typename Scalar>
inline unsigned int
122 Eigen::Matrix<Scalar, 4, 1> ¢roid);
124 template <
typename Po
intT>
inline unsigned int
127 Eigen::Vector4f ¢roid)
129 return (compute3DCentroid <PointT, float> (cloud, indices, centroid));
132 template <
typename Po
intT>
inline unsigned int
135 Eigen::Vector4d ¢roid)
137 return (compute3DCentroid <PointT, double> (cloud, indices, centroid));
150 template <
typename Po
intT,
typename Scalar>
inline unsigned int
153 Eigen::Matrix<Scalar, 4, 1> ¢roid);
155 template <
typename Po
intT>
inline unsigned int
158 Eigen::Vector4f ¢roid)
160 return (compute3DCentroid <PointT, float> (cloud, indices, centroid));
163 template <
typename Po
intT>
inline unsigned int
166 Eigen::Vector4d ¢roid)
168 return (compute3DCentroid <PointT, double> (cloud, indices, centroid));
184 template <
typename Po
intT,
typename Scalar>
inline unsigned int
186 const Eigen::Matrix<Scalar, 4, 1> ¢roid,
187 Eigen::Matrix<Scalar, 3, 3> &covariance_matrix);
189 template <
typename Po
intT>
inline unsigned int
191 const Eigen::Vector4f ¢roid,
192 Eigen::Matrix3f &covariance_matrix)
194 return (computeCovarianceMatrix<PointT, float> (cloud, centroid, covariance_matrix));
197 template <
typename Po
intT>
inline unsigned int
199 const Eigen::Vector4d ¢roid,
200 Eigen::Matrix3d &covariance_matrix)
202 return (computeCovarianceMatrix<PointT, double> (cloud, centroid, covariance_matrix));
218 template <
typename Po
intT,
typename Scalar>
inline unsigned int
220 const Eigen::Matrix<Scalar, 4, 1> ¢roid,
221 Eigen::Matrix<Scalar, 3, 3> &covariance_matrix);
223 template <
typename Po
intT>
inline unsigned int
225 const Eigen::Vector4f ¢roid,
226 Eigen::Matrix3f &covariance_matrix)
228 return (computeCovarianceMatrixNormalized<PointT, float> (cloud, centroid, covariance_matrix));
231 template <
typename Po
intT>
inline unsigned int
233 const Eigen::Vector4d ¢roid,
234 Eigen::Matrix3d &covariance_matrix)
236 return (computeCovarianceMatrixNormalized<PointT, double> (cloud, centroid, covariance_matrix));
252 template <
typename Po
intT,
typename Scalar>
inline unsigned int
255 const Eigen::Matrix<Scalar, 4, 1> ¢roid,
256 Eigen::Matrix<Scalar, 3, 3> &covariance_matrix);
258 template <
typename Po
intT>
inline unsigned int
261 const Eigen::Vector4f ¢roid,
262 Eigen::Matrix3f &covariance_matrix)
264 return (computeCovarianceMatrix<PointT, float> (cloud, indices, centroid, covariance_matrix));
267 template <
typename Po
intT>
inline unsigned int
270 const Eigen::Vector4d ¢roid,
271 Eigen::Matrix3d &covariance_matrix)
273 return (computeCovarianceMatrix<PointT, double> (cloud, indices, centroid, covariance_matrix));
289 template <
typename Po
intT,
typename Scalar>
inline unsigned int
292 const Eigen::Matrix<Scalar, 4, 1> ¢roid,
293 Eigen::Matrix<Scalar, 3, 3> &covariance_matrix);
295 template <
typename Po
intT>
inline unsigned int
298 const Eigen::Vector4f ¢roid,
299 Eigen::Matrix3f &covariance_matrix)
301 return (computeCovarianceMatrix<PointT, float> (cloud, indices, centroid, covariance_matrix));
304 template <
typename Po
intT>
inline unsigned int
307 const Eigen::Vector4d ¢roid,
308 Eigen::Matrix3d &covariance_matrix)
310 return (computeCovarianceMatrix<PointT, double> (cloud, indices, centroid, covariance_matrix));
328 template <
typename Po
intT,
typename Scalar>
inline unsigned int
331 const Eigen::Matrix<Scalar, 4, 1> ¢roid,
332 Eigen::Matrix<Scalar, 3, 3> &covariance_matrix);
334 template <
typename Po
intT>
inline unsigned int
337 const Eigen::Vector4f ¢roid,
338 Eigen::Matrix3f &covariance_matrix)
340 return (computeCovarianceMatrixNormalized<PointT, float> (cloud, indices, centroid, covariance_matrix));
343 template <
typename Po
intT>
inline unsigned int
346 const Eigen::Vector4d ¢roid,
347 Eigen::Matrix3d &covariance_matrix)
349 return (computeCovarianceMatrixNormalized<PointT, double> (cloud, indices, centroid, covariance_matrix));
366 template <
typename Po
intT,
typename Scalar>
inline unsigned int
369 const Eigen::Matrix<Scalar, 4, 1> ¢roid,
370 Eigen::Matrix<Scalar, 3, 3> &covariance_matrix);
372 template <
typename Po
intT>
inline unsigned int
375 const Eigen::Vector4f ¢roid,
376 Eigen::Matrix3f &covariance_matrix)
378 return (computeCovarianceMatrixNormalized<PointT, float> (cloud, indices, centroid, covariance_matrix));
381 template <
typename Po
intT>
inline unsigned int
384 const Eigen::Vector4d ¢roid,
385 Eigen::Matrix3d &covariance_matrix)
387 return (computeCovarianceMatrixNormalized<PointT, double> (cloud, indices, centroid, covariance_matrix));
402 template <
typename Po
intT,
typename Scalar>
inline unsigned int
404 Eigen::Matrix<Scalar, 3, 3> &covariance_matrix,
405 Eigen::Matrix<Scalar, 4, 1> ¢roid);
407 template <
typename Po
intT>
inline unsigned int
409 Eigen::Matrix3f &covariance_matrix,
410 Eigen::Vector4f ¢roid)
412 return (computeMeanAndCovarianceMatrix<PointT, float> (cloud, covariance_matrix, centroid));
415 template <
typename Po
intT>
inline unsigned int
417 Eigen::Matrix3d &covariance_matrix,
418 Eigen::Vector4d ¢roid)
420 return (computeMeanAndCovarianceMatrix<PointT, double> (cloud, covariance_matrix, centroid));
436 template <
typename Po
intT,
typename Scalar>
inline unsigned int
439 Eigen::Matrix<Scalar, 3, 3> &covariance_matrix,
440 Eigen::Matrix<Scalar, 4, 1> ¢roid);
442 template <
typename Po
intT>
inline unsigned int
445 Eigen::Matrix3f &covariance_matrix,
446 Eigen::Vector4f ¢roid)
448 return (computeMeanAndCovarianceMatrix<PointT, float> (cloud, indices, covariance_matrix, centroid));
451 template <
typename Po
intT>
inline unsigned int
454 Eigen::Matrix3d &covariance_matrix,
455 Eigen::Vector4d ¢roid)
457 return (computeMeanAndCovarianceMatrix<PointT, double> (cloud, indices, covariance_matrix, centroid));
473 template <
typename Po
intT,
typename Scalar>
inline unsigned int
476 Eigen::Matrix<Scalar, 3, 3> &covariance_matrix,
477 Eigen::Matrix<Scalar, 4, 1> ¢roid);
479 template <
typename Po
intT>
inline unsigned int
482 Eigen::Matrix3f &covariance_matrix,
483 Eigen::Vector4f ¢roid)
485 return (computeMeanAndCovarianceMatrix<PointT, float> (cloud, indices, covariance_matrix, centroid));
488 template <
typename Po
intT>
inline unsigned int
491 Eigen::Matrix3d &covariance_matrix,
492 Eigen::Vector4d ¢roid)
494 return (computeMeanAndCovarianceMatrix<PointT, double> (cloud, indices, covariance_matrix, centroid));
508 template <
typename Po
intT,
typename Scalar>
inline unsigned int
510 Eigen::Matrix<Scalar, 3, 3> &covariance_matrix);
512 template <
typename Po
intT>
inline unsigned int
514 Eigen::Matrix3f &covariance_matrix)
516 return (computeCovarianceMatrix<PointT, float> (cloud, covariance_matrix));
519 template <
typename Po
intT>
inline unsigned int
521 Eigen::Matrix3d &covariance_matrix)
523 return (computeCovarianceMatrix<PointT, double> (cloud, covariance_matrix));
538 template <
typename Po
intT,
typename Scalar>
inline unsigned int
541 Eigen::Matrix<Scalar, 3, 3> &covariance_matrix);
543 template <
typename Po
intT>
inline unsigned int
546 Eigen::Matrix3f &covariance_matrix)
548 return (computeCovarianceMatrix<PointT, float> (cloud, indices, covariance_matrix));
551 template <
typename Po
intT>
inline unsigned int
554 Eigen::Matrix3d &covariance_matrix)
556 return (computeCovarianceMatrix<PointT, double> (cloud, indices, covariance_matrix));
571 template <
typename Po
intT,
typename Scalar>
inline unsigned int
574 Eigen::Matrix<Scalar, 3, 3> &covariance_matrix);
576 template <
typename Po
intT>
inline unsigned int
579 Eigen::Matrix3f &covariance_matrix)
581 return (computeCovarianceMatrix<PointT, float> (cloud, indices, covariance_matrix));
584 template <
typename Po
intT>
inline unsigned int
587 Eigen::Matrix3d &covariance_matrix)
589 return (computeCovarianceMatrix<PointT, double> (cloud, indices, covariance_matrix));
611 template <
typename Po
intT,
typename Scalar>
inline unsigned int
613 Eigen::Matrix<Scalar, 3, 1>& centroid,
614 Eigen::Matrix<Scalar, 3, 1>& obb_center,
615 Eigen::Matrix<Scalar, 3, 1>& obb_dimensions,
616 Eigen::Matrix<Scalar, 3, 3>& obb_rotational_matrix);
638 template <
typename Po
intT,
typename Scalar>
inline unsigned int
641 Eigen::Matrix<Scalar, 3, 1>& centroid,
642 Eigen::Matrix<Scalar, 3, 1>& obb_center,
643 Eigen::Matrix<Scalar, 3, 1>& obb_dimensions,
644 Eigen::Matrix<Scalar, 3, 3>& obb_rotational_matrix);
654 template <
typename Po
intT,
typename Scalar>
void
656 const Eigen::Matrix<Scalar, 4, 1> ¢roid,
660 template <
typename Po
intT>
void
662 const Eigen::Vector4f ¢roid,
666 return (demeanPointCloud<PointT, float> (cloud_iterator, centroid, cloud_out, npts));
669 template <
typename Po
intT>
void
671 const Eigen::Vector4d ¢roid,
675 return (demeanPointCloud<PointT, double> (cloud_iterator, centroid, cloud_out, npts));
684 template <
typename Po
intT,
typename Scalar>
void
686 const Eigen::Matrix<Scalar, 4, 1> ¢roid,
689 template <
typename Po
intT>
void
691 const Eigen::Vector4f ¢roid,
694 return (demeanPointCloud<PointT, float> (cloud_iterator, centroid, cloud_out));
697 template <
typename Po
intT>
void
699 const Eigen::Vector4d ¢roid,
702 return (demeanPointCloud<PointT, double> (cloud_iterator, centroid, cloud_out));
712 template <
typename Po
intT,
typename Scalar>
void
715 const Eigen::Matrix<Scalar, 4, 1> ¢roid,
718 template <
typename Po
intT>
void
721 const Eigen::Vector4f ¢roid,
724 return (demeanPointCloud<PointT, float> (cloud_in, indices, centroid, cloud_out));
727 template <
typename Po
intT>
void
730 const Eigen::Vector4d ¢roid,
733 return (demeanPointCloud<PointT, double> (cloud_in, indices, centroid, cloud_out));
743 template <
typename Po
intT,
typename Scalar>
void
746 const Eigen::Matrix<Scalar, 4, 1> ¢roid,
749 template <
typename Po
intT>
void
752 const Eigen::Vector4f ¢roid,
755 return (demeanPointCloud<PointT, float> (cloud_in, indices, centroid, cloud_out));
758 template <
typename Po
intT>
void
761 const Eigen::Vector4d ¢roid,
764 return (demeanPointCloud<PointT, double> (cloud_in, indices, centroid, cloud_out));
776 template <
typename Po
intT,
typename Scalar>
void
778 const Eigen::Matrix<Scalar, 4, 1> ¢roid,
779 Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic> &cloud_out,
782 template <
typename Po
intT>
void
784 const Eigen::Vector4f ¢roid,
785 Eigen::MatrixXf &cloud_out,
788 return (demeanPointCloud<PointT, float> (cloud_iterator, centroid, cloud_out, npts));
791 template <
typename Po
intT>
void
793 const Eigen::Vector4d ¢roid,
794 Eigen::MatrixXd &cloud_out,
797 return (demeanPointCloud<PointT, double> (cloud_iterator, centroid, cloud_out, npts));
808 template <
typename Po
intT,
typename Scalar>
void
810 const Eigen::Matrix<Scalar, 4, 1> ¢roid,
811 Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic> &cloud_out);
813 template <
typename Po
intT>
void
815 const Eigen::Vector4f ¢roid,
816 Eigen::MatrixXf &cloud_out)
818 return (demeanPointCloud<PointT, float> (cloud_in, centroid, cloud_out));
821 template <
typename Po
intT>
void
823 const Eigen::Vector4d ¢roid,
824 Eigen::MatrixXd &cloud_out)
826 return (demeanPointCloud<PointT, double> (cloud_in, centroid, cloud_out));
838 template <
typename Po
intT,
typename Scalar>
void
841 const Eigen::Matrix<Scalar, 4, 1> ¢roid,
842 Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic> &cloud_out);
844 template <
typename Po
intT>
void
847 const Eigen::Vector4f ¢roid,
848 Eigen::MatrixXf &cloud_out)
850 return (demeanPointCloud<PointT, float> (cloud_in, indices, centroid, cloud_out));
853 template <
typename Po
intT>
void
856 const Eigen::Vector4d ¢roid,
857 Eigen::MatrixXd &cloud_out)
859 return (demeanPointCloud<PointT, double> (cloud_in, indices, centroid, cloud_out));
871 template <
typename Po
intT,
typename Scalar>
void
874 const Eigen::Matrix<Scalar, 4, 1> ¢roid,
875 Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic> &cloud_out);
877 template <
typename Po
intT>
void
880 const Eigen::Vector4f ¢roid,
881 Eigen::MatrixXf &cloud_out)
883 return (demeanPointCloud<PointT, float> (cloud_in, indices, centroid, cloud_out));
886 template <
typename Po
intT>
void
889 const Eigen::Vector4d ¢roid,
890 Eigen::MatrixXd &cloud_out)
892 return (demeanPointCloud<PointT, double> (cloud_in, indices, centroid, cloud_out));
896 template<
typename Po
intT,
typename Scalar>
899 using Pod =
typename traits::POD<PointT>::type;
902 : centroid_ (centroid),
903 p_ (reinterpret_cast<const
Pod&>(p)) { }
907 using T =
typename pcl::traits::datatype<PointT, Key>::type;
908 const std::uint8_t* raw_ptr =
reinterpret_cast<const std::uint8_t*
>(&p_) + pcl::traits::offset<PointT, Key>::value;
909 const T* data_ptr =
reinterpret_cast<const T*
>(raw_ptr);
912 if (!std::isfinite (*data_ptr))
918 centroid_[f_idx_++] += *data_ptr;
923 Eigen::Matrix<Scalar, Eigen::Dynamic, 1> ¢roid_;
933 template <
typename Po
intT,
typename Scalar>
inline void
935 Eigen::Matrix<Scalar, Eigen::Dynamic, 1> ¢roid);
937 template <
typename Po
intT>
inline void
939 Eigen::VectorXf ¢roid)
941 return (computeNDCentroid<PointT, float> (cloud, centroid));
944 template <
typename Po
intT>
inline void
946 Eigen::VectorXd ¢roid)
948 return (computeNDCentroid<PointT, double> (cloud, centroid));
958 template <
typename Po
intT,
typename Scalar>
inline void
961 Eigen::Matrix<Scalar, Eigen::Dynamic, 1> ¢roid);
963 template <
typename Po
intT>
inline void
966 Eigen::VectorXf ¢roid)
968 return (computeNDCentroid<PointT, float> (cloud, indices, centroid));
971 template <
typename Po
intT>
inline void
974 Eigen::VectorXd ¢roid)
976 return (computeNDCentroid<PointT, double> (cloud, indices, centroid));
986 template <
typename Po
intT,
typename Scalar>
inline void
989 Eigen::Matrix<Scalar, Eigen::Dynamic, 1> ¢roid);
991 template <
typename Po
intT>
inline void
994 Eigen::VectorXf ¢roid)
996 return (computeNDCentroid<PointT, float> (cloud, indices, centroid));
999 template <
typename Po
intT>
inline void
1002 Eigen::VectorXd ¢roid)
1004 return (computeNDCentroid<PointT, double> (cloud, indices, centroid));
1009 #include <pcl/common/impl/accumulators.hpp>
1075 template <
typename Po
intT>
1099 template <
typename Po
intOutT>
void
1100 get (PointOutT& point)
const;
1106 return (num_points_);
1113 std::size_t num_points_ = 0;
1134 template <
typename Po
intInT,
typename Po
intOutT> std::size_t
1136 PointOutT& centroid);
1146 template <
typename Po
intInT,
typename Po
intOutT> std::size_t
1149 PointOutT& centroid);
1153 #include <pcl/common/impl/centroid.hpp>
A generic class that computes the centroid of points fed to it.
std::size_t getSize() const
Get the total number of points that were added.
void get(PointOutT &point) const
Retrieve the current centroid.
void add(const PointT &point)
Add a new point to the centroid computation.
Iterator class for point clouds with or without given indices.
PointCloud represents the base class in PCL for storing collections of 3D points.
unsigned int computeCentroidAndOBB(const pcl::PointCloud< PointT > &cloud, Eigen::Matrix< Scalar, 3, 1 > ¢roid, Eigen::Matrix< Scalar, 3, 1 > &obb_center, Eigen::Matrix< Scalar, 3, 1 > &obb_dimensions, Eigen::Matrix< Scalar, 3, 3 > &obb_rotational_matrix)
Compute centroid, OBB (Oriented Bounding Box), PCA axes of a given set of points.
std::size_t computeCentroid(const pcl::PointCloud< PointInT > &cloud, PointOutT ¢roid)
Compute the centroid of a set of points and return it as a point.
#define PCL_MAKE_ALIGNED_OPERATOR_NEW
Macro to signal a class requires a custom allocator.
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 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...
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.
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.
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.
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.
Defines functions, macros and traits for allocating and using memory.
IndicesAllocator<> Indices
Type used for indices in PCL.
Defines all the PCL and non-PCL macros used.
Helper functor structure for n-D centroid estimation.
NdCentroidFunctor(const PointT &p, Eigen::Matrix< Scalar, Eigen::Dynamic, 1 > ¢roid)
typename traits::POD< PointT >::type Pod
A point structure representing Euclidean xyz coordinates, and the RGB color.
typename boost::fusion::result_of::as_vector< typename boost::mpl::filter_view< boost::mpl::vector< AccumulatorXYZ, AccumulatorNormal, AccumulatorCurvature, AccumulatorRGBA, AccumulatorIntensity, AccumulatorLabel >, IsAccumulatorCompatible< PointT > > >::type type