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

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

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개)

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);

제품

릴리스

R2022b

질문:

2023년 1월 26일

답변:

2023년 1월 26일

Community Treasure Hunt

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

Start Hunting!

Translated by