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 = pcread('M.ply');
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;
pts = rosReadXYZ(ptCloud)
ERROR
Error using rosReadXYZ
Expected input to be one of these types:
struct
Instead its type was pointCloud.
Error in rosReadXYZ (line 46)
validateattributes(msg,{'struct'},{'scalar'},'rosReadXYZ');
Error in xyzextract (line 13)
pts = rosReadXYZ(ptCloud,"PreserveStructureOnRead",true);
Kindly advise, I just want to extract xyz points from Point Cloud.

 채택된 답변

Sean de Wolski
Sean de Wolski 2022년 4월 23일

1 개 추천

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.

댓글 수: 5

@Sean de Wolski thank you for response. I want to generate "raster image from point cloud", for which I have found 1 function "pointcloud2image", which require xyz points data.
Sean de Wolski
Sean de Wolski 2022년 4월 25일
I think you're confusing the 3d-ness of the array (it's 2d [14816040 x 3]) and the 3d-ness of the points, which each column indicates is a coordinate in that dimension. As such the points represent 3d data, but are stored as coordinates in an array that is 2d.
Yup, thank you, I realized my mistake. Thank you for correcting me.
You'd call it with
nrows = YOUR_DESIRED_ROWS
ncols = YOUR_DESIRED_COLS
pointcloud2image(ptCloud.Location(:,1), ptCloud.Location(:,2), ptCloud.Location(:,3), nrows, ncols)
Additionally, you could probably just call scatteredInterpolant directly.
@Sean de Wolski Thank you for clarrification. I will try that, I have clear preview now. Thanks again.

댓글을 달려면 로그인하십시오.

추가 답변 (2개)

Walter Roberson
Walter Roberson 2022년 4월 23일
편집: Walter Roberson 2022년 4월 24일

0 개 추천

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.)
Naveed
Naveed 2024년 4월 20일

0 개 추천

Hi there!
How to access the features e.g (xyz, rgb values) in point cloud?
please help me out with this!

댓글 수: 4

xyz = YOURPOINTCLOUD.Location;
rgb = YOURPOINTCLOUD.Color;
Naveed
Naveed 2024년 4월 20일
But when i plug the line for rgb so it can't extract the values of rgb and i got the xyz points.....
Walter Roberson
Walter Roberson 2024년 4월 20일
Are you getting an error message? If so, what is the error?
Note that rgb can come out empty if there is no RGB information stored in the point cloud.
Naveed
Naveed 2024년 4월 20일
clc;
clear all;
close all;
ptcloud = pcread("C:\Users\PMLS\Desktop\FYP\tape-ply.ply");
points = ptcloud.Location;
colors = ptcloud.Color;
disp(['Number of points: ', num2str(ptcloud.Count)]);
player = pcplayer(ptcloud.XLimits, ptcloud.YLimits, ptcloud.ZLimits);
view(player, ptcloud);
the output is: Number of points: 84062 but having no rgb values.
>>

댓글을 달려면 로그인하십시오.

카테고리

태그

질문:

2022년 4월 23일

댓글:

2024년 4월 20일

Community Treasure Hunt

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

Start Hunting!

Translated by