global flag h_im h_1
filename='D:\07020203_mpg2-0000281.jpg';
im=imread(filename);
h_im=image(im);
while 1
cal_cord_ang;
end
function cal_cord_angHowever, I almost forget the concept of vector, even the product of two vectors. You can review the concept in this url: http://www.euclideanspace.com/maths/algebra/vectors/angleBetween/index.htm.
global flag h_im h_1
cla(h_im)
[x,y] = ginput(1);
a=[x,y];
x0=a(1,1);
y0=a(1,2);
hold on
h_1=plot(x0,y0,'color','r','marker','+');
[x,y] = ginput(1);
b=[x,y];
x1=b(1,1);
y1=b(1,2);
h_1=plot([x0 x1],[y0 y1],'color','r','marker','+');
[x,y] = ginput(1);
c=[x,y];
x2=c(1,1);
y2=c(1,2);
h_1=plot([x0 x1 x2],[y0 y1 y2],'color','r','marker','+');
% calculate angle by using this formula --> A dot B = ABcos
A=a-b;
B=c-b;
angle=acosd(dot(A,B)/(norm(A)*norm(B)));
x_t=mean([x0 x2]);
y_t=mean([y0 y2]);
text(x_t,y_t,num2str(angle),'color','r')
ginput(1)
cla(h_im)
Try it, it's very funny!!!
0 意見:
張貼留言