Fitting a cilinder to 3D vertices

5 ビュー (過去 30 日間)
Alonso Figueroa
Alonso Figueroa 2018 年 5 月 29 日
コメント済み: Walter Roberson 2020 年 5 月 31 日
I am having problems fitting a cylinder to a point cloud. Trying to use "pcfitcylinder", an error saying 'the value of 'ptCloud' is invalid. Expected ptCloud to be a pointCloud object' while the pointcloud is a nx3 created from the vertices of an .stl file. The code is:
Bone_model=stlread(fullfile(Bone_path,Bone_file));
maxDistance=.5
cilinder = pcfitcylinder(Bone_model.vertices,maxDistance);
pcshow (Bone_model.vertices);hold on;
plot(cilinder)
Is there anything i'm doing wrong?
  1 件のコメント
KSSV
KSSV 2018 年 5 月 30 日
It is expecting a different input.....read the documentation.

サインインしてコメントする。

採用された回答

Walter Roberson
Walter Roberson 2018 年 5 月 30 日
stlread() appears to be one of the functions from the File Exchange, probably https://www.mathworks.com/matlabcentral/fileexchange/22409-stl-file-reader
The vertices returned by that stlread() function are configured for use by patch(). pcfitcylinder() requires that a pointcloud object be passed in.
You might be able to use
pc = pointcloud(Bone_model.vertices);
[cilinder,inlierIndices] = pcfitcylinder(pc, maxDistance);
cylpc = select(cilinder, inlierIndices);
pcshow(cylpc)
Note that pcfitcylinder attempts to find a subset of the pointcloud that is in the form of an cylinder.
  7 件のコメント
M.S. Khan
M.S. Khan 2020 年 5 月 31 日
Hi Danny,
could you please explain the coding to me. i also want to apply it on my problem.
Warm regards,
Walter Roberson
Walter Roberson 2020 年 5 月 31 日
M.S. Khan, which coding are you referring to? The only line of code that Daniel posted was
TalusPtCloud = pointCloud(Talus.solidVertices{1,1}, 'Normal', Talus.solidNormals{1,1});

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangePoint Cloud Processing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by