script6

clear
close all
load extrinsics
load filelist

cam1.Rc = R1;
cam1.Tc = T1;
cam2.Rc = R2;
cam2.Tc = T2;

[xg, yg] = meshgrid(linspace(0,21,8));

pt = [xg(:) yg(:) zeros(64,1)];


figure(1);
daspect([1 1 1]);
view(-10,50);
hold on
mesh(xg,-yg,zeros(8));
plot(xg(1),-yg(1),'ko','MarkerSize',7);
plot3([0 21],[0 0],[0 0],'r','LineWidth',2);
plot3([0 0],-[0 21],[0 0],'g','LineWidth',2);
plot3([0 0],[0 0],-[0 10],'b','LineWidth',2);

cam1 = cam_obj2(cam1,0.3,12);
cam2 = cam_obj2(cam2,0.3,12);

hold off
xlabel('x');
ylabel('y');
zlabel('z');
grid on
figure;
subplot(2,1,1);
imshow(files{1});
subplot(2,1,2);
pt = [xg(:) yg(:) zeros(64,1) ones(64,1)];
ptc = cam1.T * pt';
ptd = ptc(1:2,:)./repmat(ptc(3,:),2,1);
xp = reshape(ptd(1,:),[8 8]);
yp = reshape(ptd(2,:),[8 8]);

ndx = [1 8 64 57 1];
mesh(xp,yp,zeros(8));
hold on
plot(ptd(1,[1 8]),ptd(2,[1 8]),'g','LineWidth',2);
plot(ptd(1,[1 57]),ptd(2,[1 57]),'r','LineWidth',2);

hold off
axis ij
axis([-0.3 0.3 -0.18 0.18]);
axis equal
figure;
subplot(2,1,1);
imshow(files{2});
subplot(2,1,2);
pt = [xg(:) yg(:) zeros(64,1) ones(64,1)];
ptc = cam2.T * pt';
ptd = ptc(1:2,:)./repmat(ptc(3,:),2,1);
xp = reshape(ptd(1,:),[8 8]);
yp = reshape(ptd(2,:),[8 8]);

ndx = [1 8 64 57 1];
mesh(xp,yp,zeros(8));
hold on
plot(ptd(1,[1 8]),ptd(2,[1 8]),'g','LineWidth',2);
plot(ptd(1,[1 57]),ptd(2,[1 57]),'r','LineWidth',2);

hold off
axis ij
axis([-0.3 0.3 -0.18 0.18]);
axis equal