I want to find out how to get the angles between the centroids
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentario
Matt J
el 26 de En. de 2023
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?
Respuestas (2)
Askic V
el 26 de En. de 2023
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)))
% 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])
0 comentarios
Image Analyst
el 26 de En. de 2023
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);
0 comentarios
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!