資源簡介
簡潔易懂的matlab版ply彩色模型生成工具,只需要輸入點云的坐標矩陣和對應的彩色RGB數組,即可生成二進制的ply文件,代碼通俗易懂,十分便捷。
代碼片段和文件信息
function?build_ply(outfilexyzrgb)
%outfile?is?the?binary?ply‘filename?which?you?want?to?make;
%xyz?is?the?N*3?matrix?for?point?cloud‘s?coordinate?data;
%rgb?is?the?color?for?every?point?respectively.
if(size(xyz1)~=size(rgb1))
????error(‘Input?xyz?and?rgb?arguments?should?have?same?number?of?rows‘);
end
if(size(xyz2)~=3?|?size(rgb2)~=3)
????error(‘Input?xyz?aand?rgb?arguments?should?have?3?columns‘);
end
pt3d(:1)?=?xyz(:1);
pt3d(:2)?=?xyz(:2);
pt3d(:3)?=?xyz(:3);
pt3d=pt3d‘;
RGB(:1)?=?uint8(rgb(:1));
RGB(:2)?=?uint8(rgb(:2));
RGB(:3)?=?uint8(rgb(:3));
RGB=RGB‘;
dataChunk?=?[reshape(typecast(reshape(single(pt3d)1[])‘uint8‘)3*4[]);?RGB];
size(dataChunk2)
file?=?writePLYhead(outfile?size(dataChunk2));
fwrite(file?dataChunk‘u
評論
共有 條評論