Extracting xyzpoints from Point Cloud

28 views (last 30 days)
Abdul Hannan Qureshi on 23 Apr 2022
I want to extract xyz points data from Point Cloud model.
pointCloud with properties:
Location: [14816040×3 single]
Count: 14816040
XLimits: [-122.5566 183.8412]
YLimits: [-214.3051 106.7991]
ZLimits: [-4.3266 6.3947]
Color: [14816040×3 uint8]
Normal: [14816040×3 single]
Intensity: []
I am using two provided ways but not getting any results.
1st Code
ptCloud;
xyzPoints = ptCloud.Location;
x = xyzPoints(:,:,1);
y = xyzPoints(:,:,2);
z = xyzPoints(:,:,3);
points3D = [x(:)'; y(:)', z(:)'];
ERROR
Index in position 3 exceeds array bounds. Index must not exceed 1.
Error in xyzextract (line 8)
y = xyzPoints(:,:,2);
2nd function is
ptCloud;
ERROR
Expected input to be one of these types:
struct
Error in xyzextract (line 13)
Kindly advise, I just want to extract xyz points from Point Cloud.

Sean de Wolski on 23 Apr 2022
The location is the xyz points and it's 2d, not 3d like how you're indexing it.
points3d = ptCloud.Location.';
Would give you what you're after.
Abdul Hannan Qureshi on 25 Apr 2022
@Sean de Wolski Thank you for clarrification. I will try that, I have clear preview now. Thanks again.

Walter Roberson on 23 Apr 2022
Edited: Walter Roberson on 24 Apr 2022
Location: [14816040×3 single]
That tells you that the position information is 14816040 x 3 . It is not a 3D array.
Pointclouds store scattered information, not grids of information.
In some cases it may make sense to reshape() the scattered coordinates into a grid after it is extracted.
The information you get from the Location property is already the points3D array that you are trying to construct.
(Opps, Sean is right, you would need to take the transpose like he shows.)

Categories

Find more on Point Cloud Processing in Help Center and File Exchange

R2022a

Community Treasure Hunt

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

Start Hunting!