1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
| clear all;
close all;
clc;
cam = CentralCamera('default');
P = mkgrid( 2, 0.5, 'T', transl(0,0,2) );
k1=cam.plot(P);
Tc0 = transl(0,0,0)*troty(0);
pd = cam.project(P, 'Tcam', Tc0)
tz=2*rand(100,1)-1;%tz=tx;
for i=1:100
%thetay(i)=atan(tz(i)/tx(i));
Tc1 = transl(0,0,tz(i))*troty(0);
pf = cam.project(P, 'Tcam', Tc1);
Sc=cam.plot(pf);
uu(i)=pf(1,1);
vv(i)=pf(2,1);
pause(0.5)
end
%c=rand(1,10);
%segma=rand(1,10);
n=100;
c=0.5*rand(1,n);
segma=0.5*rand(1,n);
w=0.5*rand(1,n);
u1=250;
v1=450;
%x1=[u1; v1];
%x2=[uu; vv];
%x=[x1; x2];
%x1=[u1, v1];
%x2=[uu(i), vv(i)];
x=u1:v1:uu:vv;
yd=tz(i);
w=0.5*rand(1,n);
eps=0.4;%epsilon
Eg=1;
while Eg>0.1978
for k=1:length(x)
for i=1: n
phi(i)=exp(-(norm(x(k)-c(i)))^2/(2*segma(i)^2));
end
y=w*phi';
w=w-eps*(y-yd(k))*phi;
c=c-eps*(y-yd(k))*norm(x(k)-c(i))/((segma(i)^2)+0.00001)*w.*phi;
segma=segma-eps*(y-yd(k))*(norm(x(k)-c(i)))^2/((segma(i)^3)+0.00001)*w.*phi;
e(k)=0.5*(y-yd(k))^2;
end
Eg=norm(e)
end
for k=1:100
for j=1: n
phi(j)=exp(-(norm(x(k)-c(j)))^2/(2*segma(j)^2));
end
y=w*phi';
sortie(k)=y;
end
figure;plot(yd);hold on
plot(sortie,'r'); |
Partager