首页 > 设计 > WEB开发 > 正文

【Matlab Computer Vision System ToolBox】学习笔记-4 -点云文件PLY格式

2019-11-02 18:27:35
字体:
来源:转载
供稿:网友

本系列博客将介绍Matlab中机器视觉工具箱的应用,部分案例,主要关于点云处理方面,更多内容见Matlab官方文档。如有翻译错误请批评指正!所有代码经自己运行测试通过。转载请注明链接 :http://blog.csdn.NET/kaspar1992

The PLY Format

Matlab视觉工具箱点云只支持XYZ坐标及颜色属性。

1. File Header 头部

PLY文件头部例子:

ply                                                       //file IDformat binary_big_endian 1.0                              //specify data format and versionelement vertex 9200                                       //define "vertex" element 顶点元素PRoperty float xproperty float yproperty float zelement face 18000                                         //define "face" elementproperty list uchar int vertex_indicesend_header                                                 //data starts after this line

文件已 “ply” 开始,表示这是一个PLY文件。头部必须包含以下语法:

format <data format> <PLY version><data format>  可以是 ascii 表示数据以文本存储; binary_little_endian  和 binary_big_endian  表示二进制数据存储。

元素以  “element”  开始,并有元素属性值。

element <element name><number in file>property <data type><property name 1>property <data type><property name 2>property <data type><property name 3>...例如,
element vertex 9200定义了一个 vertex (顶点),有9200个元素,每个元素由 property ( 属性) 描述,这里有两种 属性,标量和列表。

标量的定义语法:

property <data type><property name>

其中 <data type>可以是以下类型:

列表语法定义如下:

property list <count data type><data type><property name>例如:property list uchar int vertex_index

定义了以一个字节整形开始的 顶点索引,这对于存储在一个脸中不同的顶点较复杂的多边形数据很有用。

头部还可以包括 comments  ,可以提供文件的作者信息,文件描述,数据来源和其他文字信息,格式如下:

comment<comment text>

2. Data 数据

数据存储格式在文件头部已经定义,ASCII或者二进制,数据按文件头部定义顺序存储。在上面的例子中,9200个顶点,每个顶点有xyz属性值。文件数据如下:

float vertex[1].xfloat vertex[1].yfloat vertex[1].zfloat vertex[2].xfloat vertex[2].yfloat vertex[2].z...float vertex[9200].xfloat vertex[9200].yfloat vertex[9200].z

通常,每个元素的值按行一次性存储:

<property 1><property 2> ... <property N> element[1]<property 1><property 2> ... <property N> element[2]

...

列表以一个count开始,后面有scalars。例如上面的face,列表属性有 vertex_indices ,uchar 的 count 和 in 的 scalar

uchar countint face[1].vertex_indices[1]int face[1].vertex_indices[2]int face[1].vertex_indices[3]...int face[1].vertex_indices[count]uchar countint face[2].vertex_indices[1]int face[2].vertex_indices[2]int face[2].vertex_indices[3]...int face[2].vertex_indices[count]...

3. Common Elements and Properties 通用元素和属性

 

因为点云格式比较复杂,包括很多的元素及属性,一个通用的属性可以在不同的程序中使用,Turk建议元素和属性使用一些标准。

4. More

更多关于PLY的内容,请点击链接 Greg Turk’s article on the PLY format

看到这里笔者想到之前的笔记中使用的 teapot.ply  ,于是找出打开,看看是不是上述的说明,截图如下,清晰明了。本博文对于以后自己建立点云有很大帮助。(点云数据那么多,上千上万,自己一个一个输入吗难道。。。)

 

 


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表