Error using dlmread- mismatch between file and format character vector (reading a ply file)

1 visualización (últimos 30 días)
I am trying to read in a ply file to matlab using the following code:
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;
I obtain the following error:
Error using dlmread
Mismatch between file and format character vector. Trouble reading 'Numeric' field from file (row number 1, field number 3) ==> by CloudCompare!\n
I have been able to read in other ply files using this code, I am not sure what I am missing this time. The ply file is a large point cloud ( about 6 000 000 points) that I converted to a ply file using CloudCompare.

Respuesta aceptada

Walter Roberson
Walter Roberson el 4 de Jun. de 2019
Your ply file contains a comment in an unexpected place. If you look at the file in the place it contains "by CloudCompare" a number is expected. Possibly the code is expecting that the line ends at that point and that the next line starts with a number

Más respuestas (1)

Sean de Wolski
Sean de Wolski el 3 de Jun. de 2019
Why not just use pcread?
  1 comentario
Kaela Johnson
Kaela Johnson el 3 de Jun. de 2019
Thanks for the reply! I need the 3d coordinates of the vertices, and the faces of the mesh contained in the ply file, to then make a tree structure out of the vertices and faces for mesh intersection purposes. I created this ply file from a point cloud for that purpose.

Iniciar sesión para comentar.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by