A simple file format for storing multi-dimensional point data. It consists of a text header (with the fields below), followed by the data in ASCII (w/ points on separate lines) or binary (a memory copy of the points vector of the PC).

PCD example

PCD example

writing PCD Files

#include <pcl/io/pcd_io.h>
#include <pcl/point_types.h>

int main (int argc, char** argv){
pcl::PointCloud<pcl::PointXYZ> cloud;
// Fill in the cloud data
cloud.width = 50;
cloud.height = 1;
cloud.is_dense = false;
cloud.points.resize (cloud.width*cloud.height);
for (size_t i+0; i<cloud.points.size(); ++i){
	cloud.points[i].x = 1024 * rand() / (RAND_MAX + 1.0f);
	cloud.points[i].y = 1024 * rand() / (RAND_MAX + 1.0f);
	cloud.points[i].z = 1024 * rand() / (RAND_MAX + 1.0f);
}
pcl::io::savePCDFileASCII ("test_pcd.pcd", cloud);
return (0);
}

reading PCD Files

#include <pcl/io/pcd_io.h>
#include <pcl/point_types.h>

int main (int argc, char** argv){
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZ>);
// Load the file
if (pcl::io::loadPCDFile<pcl::PointXYZ> ("test_pcd.pcd", *cloud) == -1)
{
	PCL_ERROR ("Couldn't_read_file_test_pcd.pcd_\\n");
	return (-1);
}
// Do some processing on the cloud here
return (0);
}