Reading ply file into my matlab code

Feel free to ask any question here
Post Reply
Kaela.john
Posts: 2
Joined: Mon Jun 03, 2019 10:40 pm

Reading ply file into my matlab code

Post by Kaela.john »

Hello, I have a point cloud which I then used to create a mesh on Cloud Compare. This worked out very well. The issue is that I then need to read in this ply file into a matlab code. This code works for other ply files, however when I try to use the file that I need to use, I obtain the following error:
Error using dlmread (line 147)
Mismatch between file and format character vector.
Trouble reading 'Numeric' field from file (row number 1, field number 3) ==> by CloudCompare!\n

I have attached the matlab function below, any help would be greatly appreciated.

Thank you

function fv = read_ply2_ExampleData(fileName)

%
% this function reads a ply file (must be in text format)
%
% to calc. normals etc use calcMeshNormals
%
% Copyright : This code is written by Ajmal Saeed Mian {ajmal@csse.uwa.edu.au}
% Computer Science, The University of Western Australia. The code
% may be used, modified and distributed for research purposes with
% acknowledgement of the author and inclusion this copyright information.
%
% Modified by Vipin Vijayan.

x = dlmread(fileName, ' ', [4 2 4 2]);
y = dlmread(fileName, ' ', [15 2 15 2]);
header = 18; %starting by row=0, the first row of data to be read starts here

vertex = dlmread(fileName, ' ', [header 0 x+(header-1) 9]);

poly = dlmread(fileName, ' ', [x+header 0 x+(header-1)+y 3]);
poly(:,1) = [];
poly = poly + 1;

fv.vertices = vertex;
fv.faces = poly;
daniel
Site Admin
Posts: 7713
Joined: Wed Oct 13, 2010 7:34 am
Location: Grenoble, France
Contact:

Re: Reading ply file into my matlab code

Post by daniel »

That doesn't look like a legit PLY file to me... The format is way more complicated (but you'll see that if you output a real PLY file in ASCII mode with CC).
Daniel, CloudCompare admin
Post Reply