学习 点云格式(PLY)

学习 点云格式(PLY)

基本概念

注:全文为翻译

PLY polygon file format, a format for storing graphical objects that are described as a collection of polygons.

PLY:多边形文件格式(polygon file format),用来存储以许多多边形形式描述的图形物体。

The PLY format describes an object as a collection of vertices, faces and other elements, along with properties such as color and normal direction that can be attached to these elements.

PLY 格式通过许多的顶点、面、其他元素以及颜色、法线方向等附加属性一道描述一个物体。

A typical PLY object definition is simply a list of (x,y,z) triples for vertices and a list of faces that are described by indices into the list of vertices. Most PLY files include this core information.

一个典型的 PLY 物体定义就是一系列顶点的(x, y, z) 坐标点、一系列顶点列表索引所描述的面。大多数 PLY 文件包含这个核心信息。

Vertices and faces are two examples of “elements”, and the bulk of a PLY file is its list of elements. Each element in a given file has a fixed number of “properties” that are specified for each element. The typical information in a PLY file contains just two elements, the (x,y,z) triples for vertices and the vertex indices for each face.

顶点和面是 PLY 格式文件元素的两个例子,PLY 文件的大部分是他自己的元素的列表。每一个元素都有固定数目的属性。PLY 文件中的典型信息仅包含两个元素:(x, y, z)顶点三维坐标以及每一个面的顶点索引。

Applications can create new properties that are attached to elements of an object. For example, the properties red, green and blue are commonly associated with vertex elements.

应用程序可以创一个物体的元素的新的附加属性。比如:红、绿、蓝三个属性通常与顶点元素相关联。

In addition, one can create a new element type and define the properties associated with this element. Examples of new elements are edges, cells (lists of pointers to faces) and materials (ambient, diffuse and specular colors and coefficients).

此外,也可以创建新的元素类型并定义与之相关联的属性。比如:边元素,格子元素(面的一系列点)以及材质元素(环境,漫射,高光颜色以及系数)。

PLY 文件结构

结构模板

  Header
  Vertex List
  Face List
  (lists of other elements)

The header is a series of carriage-return terminated lines of text that describe the remainder of the file. The header includes a description of each element type, including the element’s name (e.g. “edge”), how many such elements are in the object, and a list of the various properties associated with the element.

Header(文件头): 一系列以回车键结束的行文本(carriage-return terminated lines)用来描述接下来的文件内容。文件头包括:每一个元素类型的描述(包含每一个元素的名称,比如 “edge” )、目标中的每个元素的个数、与每类元素相关联的一系列繁多的属性。

示例 1

注:{···} 括号以及其中的文件不是 PLY 文件内容,复制后删除。

ply
format ascii 1.0            { ascii/binary, format version number,格式版本号 }
comment made by Greg Turk   { comments keyword specified, like all lines,注释,关键字 comment }
comment this file is a cube
element vertex 8            { define "vertex" element, 8 of them in file, 定义元素 vertex 以及数目 8 }
property float x            { vertex contains float "x" coordinate,定义 vertex 元素 属性+类型}
property float y            { y coordinate is also a vertex property }
property float z            { z coordinate, too }
element face 6              { there are 6 "face" elements in the file,定义元素 face 以及数目 6 }
property list uchar int vertex_index      { "vertex_indices" is a list of ints,定义 face元素类型 }
end_header                  { delimits the end of the header,文件头分割文本,表示文件头结束 }
0 0 0                       { start of vertex list,vertex 元素列表起始,每列数字表示一个属性 }
0 0 1
0 1 1
0 1 0
1 0 0
1 0 1
1 1 1
1 1 0
4 0 1 2 3                   { start of face list, face 元素列表起始 }
4 7 6 5 4
4 0 4 5 1
4 1 5 6 2
4 2 6 7 3
4 3 7 4 0

示例1显示结果
在这里插入图片描述

关键字

  1. ply:文件头
  2. format:ASCII 或二进制格式 + 版本号
  3. comment: 注释
  4. element:元素描述
  5. property:元素属性描述

一般的属性描述结构

element  
property  
property  
property  
...

The properties listed after an “element” line define both the data type of the property and also the order in which the property appears for each element. There are two kinds of data types a property may have: scalar and list. Here is a list of the scalar data types a property may have:

位列元素行后的属性定义了:1. 属性的数据类型,2. 属性在元素中出现的顺序。数据类型一般有两种类型:1. 标量(scalar),2. 列表。标量数据类型的列表如下:

name        type        number of bytes
---------------------------------------
char       character                 1
uchar      unsigned character        1
short      short integer             2
ushort     unsigned short integer    2
int        integer                   4
uint       unsigned integer          4
float      single-precision float    4
double     double-precision float    8

特殊的属性类型定义
ply 中特殊的属性类型:使用列表数据类型,声明如下

property list
property list type type property_name

cube 文件中属性的列表数据类型示例:

property list uchar int vertex_index

This means that the property “vertex_index” contains first an unsigned char telling how many indices the property contains, followed by a list containing that many integers. Each integer in this variable-length list is an index to a vertex.

这个声明说明:属性 vertex_index 包含:1. unsigned char (uchar) 属性中所包含的索引数目,使用 uchar 表示所能一个面能索引的顶点的最大个数,2. 顶点的索引 int

示例 2

另外一个 ply 立方体定义:

ply
format ascii 1.0
comment author: Greg Turk
comment object: another cube
element vertex 8
property float x
property float y
property float z
property uchar red                    { start of vertex color, vertex 元素 颜色属性 }
property uchar green
property uchar blue
element face 7
property list uchar int vertex_index  { (uchar) number of vertices for each face (每一个面的顶点个数),(int) 顶点的索引  }
element edge 5                        { five edges in object,声明 edge 元素 + 元素数目 }
property int vertex1                  { index to first vertex of edge,声明 edge 元素的属性 vertex1 + 类型 }
property int vertex2                  { index to second vertex }
property uchar red                    { start of edge color, 声明 edge 元素的属性 red + 类型 }
property uchar green
property uchar blue
end_header
0 0 0 255 0 0                         { start of vertex list,顶点元素列表 x y z r g b }
0 0 1 255 0 0
0 1 1 255 0 0
0 1 0 255 0 0
1 0 0 0 0 255
1 0 1 0 0 255
1 1 1 0 0 255
1 1 0 0 0 255
3 0 1 2                           { start of face list, begin with a triangle,面(三角形)元素列表 面顶点数,顶点索引 }
3 0 2 3                           { another triangle }
4 7 6 5 4                         { now some quadrilaterals,面(四边形)元素列表,同上 }
4 0 4 5 1
4 1 5 6 2
4 2 6 7 3
4 3 7 4 0
0 1 255 255 255                   { start of edge list, begin with white edge,边元素列表,起始点索引 结束点索引 r g b }
1 2 255 255 255
2 3 255 255 255
3 0 255 255 255

示例2显示结果
在这里插入图片描述

参考链接:

链接: (翻译自) PLY - Polygon File Format.
链接: MeshLAB tutorial.
链接: PLY.
链接: The PLY Format.

  • 10
    点赞
  • 46
    收藏
    觉得还不错? 一键收藏
  • 5
    评论
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值