浅述pcd,ply,out文件格式

三维重建过程中用到的一些文件格式,在这里做一下记录。

PCD

point cloud data, PCD并不是第一种支持3D点云数据的文件类型。
参考自 http://pointclouds.org/documentation/tutorials/pcd_file_format.php
格式示例如下:

# .PCD v0.7 - Point Cloud Data file format
VERSION 0.7
FIELDS x y z
SIZE 4 4 4
TYPE F F F
COUNT 1 1 1
WIDTH 5
HEIGHT 1
VIEWPOINT 0 0 0 1 0 0 0
POINTS 5
DATA ascii
0.35222197 -0.15188313 -0.10639524
-0.3974061 -0.47310591 0.29260206
-0.73189831 0.66710472 0.44130373
-0.73476553 0.85458088 -0.036173344
-0.46070004 -0.2774682 -0.91676188
  • VERSION
    指定PCD文件版本号,目前正式的是v0.7
  • FIELDS
    指定点拥有的每一维/通道数据的名称。
FIELDS x y z                                # XYZ data
FIELDS x y z rgb                            # XYZ + colors
FIELDS x y z normal_x normal_y normal_z     # XYZ + surface normals
FIELDS j1 j2 j3                             # moment invariants
  • SIZE
    指定点的每一维数据的字节(bytes)大小。
unsigned char/char has 1 byte
unsigned short/short has 2 bytes
unsigned int/int/float has 4 bytes
double has 8 bytes
  • TYPE
    指定点每个维度的类型为char。
I - represents signed types int8 (char), int16 (short), and int32 (int)
U - represents unsigned types uint8 (unsigned char), uint16 (unsigned short), uint32 (unsigned int)
F - represents float types
  • COUNT
    指定每一维数据包含的元素数。例如,x数据一般拥有1个元素,但是一个像VFH一样的特征描述子拥有308个元素。本质上这是将n-D直方图描述子应用到每一个点的一种方式,可以将它们当成一个单个连续的存储块来对待。如果COUNT 不明确设定,所有维度的count都会默认设置为1。

  • WIDTH
    指定点云数据集点数目的宽度。

    • 指定不规则数据点云(等价于下文的POINTS)中点的总数
    • 它可以指定一个规则点云数据集每一行点的总数
  • HEIGHT
    指定点云数据集点数目的高度。

    • 非规则数据集的HEIGHT设置为1(用于检验一个数据集是否是规则的)
    • 指定规则数据点云集的总行数
  • VIEWPOINT
    指定数据集中点的获取视角。视角信息由一个平移(tx ty tz)+四元组(qw qx qy qz)确定。默认值是: 0 0 0 1 0 0 0

  • POINTS
    指定点云中点的总数。(与上面WIDTH和HEIGHT是有些重复的)

  • DATA
    指定点云数据被存储的数据类型。0.7版本支持ascii和binary两种数据类型。

PLY

Polygon File Format, 该格式主要用以储存立体扫描结果的三维数值,透过多边形片面的集合描述三维物体,与其他格式相较之下这是较为简单的方法。它可以储存的资讯包含颜色、透明度、表面法向量、材质座标与资料可信度,并能对多边形的正反两面设定不同的属性。
参考自 https://zh.wikipedia.org/wiki/PLY
格式示例如下:

 ply
 format ascii 1.0
 element vertex 4
 property float x
 property float y
 property float z
 element face 4
 property list uchar int vertex_index
 end_header
 0 3 0
 2.449 -1.0 -1.414
 0 -1 2.828
 -2.449 -1.0 -1.414
 3 0 1 3
 3 0 2 1
 3 0 3 2
 3 1 2 3
  • header

第一行ply,作为PLY格式的识别。
第二行是版本资讯

 format ascii 1.0
 format binary_little_endian 1.0
 format binary_big_endian 1.0

第三行开始描述元素及属性,必须使用’element’及’property’的关键字,一般的格式为element下方接着属性列表,'property’不仅定义了资料的型态,其出现顺序亦定义了资料的顺序。内定的资料形态有两种写法:一种是char uchar short ushort int uint float double,另外一种是具有位元长度的int8 uint8 int16 uint16 int32 uint32 float32 float64。

element <element name> <number in file>
property <data_type> <property name 1>
property <data_type> <property name 2>
property <data_type> <property name 3>

一般而言,网格模型的“元素”就是顶点(vertices)、面(faces),另外还可能包含有(edges)、深度图样本(samples of range maps)与三角带(triangle strips)等元素。
最后,标头必须以此行结尾:

end_header

这之后就是按照上面描述的元素和属性写具体的元素和属性。

OUT

bundler是经典的单目重建公开库之一,.out文件是它的输出格式,包含场景估计和相机几何参数。
参考自 http://www.cs.cornell.edu/~snavely/bundler/bundler-v0.4-manual.html#S6
示例如下:

# Bundle file v0.3
    <num_cameras> <num_points>   [two integers]
    <camera1>
    <camera2>
       ...
    <cameraN>
    <point1>
    <point2>
       ...
    <pointM>

具体如下:

  • 版本信息:# Bundle file v0.3
  • num_cameras num_points:两个整数,分别表示相机总数(其实就是输入图像的数量)和匹配到的点数;
  • 接下来依次是每个相机的内参和外参信息;
    • 内参:f k1 k2:焦距,两个径向畸变参数;
    • 外参:R:表示相机旋转的矩阵,33;T:相机平移矩阵,13;
 <f> <k1> <k2>   [the focal length, followed by two radial distortion coeffs]
    <R>             [a 3x3 matrix representing the camera rotation]
    <t>             [a 3-vector describing the camera translation]
  • 匹配点
    • position:点空间位置的描述,1*3;
    • color:RGB信息,1*3;
    • view list:描述点可见性的向量,包括 view list 长度,camera第几个相机,key表示该相机中第几个sift特征点,x和y表示在二维图像上的坐标(以图像中心的原点);
<position>      [a 3-vector describing the 3D position of the point]
<color>         [a 3-vector describing the RGB color of the point]
<view list>     [a list of views the point is visible in]
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值