XYZ点坐标转pcd点云

转点云显示,MATLAB代码如下

load('XYZwCell.mat');
XYzw = cell2mat(XYZw);
AA = zeros(1024,1280);
BB = zeros(1024,1280);
CC = zeros(1024,1280);
for i = 1:1024
    for j = 1:1280
        AA(i,j) = XYZw{i,j}(1);
        BB(i,j) = XYZw{i,j}(2);
        CC(i,j) = XYZw{i,j}(3);
    end
end


XX = zeros(8192,1);
YY = zeros(8192,1);
ZZ = zeros(8192,1);
k = 1;
for i = 1:16:1024      %64
    for j = 1:10:1280  %128
        %for k = 1:16384
          XX(k,1)=AA(i,j);
          YY(k,1)=BB(i,j);
          ZZ(k,1)=CC(i,j); 
          k = k+1;
        %end
    end
end

Data = [XX,YY,ZZ];
Data = single(Data);
ptCloud = pointCloud(Data(:,1:3));
pcwrite(ptCloud,'test.pcd','Encoding','ascii'); %将程序中的xyz数据写入pcd文件中
pc = pcread('test.pcd');
pcshow(pc); %显示点云

效果

 参考链接

https://blog.csdn.net/qinqinxiansheng/article/details/104786230

 

posted @ 2023-12-04 14:30  路人加  阅读(207)  评论(0编辑  收藏  举报