1.PCD文件的创建 pcl::PointCloud<pcl::PointXYZ> cloud; // Fill in the cloud data cloud.width = 500; cloud.height = 200; cloud.is_dense = false; cloud.points.resize(cloud.width * cloud.height); for (std::size_t i = 0; i < cloud.points.size(); ++i) { cloud.points[i].x =2 * rand() / (RAND_MAX + 1.0f); cloud.points[i].y =2 * rand() / (RAND_MAX + 1.0f); cloud.points[i].z = 2 * rand() / (RAND_MAX + 1.0f); } pcl::io::savePCDFileASCII("test_pcd.pcd", cloud); 2.PCD文件的读取 pcl::PointCloud<pcl::PointXYZ>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZ>); if (pcl::io::loadPCDFile<pcl::PointXYZ>("test_pcd.pcd", *cloud) == -1) //* load the file { PCL_ERROR("Couldn't read file test_pcd.pcd \n"); return (-1); } 3.点云数据的显示 pcl::visualization::CloudViewer viewer("Cloud Viewer"); viewer.showCloud(cloud); while(!viewer.wasStopped()) { }