I want to find out how to get the angles between the centroids

2 ビュー (過去 30 日間)
Don Wirasinha
Don Wirasinha 2023 年 1 月 26 日
回答済み: Image Analyst 2023 年 1 月 26 日
I have got the code which detects blue colored objects, shows their centroids and draws a line through them. My next task is to display the angle displayed between the centroids. (the angle formed at the elbow joint, with the centroids being located at the shoulder, elbow and wrist. if you could find the code required for this and can explain it a bit it would be helpful.
  1 件のコメント
Matt J
Matt J 2023 年 1 月 26 日
In what way is displaying the angle a different challenge from what you've already displayed? It's just one more number to add to the image isn't it?

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

回答 (2 件)

Askic V
Askic V 2023 年 1 月 26 日
Hello Don,
I think you might find this example useful:
close all
clc
clear
P1 = [231; 84];
P2 = [297; 284];
P3 = [544; 250];
p_12 = P1-P2;
p_23 = P3-P2;
theta = acosd(dot(p_12,p_23)/(norm(p_12)*norm(p_23)))
theta = 100.4253
% Plot results
plot(P1(1),P1(2),'ro');
text(P1(1),P1(2),[' \leftarrow ', num2str(P1(1)),', ', num2str(P1(2))]);
hold on
plot(P2(1),P2(2),'ro');
text(P2(1),P2(2),[' \leftarrow ', num2str(P2(1)),', ', num2str(P2(2))])
plot(P3(1),P3(2),'ro');
text(P3(1),P3(2),[' \leftarrow ', num2str(P3(1)),', ', num2str(P3(2))])
v1 = quiver(P2(1),P2(2), -abs(P2(1)-P1(1)), -abs(P2(2)-P1(2)),'off');
v2 = quiver(P2(1),P2(2), abs(P3(1)-P2(1)), -abs(P3(2)-P2(2)),'off');
grid on
xlim([0 700])
ylim([0 300])

Image Analyst
Image Analyst 2023 年 1 月 26 日
Try title or text on the image axes:
caption = sprintf('Angle = %.2f degrees', theta);
title(caption, 'FontSize', 16);
text(350, 175, caption, 'Color', 'r', 'FontSize', 16);

カテゴリ

Help Center および File ExchangeImages についてさらに検索

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by