ylongzh 发表于 2015-5-26 10:00
整个slides的最后就是一个现成的cpp
就是这个吧
#include <pcl/common/common.h>
#include <pcl/io/pcd_io.h>
#include <pcl/features/normal_3d_omp.h>
#include <pcl/surface/mls.h>
#include <pcl/surface/poisson.h>
#include <pcl/io/vtk_io.h>
using namespace pcl;
int
main (int argc, char **argv)
{
if (argc != 3)
{
PCL_ERROR ("Syntax: %s input.pcd output.ply\n", argv[0]);
return -1;
}
PointCloud<PointXYZ>::Ptr cloud (new PointCloud<PointXYZ> ());
io::loadPCDFile (argv[1], *cloud);
MovingLeastSquares<PointXYZ, PointXYZ> mls;
mls.setInputCloud (cloud);
mls.setSearchRadius (0.01);
mls.setPolynomialFit (true);
mls.setPolynomialOrder (2);
mls.setUpsamplingMethod (MovingLeastSquares<PointXYZ, PointXYZ>::SAMPLE_LOCAL_PLANE);
mls.setUpsamplingRadius (0.005);
mls.setUpsamplingStepSize (0.003);
PointCloud<PointXYZ>::Ptr cloud_smoothed (new PointCloud<PointXYZ> ());
mls.process (*cloud_smoothed);
NormalEstimationOMP<PointXYZ, Normal> ne;
ne.setNumberOfThreads (8);
ne.setInputCloud (cloud_smoothed);
ne.setRadiusSearch (0.01);
Eigen::Vector4f centroid;
compute3DCentroid (*cloud_smoothed, centroid);
ne.setViewPoint (centroid[0], centroid[1], centroid[2]);
PointCloud<Normal>::Ptr cloud_normals (new PointCloud<Normal> ());
ne.compute (*cloud_normals);
for (size_t i = 0; i < cloud_normals->size (); ++i)
{
cloud_normals->points.normal_x *= -1;
cloud_normals->points.normal_y *= -1;
cloud_normals->points.normal_z *= -1;
}
PointCloud<PointNormal>::Ptr cloud_smoothed_normals (new PointCloud<PointNormal> ());
concatenateFields (*cloud_smoothed, *cloud_normals, *cloud_smoothed_normals);
Poisson<PointNormal> poisson;
poisson.setDepth (9);
poisson.setInputCloud (cloud_smoothed_normals);
PolygonMesh mesh;
poisson.reconstruct (mesh);
io::saveVTKFile (argv[2], mesh);
return 0;
}
我这个显示无法找到程序,系统找不到指定文件,此外,io::loadPCDFile (argv[1], *cloud);
这个arv[1]就是pcd文件名字吗?好像有点怪啊,谢谢你啦! |