Matlab converts xyz data to .pcd point cloud file

First of all, we must ensure that the xyz data dimension is n × 3, otherwise it will be converted by matrix operation, for example:

Data=[spotx;spoty;spotz]';%注意有求逆运算

Then convert it through the pcwrite function that comes with matlab. The 2016b version does not have this function, and the 2018a version needs to be installed.

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

If there is no accident, the .pcd file has been generated, you can find the file path in the directory window, mine is in the bin folder
Insert picture description here

Published 22 original articles · Likes2 · Visits 1157

Guess you like

Origin blog.csdn.net/qinqinxiansheng/article/details/104786230