Search code examples
matlabimportpoint-clouds

Reading from a .pts file that has no header into a point cloud


I have a file with .pts ending which contains 6 columns of number. it is practically a text file since it has no defined header or anything else. A snipit for example:

497074.93 5419772.04 266.04 12 1 1 
497074.93 5419772.08 266.02 15 1 1 
497074.93 5419772.09 266.05 13 1 1 
497074.93 5419772.11 266.05 13 1 1 
497074.94 5419772.14 266.02 11 1 1 
497074.94 5419772.15 266.04 13 1 1 
497074.94 5419772.17 266.04 14 1 1 
497074.94 5419772.18 266.05 14 1 1 

I have two questions here:

  • Are these xyz values with RGB attached?

  • How can I load them into matlab and save it as a point cloud?

The data was obtained from this link and as best as I can tell is supposed to contain a point cloud of some format.


Solution

  • For what concerns the reading in, you can use textscan:

    filename = '*** Full path to your text file ***';
    fid = fopen(filename, 'r');
    if fid == -1, error('Cannot open file! Check filename or location.'); end
    readdata = cell2mat(textscan(fid,'%f%f%f%f%f%f'));
    fclose(fid);
    

    This code will save the data in a matrix with 6 columns, if the file does not contain data other than the numbers. The format %f can be changed according to your needs (see https://de.mathworks.com/help/matlab/ref/textscan.html).

    About the meaning of the data: when I click on the link I don't see any data so please be more specific on that. Besides that, why would you use data of which you don't know the meaning?