23 #include <pcl/common/pca.h>
24 #include <pcl/common/io.h>
25 #include <pcl/common/common.h>
47 magnitudeSumAbsolute = 0.;
48 magnitudeAverage = 0.;
49 magnitudeAverageAbsolute = 0.;
53 phaseSumAbsolute = 0.;
55 phaseAverageAbsolute = 0.;
58 centreOfGravity.assign(0.,0.,0.);
59 eigenValues.assign(0.,0.,0.);
60 eigenVectors[0].assign(0.,0.,0.);
61 eigenVectors[1].assign(0.,0.,0.);
62 eigenVectors[2].assign(0.,0.,0.);
63 orientedExtentsMin.assign(0.,0.,0.);
64 orientedExtentsMax.assign(0.,0.,0.);
66 planeIntersection.assign(0.,0.,0.);
67 planeIntersectionOk =
false;
71 inline void insert(
int index,
double magnitude,
double phase)
75 indices.push_back(index);
77 magnitudeSum += magnitude;
78 magnitudeSumAbsolute += fabs(magnitude);
81 phaseSumAbsolute += fabs(phase);
88 const std::string &magnitudeFloatMemberName,
89 const std::string &phaseFloatMemberName)
92 const double numPointsDbl =
static_cast<double>(numPoints);
95 magnitudeAverage = magnitudeSum / numPointsDbl;
96 magnitudeAverageAbsolute = magnitudeSumAbsolute / numPointsDbl;
99 phaseAverage = phaseSum / numPointsDbl;
100 phaseAverageAbsolute = phaseSumAbsolute / numPointsDbl;
104 pcl::copyPointCloud(inputPointCloud, indices, clusterCloud);
109 magnitudeMedian = stats.
median;
111 phaseMedian = stats.
median;
114 if (clusterCloud.points.size() >=3 ){
117 pcl::PCA<MLPointCloudXYZINormal::PointType> PCAFilter;
121 const Eigen::Vector3f eigenVector0Tmp = PCAFilter.getEigenVectors().col(0);
122 const Eigen::Vector3f eigenVector1Tmp = PCAFilter.getEigenVectors().col(1);
123 const Eigen::Vector3f eigenVector2Tmp = PCAFilter.getEigenVectors().col(2);
125 centreOfGravity.assign( meanTmp[0], meanTmp[1], meanTmp[2] );
126 eigenValues.assign( eigenValuesTmp[0], eigenValuesTmp[1], eigenValuesTmp[2] );
127 eigenVectors[0].assign( eigenVector0Tmp[0], eigenVector0Tmp[1], eigenVector0Tmp[2] );
128 eigenVectors[1].assign( eigenVector1Tmp[0], eigenVector1Tmp[1], eigenVector1Tmp[2] );
129 eigenVectors[2].assign( eigenVector2Tmp[0], eigenVector2Tmp[1], eigenVector2Tmp[2] );
133 PCAFilter.project(clusterCloud, tmpCloud);
134 pcl::PointXYZINormal minPoint, maxPoint;
135 pcl::getMinMax3D(tmpCloud, minPoint, maxPoint);
138 orientedExtentsMin[0] = minPoint.x;
139 orientedExtentsMin[1] = minPoint.y;
140 orientedExtentsMin[2] = minPoint.z;
141 orientedExtentsMax[0] = maxPoint.x;
142 orientedExtentsMax[1] = maxPoint.y;
143 orientedExtentsMax[2] = maxPoint.z;
147 Plane plane(planeNormal, planePoint);
148 Line line(centreOfGravity, centreOfGravity+eigenVectors[0]);
149 planeIntersectionOk = plane.
intersect(line, planeIntersection);
Project global and OS specific declarations.
Disables warnings from PCL headers which otherwise cannot be avoided.
Restores disabled warnings from PCL headers which otherwise cannot be avoided.
Class to define the geometry primitive 'Line' consisting of a position and a direction.
Class defining a plane in 3D.
bool intersect(const Line &l, Vector3 &intersection) const
Intersects this plane with line l and returns the intersection point in intersection.
A collection of statistical tool functions used in MLPCLSupport.
MLint64 MLint
A signed ML integer type with at least 64 bits used for index calculations on very large images even ...
std::shared_ptr< const POINT_CLOUD_TYPE > PCLMakeLocalNonDeletingSharedConstPtr(const POINT_CLOUD_TYPE &pntCloud)
Many pcl filters and classes require a boost shared pointer to the point cloud to be processed,...
Tvec3< MLfloat > Vector3f
A vector with three components of type float.
pcl::PointCloud< pcl::PointXYZINormal > MLPointCloudXYZINormal
The basic point cloud type used in the PCL MeVisLab binding.
Tvec4< MLfloat > Vector4f
A vector with four components of type float.
Small helper container managing some information about a cluster.
Vector3 eigenValues
Eigenvalues of the cluster.
double phaseSum
The sum of all point phases in the cluster.
Vector3 planeIntersection
Intersection of main axes of cluster with user plane.
Vector3 orientedExtentsMin
Minimum extents according to the eigen vectors.
double magnitudeSum
The sum of all point magnitudes in the cluster.
MLint numPoints
Number of points in the cluster.
double phaseSumAbsolute
The sum of all absolute point phases in the cluster.
StatisticalClusterInfo()
Constructor defaulting everything to an empty cluster.
double phaseMedian
The median of all point phases in the cluster.
double magnitudeMedian
The median of all point magnitudes in the cluster.
double phaseAverage
The average of all point phases in the cluster.
double phaseAverageAbsolute
The average of all point phases in the cluster.
double magnitudeSumAbsolute
The sum of all absolute point magnitudes in the cluster.
Vector3 centreOfGravity
Centre of gravity of the cluster.
std::vector< int > indices
List of point indices of the cluster.
bool planeIntersectionOk
True if intersection of main axes of cluster with user plane is valid, otherwise false.
double magnitudeAverageAbsolute
The average of all point magnitudes in the cluster.
void finalize(const MLPointCloudXYZINormal &inputPointCloud, const Vector3 &planeNormal, const Vector3 &planePoint, const std::string &magnitudeFloatMemberName, const std::string &phaseFloatMemberName)
To be called after last insert to finalise cluster calculations.
void clear()
Setting default values corresponding to an empty cluster.
Vector3 orientedExtentsMax
Minimum extents according to the eigen vectors.
double magnitudeAverage
The average of all point magnitudes in the cluster.
void insert(int index, double magnitude, double phase)
Inserting a new magnitude,phase pair updating statistics.