Filter löschen
Filter löschen

using pcfitcylinder - unexpected results?

3 Ansichten (letzte 30 Tage)
Dan Howe
Dan Howe am 16 Apr. 2020
Kommentiert: Tao Liu am 23 Okt. 2023
Hi, I'm looking to use the pcfitcylinder function and to check how it works, was trying to construct a simple test case.
I've got the code below to generate some point cloud data to fit a cylinder to. I think the point cloud data is correct but the fitted cylinder is nowhere near close. Could anyone advise what the issue is (I'm sure it's what I'm passing into the function)?
Thanks
r=10; %radius
length=10;
ntheta=100; % number of points to sample around circumference
nz=4; %number of layers to slice along cylinder
A=rand(ntheta,nz); %generate random points
A=A*2*pi; %convert to angle
B=0; % eventually want to try B=rand(ntheta,nz);
X=(r+5*B).*cos(A); %X co-ordinate
Y=(r+5*B).*sin(A);
z=[0:length/(nz-1):length];
Z=repmat(z,ntheta,1);
mypointcloud=pointCloud([X(:),Y(:),Z(:)]);
maxDistance=1;
cyl=pcfitcylinder(mypointcloud,maxDistance)
scatter3(X(:),Y(:),Z(:));
hold on
pcshow(pcloud);
plot(cyl);

Antworten (2)

Prabhan Purwar
Prabhan Purwar am 21 Apr. 2020
Hi,
Please refer to the following code:
r=1; %radius
length=1;
ntheta=100; % number of points to sample around circumference
nz=20; %number of layers to slice along cylinder
A=rand(ntheta,nz); %generate random points
A=A*2*pi; %convert to angle
B=0; % eventually want to try B=rand(ntheta,nz);
X=(r+5*B).*cos(A); %X co-ordinate
Y=(r+5*B).*sin(A);
z=[0:length/(nz-1):length];
Z=repmat(z,ntheta,1);
mypointcloud=pointCloud([X(:),Y(:),Z(:)]);
maxDistance=0.005;
cyl=pcfitcylinder(mypointcloud,maxDistance)
scatter3(X(:),Y(:),Z(:));
hold on
pcshow(mypointcloud);
plot(cyl);
Output:
Kindly refer to the following link:
Tip:
The following parameters plays a major role, as the algorithm to find a cylinder is based upon MSAC which relies upon the density of point clouds.
ntheta=100; % number of points to sample around circumference
nz=20; %number of layers to slice along cylinder
  1 Kommentar
Dan Howe
Dan Howe am 28 Apr. 2020
Thanks for the response but I only have a few 'slices' of point cloud data along the cylinder axis. I was surprised that the fitted cylinder could be so wildly out.
Given that my data slices are more or less planar I could just fit circles along each slice and best fit a line through circle centers. but pcfitcylinder seemed a more elegant approach if it gave a reasonable fit.

Melden Sie sich an, um zu kommentieren.


Dale Robinson
Dale Robinson am 15 Nov. 2022
I too have found this pcfitcylinder to be very unreliable. If I repeat the exact same code, it gives different answers each time. The optimisation must be unstable. Going to write my own code instead
  1 Kommentar
Tao Liu
Tao Liu am 23 Okt. 2023
Hi Dale,
I totally agree with you. I also got different results for each simulation. Do you have a reliable solution?
Thanks
Tao

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Statistics and Machine Learning Toolbox finden Sie in Help Center und File Exchange

Produkte


Version

R2016a

Community Treasure Hunt

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

Start Hunting!

Translated by