PCL study notes-PCD (point cloud data) file format

PCL study notes-PCD (point cloud data) file format

Example of pcd file data

# .PCD v.7 - Point Cloud Data file format
VERSION .7
FIELDS x y z rgb
SIZE 4 4 4 4
TYPE F FFF
COUNT 1 1 1 1
WIDTH 213
HEIGHT 1
VIEWPOINT 0 0 0 1 0 0 0
POINTS 213
DATA ascii
0.93773 0.33763 0 4.2108e+06
0.90805 0.35641 0 4.2108e+06
  • PCD version
    Before the release of Point Cloud Library (PCL) version 1.0, the PCD file format had different revision numbers. These revision numbers are numbered with PCD_Vx (for example, PCD_V5, PCD_V6, PCD_V7, etc.), which represent the 0.x version number of the PCD file. However, the official release of the PCD file format in PCL is version 0.7 (PCD_V7).

  • File header format
    Each PCD file contains a file header, which determines and declares a certain characteristic of the point cloud data stored in the file. The PCD file header must be encoded in ASCII code. Each file header field and ascii point data specified in the PCD file are separated by a new line (\n). Starting from version 0.7, the PCD file header contains the following fields:

      ·VERSION –指定PCD文件版本
    
      ·FIELDS –指定一个点可以有的每一个维度和字段的名字。例如: FIELDS x y z # XYZ data FIELDS x y z rgb # XYZ + colors FIELDS x y z normal_xnormal_y normal_z # XYZ + surface normals FIELDS j1 j2 j3 # moment invariants ...
    
      ·SIZE –用字节数指定每一个维度的大小。例如: unsigned char/char has 1 byte unsigned short/short has 2 bytes unsignedint/int/float has 4 bytes double has 8 bytes
    
      ·TYPE –用一个字符指定每一个维度的类型。现在被接受的类型有: I –表示有符号类型int8(char)、int16(short)和int32(int); U – 表示无符号类型uint8(unsigned char)、uint16(unsigned short)和uint32(unsigned int); F –表示浮点类型。
    
      ·COUNT –指定每一个维度包含的元素数目。例如,x这个数据通常有一个元素,但是像VFH这样的特征描述子就有308个。实际上这是在给每一点引入n维直方图描述符的方法,把它们当做单个的连续存储块。默认情况下,如果没有COUNT,所有维度的数目被设置成1。
    
      ·WIDTH –用点的数量表示点云数据集的宽度。根据是有序点云还是无序点云,WIDTH有两层解释: 1)它能确定无序数据集的点云中点的个数(和下面的POINTS一样); 2)它能确定有序点云数据集的宽度(一行中点的数目)。 注意:有序点云数据集,意味着点云是类似于图像(或者矩阵)的结构,数据分为行和列。这种点云的实例包括立体摄像机和时间飞行摄像机生成的数据。有序数据集的优势在于,预先了解相邻点(和像素点类似)的关系,邻域操作更加高效,这样就加速了计算并降低了PCL中某些算法的成本。 例如: WIDTH 640 # 每行有640个点
    
      ·HEIGHT –用点的数目表示点云数据集的高度。类似于WIDTH ,HEIGHT也有两层解释: 1)它表示有序点云数据集的高度(行的总数); 2)对于无序数据集它被设置成1(被用来检查一个数据集是有序还是无序)。 有序点云例子: WIDTH 640 # 像图像一样的有序结构,有640行和480列, HEIGHT 480 # 这样该数据集中共有640*480=307200个点 无序点云例子: WIDTH 307200 HEIGHT 1 # 有307200个点的无序点云数据集
    
      ·VIEWPOINT–指定数据集中点云的获取视点。VIEWPOINT有可能在不同坐标系之间转换的时候应用,在辅助获取其他特征时也比较有用,例如曲面法线,在判断方向一致性时,需要知道视点的方位, 视点信息被指定为平移(txtytz)+四元数(qwqxqyqz)。默认值是: VIEWPOINT 0 0 0 1 0 0 0
    
      ·POINTS–指定点云中点的总数。从0.7版本开始,该字段就有点多余了,因此有可能在将来的版本中将它移除。 例子: POINTS 307200 #点云中点的总数为307200
    
      ·DATA –指定存储点云数据的数据类型。从0.7版本开始,支持两种数据类型:ascii和二进制。查看下一节可以获得更多细节。 注意:文件头最后一行(DATA)的下一个字节就被看成是点云的数据部分了,它会被解释为点云数据。 警告:PCD文件的文件头部分必须以上面的顺序精确指定,也就是如下顺序: VERSION、FIELDS、SIZE、TYPE、COUNT、WIDTH、HEIGHT、VIEWPOINT、POINTS、DATA 之间用换行隔开
    

Storage data type

In version 0.7, the .PCD file format stores data in two modes: If it is in ASCII format, each dot occupies a new line: p_1 p_2… p_n Note: Starting from PCL version 1.0.1, the string "nan" is used to represent NaN , This character indicates that the value of the point does not exist or is illegal, etc. In addition, in order to adapt to the use of "NaN" in the previous version to indicate that the value of the point does not exist or is illegal, PCL provides a binary executable file that converts NaN to nan

pcl_convert_NaN_nan:converts “NaN” values to “nan” values.
 (Note: Starting with PCL version 1.0.1 the string representation for NaN is “nan”.)
 
 用法实例:
 pcd_convert_NaN_nan input.pcd output.pcd

Other file formats

PLY是一种多边形文件格式,由Stanford大学的Turk等人设计开发;

STL是3D Systems公司创建的模型文件格式,主要应用于CAD、CAM领域;

OBJ是从几何学上定义的文件格式,首先由Wavefront Technologies开发;

X3D是符合ISO标准的基于XML的文件格式,表示3D计算机图形数据;

其他许多种格式。

Guess you like

Origin blog.csdn.net/m0_45388819/article/details/109964325