点群データ上のおける重心検出する方法について

46 次查看(过去 30 天)
ichiro obayashi
ichiro obayashi 2017-2-10
天井を対象とした取得データにRANSACを行い、平面上に存在する物体を取り除いた後、その重心(付随画像上での赤×印部分です)を検出しようと考えています。 データの形状はX,Y,Zそれぞれ、17624*1となっています。 何か良い方法はありますでしょうか?Matlab初心者で大変申し訳ありません、宜しくお願い致します。
  1 个评论
Jiro Doke
Jiro Doke 2017-2-11
ご質問ありがとうございます。
どこで困っているのかをもう少し具体的にお願いします。RANSACの手法についての質問でしょうか?それとも、RANSACを MATLAB でどのようにプログラムするかの質問でしたら、アルゴリズムを数式などで説明いただけると助かります。それとも、XYZ のデータから重心を求める方法が知りたいのでしょうか。それとも、求めた重心をグラフに描画する方法が知りたいのでしょうか。
できる限り質問をきり砕いて、試したことなど含めて聞いて下さい。
MATLAB 初心者の方には2時間程度で受けられるオンライン MATLAB 入門をお勧めします: MATLAB Academy

请先登录,再进行评论。

采纳的回答

Tohru Kikawada
Tohru Kikawada 2017-2-13
编辑:Tohru Kikawada 2017-2-13
Jiro Doke さんのご指摘のとおり具体的に書いていただけると適切な回答が迅速に得られる可能性があります。
点群のフィッティングについてはComputer Vision System Toolboxの pcfitplane 関数が役に立つかもしれません。
また、単純な重心でしたら各座標の平均で求められると思います。
XYZ = randn(10,3);
mean(XYZ)
下記の例は上記のComputer Vision System Toolboxの pcfitplane と Statistics and Machine Learning Toolbox の kmeans を使って、壁面の除去と各オブジェクトの重心を計算させた例です。
ご参考まで。
%%点群の重心を計算
%%点群読み込みと可視化
load('object3d.mat')
figure
pcshow(ptCloud)
xlabel('X(m)')
ylabel('Y(m)')
zlabel('Z(m)')
title('Original Point Cloud')
%%下の台座の除去
maxDistance = 0.02;
referenceVector = [0,0,1];
maxAngularDistance = 5;
[model1,inlierIndices,outlierIndices] = pcfitplane(ptCloud,...
maxDistance,referenceVector,maxAngularDistance);
plane1 = select(ptCloud,inlierIndices);
remainPtCloud = select(ptCloud,outlierIndices);
figure
pcshow(remainPtCloud)
title('台座の除去')
%%左側の壁面の除去
roi = [-inf,inf;0.4,inf;-inf,inf];
sampleIndices = findPointsInROI(remainPtCloud,roi);
[model2,inlierIndices,outlierIndices] = pcfitplane(remainPtCloud,...
maxDistance,'SampleIndices',sampleIndices);
plane2 = select(remainPtCloud,inlierIndices);
remainPtCloud = select(remainPtCloud,outlierIndices);
figure
pcshow(remainPtCloud)
title('左側の壁を除去')
%%置くの壁面の除去
roi = [-inf,inf;-inf,inf;0.9,1.2];
sampleIndices = findPointsInROI(remainPtCloud,roi);
[model3,inlierIndices,outlierIndices] = pcfitplane(remainPtCloud,...
maxDistance,'SampleIndices',sampleIndices);
plane3 = select(remainPtCloud,inlierIndices);
remainPtCloud = select(remainPtCloud,outlierIndices);
figure
h = pcshow(remainPtCloud)
title('左側の壁を除去')
%%点群の重心計算と可視化
points = remainPtCloud.Location;
points(any(isnan(points),2),:) = [];
%%3つの要素にクラスタリングに重心位置計算
rng default; % 乱数のシードをデフォルトに変更(同じ結果になるように)
[idx,C] = kmeans(points,3);
hold on;
scatter3(C(:,1),C(:,2),C(:,3),200,[1 0 0],'filled');
実行結果:

更多回答(0 个)

类别

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

Community Treasure Hunt

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

Start Hunting!