Why is it slow when I use segmentGro​undFromLid​arData function with pointCloud I made?

4 次查看(过去 30 天)
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

回答(1 个)

Venkata Ram Prasad Vanguri
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
  1 个评论
MINHOON KIM
MINHOON KIM 2020-9-25
Oh I had some mistake in writting code.
The code that I want to show you is same with your answer.
In that case, computer spends more time in calculating ....

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Point Cloud Processing 的更多信息

产品


版本

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by