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

조회 수: 1 (최근 30일)
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.

채택된 답변

Walter Roberson
Walter Roberson 2019년 6월 4일
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

추가 답변 (1개)

Sean de Wolski
Sean de Wolski 2019년 6월 3일
Why not just use pcread?
  댓글 수: 1
Kaela Johnson
Kaela Johnson 2019년 6월 3일
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.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Other Formats에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by