PCL学习(一)从PLY文件读入点云数据

#include   
#include   
#include   
#include 

int main(int argc, char** argv)
{
	pcl::PointCloud::Ptr cloud(new pcl::PointCloud);

	if (pcl::io::loadPLYFile("model.ply", *cloud) == -1) //* load the file  
	{
		PCL_ERROR("Couldn't read file test_pcd.pcd \n");
		system("PAUSE");
		return (-1);
	}
	std::cout << "Loaded "
		<< cloud->width * cloud->height
		<< " data points from test_pcd.pcd with the following fields: "
		<< std::endl;
	for (size_t i = 0; i < cloud->points.size(); ++i)
		std::cout << "    " << cloud->points[i].x
		<< " " << cloud->points[i].y
		<< " " << cloud->points[i].z
		<< std::endl;
	//std::string filename("test.pcd");
	//pcl::PCDWriter writer;
	//writer.write(filename, *cloud);

	system("PAUSE");
	return (0);
}

  上面这段代码从ply文件中读入点云

#include   
#include   
#include   
#include 
#include 

int main(int argc, char** argv)
{
	pcl::PointCloud::Ptr cloud(new pcl::PointCloud);

	if (pcl::io::loadPLYFile("model.ply", *cloud) == -1) //* load the file  
	{
		PCL_ERROR("Couldn't read file test_pcd.pcd \n");
		system("PAUSE");
		return (-1);
	}
	//pcl::StatisticalOutlierRemoval::applyFileter()
	pcl::visualization::CloudViewer viewer("Viewer");
	viewer.showCloud(cloud);

	system("PAUSE");
	return (0);
}

  将读入的ply文件可视化出来

PCL学习(一)从PLY文件读入点云数据_第1张图片

转载于:https://www.cnblogs.com/BambooEatPanda/p/7551825.html

你可能感兴趣的:(PCL学习(一)从PLY文件读入点云数据)