使用MATLAB读取.ply点云图
filename = 'C:\\Users\\13163\\Desktop\\3D_PointCloud\\PointCloud_2\\3D点云生成\\Group_1\\outputMesh.ply';
[vertices, faces, color] = readPly(filename);
plotPly(vertices, faces, color);
function [vertices, faces, color] = readPly(filename)
% 打开文件
fid = fopen(filename, 'r');
if fid == -1
error('Cannot open PLY file.');
end
% 跳过头部信息,读取直到遇到顶点数据
line = fgets(fid);
while true
line = fgets(fid);
if contains(line, 'end_header')
break;
end
end
% 读取顶点数量
line = fgets(fid);
tokens = strsplit(line)