Borrar filtros
Borrar filtros

Lidar Labeler loads point clouds in the order returned by the dir function? How to sort the files?

2 visualizaciones (últimos 30 días)
Hi everyone. I have saved Point Clouds as .pcd files in the directory with names e.g. PointClouds1.pcd .......... PointClouds20.pcd.
However the lidar labeler reads them in the order returned by dir function. The order returned by dir function, is as follows,
PointClouds11.pcd PointClouds15.pcd PointClouds19.pcd PointClouds4.pcd PointClouds8.pcd PointClouds12.pcd PointClouds16.pcd PointClouds2.pcd PointClouds5.pcd PointClouds9.pcd PointClouds1.pcd PointClouds13.pcd PointClouds17.pcd PointClouds20.pcd PointClouds6.pcd PointClouds10.pcd PointClouds14.pcd PointClouds18.pcd PointClouds3.pcd PointClouds7.pcd.
How do I make sure that labeler app loads file in correct order (e.g starting from 1 upto 20). Or how do I make sure that files are saved in the correct order?
I think, I am making a mistake while saving the files as .pcd. Here is the code that I used to display the point clouds in pc player as well as save them as .pcd.
% Define pointcloud player
xLimit = [-50,50];
yLimit = [-50,50];
zLimit = [-3,15];
%Use a loop to play and save the point clouds as .pcd
while(hasFrame(veloReader) && isOpen(player) && (veloReader.CurrentTime < veloReader.StartTime + seconds(2)))
%extract point clouds frame by frame from Velodyne scans
PtCloud = readFrame(veloReader, a); % veloReader is 1x1 velodyneROSMessageReader
%save point clouds as struct
pcdfile=sprintf(filename,a); %Generate file name
pcwrite(PointClouds(a),pcdfile,'Encoding','ascii') % save points clouds as .pcd
view(player,PtCloud.Location,PtCloud.Intensity); %view pointclouds in the pc player
Thank you very much for your time.

Respuesta aceptada

Cam Salzberger
Cam Salzberger el 1 de Abr. de 2022
Hello Sarang,
I'm not sure about getting Lidar Labeler to load in a different order, or if this is the best way to generate point clouds for use with it. But I can at least answer how to save them in order:
This will result in filenames like "PointClouds01.pcd", "PointClouds02.pcd", etc.
The "2" is the precision before the decimal point, and the preceding "0" pads out the value with zeros to reach "2" places. If you wanted to have three-digit numbers instead, use "03" instead of "02". See here for more information.
  2 comentarios
Sarang Jokhio
Sarang Jokhio el 1 de Abr. de 2022
Editada: Sarang Jokhio el 1 de Abr. de 2022
Hi Cam. Thank you very much for quick response.
this method indeed saves .pcd files in the correct order in the folder.
However, when I use dir in the current directory to lists files and folders in the current folder, the order given by 'dir' is again wrong. This the order, in which Lidar Labeler App loads the data (which is incorrect).
(PointClouds003.pcd PointClouds007.pcd PointClouds011.pcd PointClouds015.pcd PointClouds019.pcd
PointClouds004.pcd PointClouds008.pcd PointClouds012.pcd PointClouds016.pcd PointClouds020.pcd
PointClouds001.pcd PointClouds005.pcd PointClouds009.pcd PointClouds013.pcd PointClouds017.pcd
PointClouds002.pcd PointClouds006.pcd PointClouds010.pcd PointClouds014.pcd PointClouds018.pcd)
My problem is that I want to have files in order in the folder, at the same dir function also returns the same order.
I am sorry if my question does not make sense at all :D I am super new to Matlab,
Thank you.
Cam Salzberger
Cam Salzberger el 5 de Abr. de 2022
Hey Sarang,
I think you're confusing display order with actual order. I have a directory set up with PointClouds001.pcd...PointClouds020.pcd. If I just do "dir", I get this:
But if you do this, you can see that the files are in the correct order:
>> info = dir;
>> arrayfun(@(x) disp(, info)
Again, not too sure about Lidar Labeler. But that should at least address what "dir" is doing.

Iniciar sesión para comentar.

Más respuestas (0)


Más información sobre Point Cloud Processing en Help Center y File Exchange.




Community Treasure Hunt

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

Start Hunting!

Translated by