Introduction
PCD is the native file format of the Point Cloud Library (PCL), an open source C++ library for processing point clouds that is widely used in robotics and computer vision. Depth cameras and lidar sensors on robots are often recorded to PCD files for later processing.
A PCD file can store any set of fields per point, such as position, colour, normal or intensity, and can keep the grid layout of an organised cloud from a depth camera, where points are arranged in rows and columns like the pixels of an image.
Structure
Every PCD file starts with a text header. FIELDS names each value of a
point, SIZE gives its size in bytes, TYPE whether it is a
signed integer (I), unsigned integer (U) or float
(F), and COUNT how many elements it has. WIDTH
and HEIGHT give the layout, with a height of 1 for an unorganised cloud,
VIEWPOINT the sensor’s position and orientation, and POINTS
the total. The last header line, DATA, says how the points follow:
ascii, binary or binary_compressed.
# .PCD v0.7 - Point Cloud Data file format
VERSION 0.7
FIELDS x y z intensity
SIZE 4 4 4 4
TYPE F F F F
COUNT 1 1 1 1
WIDTH 3
HEIGHT 1
VIEWPOINT 0 0 0 1 0 0 0
POINTS 3
DATA ascii
0.0 0.0 0.0 12
1.0 0.0 0.0 40
0.0 1.0 0.0 33
In this reference
- Header and data – every header line and how PCL reads it, field types and sizes, packed colour, the ascii, binary and binary_compressed forms, the LZF byte stream, NaN and is_dense, and PCL’s field names, with worked bytes
Not described
Known, not yet covered
- Viewer: the explorer shows the header entry by entry (with the unknown-keyword and prefix-matching rules), the fields with the names the reference lists (PCL's point types and the Ouster, Velodyne and LIO-SAM drivers), every point of all three DATA forms in pages (an LZF decoder written from the lzf.cpp rules, with every item of the stream listed),
rgbandrgbaas colours, padding fields, array fields, a 3D view (a regular sample above 1,000,000 points; every point stays in the table), the grid of an organised cloud, and the problems the reference's rules give (header order and prefix matching, size, type and count mismatches, invalid types, POINTS against WIDTH × HEIGHT, short files, the compressed sizes, the ASCII bad-line rule, bytes after the data, nan and inf againstis_dense). Not covered: the units and coordinate system (not in the file), applying VIEWPOINT to the 3D view (it is shown, not applied), a compressed block of more than 2 GiB (one typed array: the points are not shown, with the reason), and a comparison with PCL's own tools (pcl_pcd2ply and pcl_viewer are not installed here). The ASCII reader follows PCL's word rules (a line is ended by a line feed only, only a line of length 0 is skipped, the word nan clears is_dense,infinityand12abcare read as PCL reads them), and every word of a long header line or ASCII point and every element of an array is a node of the Structure tree, in groups past 400; the Points table shows the first 8 values of an array and says so. A Kodak Photo CD file named .pcd keeps a neutral entry in the registry, so it is not called an invalid PCL file. The viewer's own CR LF handling of a blank line follows PCL on Linux and macOS (the CR makes the line non-empty); PCL on Windows reads the file in text mode and would skip it. - Viewer: every number PCL reads from text is read here by one model of C++
std::istringstream >> Tin the classic locale (explorer/formats/pcd/stream.js), as pcd_io.cpp and file_io.h use it. In the header, one stream is made over each whole line: SIZE and COUNT are read asint, WIDTH and HEIGHT asunsigned int, POINTS assize_t, VIEWPOINT as sevenfloats. A word with a number in front of other characters is read as that number and is a note, not an error (WIDTH 2abcand2.5are 2,COUNT 1abc,2.5and1e0are 1, 2 and 1,SIZE 4abcand4.0are 4, a VIEWPOINT word1.5abcis 1.5,0x10is 0); the characters left over are what the next value on the line is read from, soSIZE 4abc 4reads 4 and then 0. A word with no number in front stores 0 and stops every later value on that line: WIDTH and HEIGHT then refuse the file as PCL does (a thrown exception), a COUNT of 0 removes the field, and in VIEWPOINT the Overview says the line is present, which values PCL read as written, and that the rest are not determined by the file. An unsigned value written with a minus sign wraps (WIDTH -1is 4,294,967,295,POINTS -1is 2^64 - 1), a value out of range is the largest or smallest value and fails the stream, and WIDTH × HEIGHT is compared with POINTS as a 32-bit product, as PCL does. In ASCII data the same model reads each word as the field's type (2.5in an integer field is 2,-1in an unsigned field wraps, 300 in a U 1 field is 44), then falls back toatofas copyStringValue does. Where the C++ standard leaves a result open the page says so and shows no number: the variables PCL declares without a value (int col_type,float x, y, z, w) after a failed stream, and a double that does not fit an integer type after theatoffallback. Not covered: where libstdc++ (GCC, used for PCL on Linux) and libc++ (Clang on macOS) differ for float and double the model follows libstdc++ and the C++11 text; libc++ reads a float word such as1.5abcor2abcas a failure (value 0), reads0x10as 16, gives infinity for an overflow and fails on a denormal; this was probed with the system clang++ (scripts/pcd/streamprobe.cpp) and a PCL built on macOS would differ on those words. A float is rounded once from a double, not by strtof, which could differ in the last bit in rare half-way cases. PCL itself is not run, so none of this is compared with its own output; a POINTS whose data buffer passes the largest vector is reported as the uncaught std::length_error it is in PCL, but one that merely exceeds the machine's memory (std::bad_alloc, or an overcommitted allocation) is not judged. - Viewer: a VIEWPOINT line with fewer than seven values is fatal, as in PCL. The word nan in an ASCII field of SIZE 1 (TYPE I or U) is a problem that says is_dense stays true, because PCL's 8-bit readers have no nan check; in a wider integer field the word nan is stored as 0 (the quiet NaN of an integer type) and clears is_dense.
Links
Software
- CloudCompare – free open source point cloud and mesh tool (Windows, macOS, Linux)
- pcl_viewer – the viewer that comes with the Point Cloud Library
Developers
- Point Cloud Library – the point cloud processing library that defines the format (C++)
- Open3D – 3D data library that reads and writes PCD (Python, C++)
Reference
- The PCD (Point Cloud Data) file format – the Point Cloud Library’s description of the format