Lidar Labeler loads point clouds in the order returned by the dir function? How to sort the files?
조회 수: 1 (최근 30일)
이전 댓글 표시
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];
%player
player=pcplayer(xLimit,yLimit,zLimit);
xlabel(player.Axes,'X(m)');
ylabel(player.Axes,'Y(m)');
zlabel(player.Axes,'Z(m)');
%PointClouds.CurrentTime=PointClouds.StartTime+seconds(1);
veloReader.CurrentTime=veloReader.StartTime;
%Use a loop to play and save the point clouds as .pcd
a=0;
filename="PointClouds%d.pcd";
while(hasFrame(veloReader) && isOpen(player) && (veloReader.CurrentTime < veloReader.StartTime + seconds(2)))
a=a+1
%extract point clouds frame by frame from Velodyne scans
PtCloud = readFrame(veloReader, a); % veloReader is 1x1 velodyneROSMessageReader
%save point clouds as struct
PointClouds(a)=PtCloud;
timeDuration(a)=veloReader.Timestamps(a);
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
pause(0.1);
veloReader.CurrentTime
end
Thank you very much for your time.
댓글 수: 0
채택된 답변
Cam Salzberger
2022년 4월 1일
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:
filename="PointClouds%02d.pcd";
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.
-Cam
댓글 수: 2
Cam Salzberger
2022년 4월 5일
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(x.name), info)
.
..
PointClouds001.pcd
PointClouds002.pcd
PointClouds003.pcd
PointClouds004.pcd
PointClouds005.pcd
Again, not too sure about Lidar Labeler. But that should at least address what "dir" is doing.
-Cam
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Labeling, Segmentation, and Detection에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!