当前位置: 首页> 文旅> 文化 > 商业网站模板下载_湖北项目备案查询系统_友情链接的检查方法_小程序制作流程

商业网站模板下载_湖北项目备案查询系统_友情链接的检查方法_小程序制作流程

时间:2025/7/12 4:57:26来源:https://blog.csdn.net/zxjiaya/article/details/144090246 浏览次数:0次
商业网站模板下载_湖北项目备案查询系统_友情链接的检查方法_小程序制作流程

文章目录

    • 报错
      • 错误使用 fopen 找不到文件
      • 无法运行,运行按钮变灰
    • 读取ply文件

使用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 == -1error('Cannot open PLY file.');end% 跳过头部信息,读取直到遇到顶点数据line = fgets(fid);while trueline = fgets(fid);if contains(line, 'end_header')break;endend% 读取顶点数量line = fgets(fid);tokens = strsplit(line);numVertices = str2double(tokens{2});% 读取面片数量(可选)line = fgets(fid);tokens = strsplit(line);numFaces = str2double(tokens{2});% 读取顶点数据vertices = zeros(numVertices, 3);color = zeros(numVertices, 3); % 如果 PLY 文件中包含颜色信息for i = 1:numVerticesline = fgets(fid);tokens = strsplit(strtrim(line));vertices(i, :) = str2double(tokens(1:3));if length(tokens) >= 6color(i, :) = str2double(tokens(4:6)); % 如果文件有颜色信息endend% 读取面片数据faces = zeros(numFaces, 3);for i = 1:numFacesline = fgets(fid);tokens = strsplit(strtrim(line));faces(i, :) = str2double(tokens(2:end));end% 关闭文件fclose(fid);
endfunction plotPly(vertices, faces, color)% 绘制点云figure;hold on;scatter3(vertices(:, 1), vertices(:, 2), vertices(:, 3), 10, color, 'filled');% 绘制面片if ~isempty(faces)trimesh(faces, vertices(:, 1), vertices(:, 2), vertices(:, 3), 'FaceColor', 'cyan', 'FaceAlpha', 0.3);endaxis equal;xlabel('X');ylabel('Y');zlabel('Z');title('3D Point Cloud and Mesh');grid on;hold off;
end

报错

错误使用 fopen 找不到文件

filename = ‘“C:\Users\13163\Desktop\3D_PointCloud\PointCloud_2\3D点云生成\Group_1\outputMesh.ply”’; % 替换为你的 PLY 文件路径
[vertices, faces, color] = readPly(filename);
plotPly(vertices, faces, color);错误使用 fopen
找不到文件。确保文件存在且路径有效。

出错 untitled9>readPly (第 6 行)
fid = fopen(filename, ‘r’);
原因:Windows 路径分隔符是反斜杠 \,但在字符串中需要使用双反斜杠 \,或者使用正斜杠 /,因为 MATLAB 中反斜杠 \ 用作转义字符。

filename = 'C:\Users\13163\Desktop\3D_PointCloud\PointCloud_2\3D点云生成\Group_1\outputMesh.ply';

改成\即可。

filename = 'C:\\Users\\13163\\Desktop\\3D_PointCloud\\PointCloud_2\\3D点云生成\\Group_1\\outputMesh.ply';

无法运行,运行按钮变灰

在这里插入图片描述

第一次使用实时脚本,注意函数一定写在主函数后面,否则无法运行

读取ply文件

% 定义文件路径
filename = "C:\\Users\\13163\\Desktop\\3D_PointCloud\\PointCloud_2\\3D点云生成\\Group_1\\outputMesh.ply"; % 替换为你自己的文件路径% 读取 PLY 点云文件
ptCloud = pcread(filename);% 显示点云
pcshow(ptCloud);
title('3D Point Cloud Visualization');

在这里插入图片描述

关键字:商业网站模板下载_湖北项目备案查询系统_友情链接的检查方法_小程序制作流程

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

责任编辑: