1 #ifndef PCL_FEATURES_FROM_MESHES_H_ 2 #define PCL_FEATURES_FROM_MESHES_H_ 4 #include <pcl/features/normal_3d.h> 16 template <
typename Po
intT,
typename Po
intNT>
inline void 19 int nr_points = static_cast<int>(cloud.
points.size());
20 int nr_polygons = static_cast<int>(polygons.size());
25 normals.
points.resize(nr_points);
27 for (
int i = 0; i < nr_points; ++i )
28 normals.
points[i].getNormalVector3fMap() = Eigen::Vector3f::Zero();
33 for (
int i = 0; i < nr_polygons; ++i )
35 const int nr_points_polygon = (int)polygons[i].vertices.size();
36 if (nr_points_polygon < 3)
continue;
39 Eigen::Vector3f vec_a_b = cloud.
points[polygons[i].vertices[0]].getVector3fMap() - cloud.
points[polygons[i].vertices[1]].getVector3fMap();
40 Eigen::Vector3f vec_a_c = cloud.
points[polygons[i].vertices[0]].getVector3fMap() - cloud.
points[polygons[i].vertices[2]].getVector3fMap();
41 Eigen::Vector3f normal = vec_a_b.cross(vec_a_c);
45 for (
int j = 0; j < nr_points_polygon; ++j )
46 normals.
points[polygons[i].vertices[j]].getNormalVector3fMap() += normal;
49 for (
int i = 0; i < nr_points; ++i )
51 normals.
points[i].getNormalVector3fMap().normalize();
64 template <
typename Po
intT,
typename Po
intNT>
inline void 67 std::vector<Eigen::Matrix3d, Eigen::aligned_allocator<Eigen::Matrix3d> >& covariances,
68 double epsilon = 0.001)
72 int nr_points = static_cast<int>(cloud.
points.size());
73 covariances.resize(nr_points);
74 for (
int i = 0; i < nr_points; ++i)
76 Eigen::Vector3d normal(normals.
points[i].normal_x,
77 normals.
points[i].normal_y,
78 normals.
points[i].normal_z);
85 y = y - normal(1) * normal;
88 rot.row(0) = normal.cross(rot.row(1));
95 covariances[i] = rot.transpose()*cov*rot;
103 #endif // PCL_FEATURES_FROM_MESHES_H_ std::vector< PointT, Eigen::aligned_allocator< PointT > > points
The point data.
uint32_t height
The point cloud height (if organized as an image-structure).
void flipNormalTowardsViewpoint(const PointT &point, float vp_x, float vp_y, float vp_z, Eigen::Matrix< Scalar, 4, 1 > &normal)
Flip (in place) the estimated normal of a point towards a given viewpoint.
uint32_t width
The point cloud width (if organized as an image-structure).
PointCloud represents the base class in PCL for storing collections of 3D points.
pcl::PCLHeader header
The point cloud header.
void computeApproximateCovariances(const pcl::PointCloud< PointT > &cloud, const pcl::PointCloud< PointNT > &normals, std::vector< Eigen::Matrix3d, Eigen::aligned_allocator< Eigen::Matrix3d > > &covariances, double epsilon=0.001)
Compute GICP-style covariance matrices given a point cloud and the corresponding surface normals.
void computeApproximateNormals(const pcl::PointCloud< PointT > &cloud, const std::vector< pcl::Vertices > &polygons, pcl::PointCloud< PointNT > &normals)
Compute approximate surface normals on a mesh.