本系列博客將介紹Matlab中機器視覺工具箱的應用,部分案例,主要關于點云處理方面,更多內容見Matlab官方文檔。如有翻譯錯誤請批評指正!所有代碼經自己運行測試通過。轉載請注明鏈接 :http://blog.csdn.NET/kaspar1992
Matlab視覺工具箱點云只支持XYZ坐標及顏色屬性。
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 ,于是找出打開,看看是不是上述的說明,截圖如下,清晰明了。本博文對于以后自己建立點云有很大幫助。(點云數據那么多,上千上萬,自己一個一個輸入嗎難道。。。)
新聞熱點
疑難解答