Why is it slow when I use segmentGroundFromLidarData function with pointCloud I made?
4 views (last 30 days)
Show older comments
This File is segmentGroundFromLidarData example.
When I use segmentGroundFromLidarData function after extracting only location from orginal pointCloud and rebuilding this location into pointCloud,
SegmentGroundFromLidarData's speed is more slower upto 2-times.
Why this situation is happened?
velodyneFileReaderObj = velodyneFileReader('lidarData_ConstructionRoad.pcap','HDL32E');
% Create a point cloud player using pcplayer. Define its x-, y-, and z-axes limits, in meters, and label its axes.
xlimits = [-40 40];
ylimits = [-15 15];
zlimits = [-3 3];
player = pcplayer(xlimits,ylimits,zlimits);
% Label the pcplayer axes.
xlabel(player.Axes,'X (m)')
ylabel(player.Axes,'Y (m)')
zlabel(player.Axes,'Z (m)')
% Set the colormap for labeling points. Use RGB triplets to specify green for ground-plane points, and red for obstacle points.
colors = [0 1 0; 1 0 0];
greenIdx = 1;
redIdx = 2;
% Iterate through the first 200 point clouds in the Velodyne PCAP file, using readFrame to read in the data. Segment the ground points from each point cloud. Color all ground points green and nonground points red. Plot the resulting lidar point cloud.
colormap(player.Axes,colors)
title(player.Axes,'Segmented Ground Plane of Lidar Point Cloud');
for i = 1 : 200
% Read current frame.
ptCloud = velodyneFileReaderObj.readFrame(i);
% Create label array.
colorLabels = zeros(size(ptCloud.Location,1),size(ptCloud.Location,2));
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Find the ground points.
tic
groundPtsIdx = segmentGroundFromLidarData(ptCloud);
toc
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% tic
% l = ptCloud.Location;
% pt = pointCloud(l);
% groundPtsIdx = segmentGroundFromLidarData(pt);
% toc
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Map color ground points to green.
colorLabels(groundPtsIdx (:)) = greenIdx;
% Map color nonground points to red.
colorLabels(~groundPtsIdx (:)) = redIdx;
% Plot the results.
view(player,ptCloud.Location,colorLabels)
end
0 Comments
Answers (1)
Venkata Ram Prasad Vanguri
on 24 Sep 2020
HI,
The extra time is due to point cloud creation. Keep point cloud creation out of time measuring block, then you will have similar timing results.
l = ptCloud.Location;
pt = pointCloud(l);
tic
groundPtsIdx = segmentGroundFromLidarData(pt);
toc
See Also
Categories
Find more on Point Cloud Processing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!