script4

file1 = 'cam1_image_2.jpg';
file2 = 'cam2_image_2.jpg';

% cpselect(file1,file2);

load cpdata
rgb1 = imread(file1);
imshow(rgb1);
hold on
plot(cam1pts(:,1),cam1pts(:,2),'bx','MarkerSize',11,'LineWidth',2);
hold off
rgb1 = imread(file2);
imshow(rgb2);
hold on
plot(cam2pts(:,1),cam2pts(:,2),'bx','MarkerSize',11,'LineWidth',2);
hold off
x = (cam1pts-320)/320;
xp = (cam2pts-320)/320;
sz = size(x);
N = sz(1);
A = [ xp(:,1).*x(:,1) xp(:,1).*x(:,2) xp(:,1) xp(:,2).*x(:,1) ...
    xp(:,2).*x(:,2) xp(:,2) x(:,1) x(:,2) ones(N,1)];

[U D V] = svd(A);

disp('check SVD');
disp(max(max(abs(A - U*D*V'))))

fprintf('Rank A = %g\n',rank(A))

F = reshape(V(9,:),3,3)';

[U1 D1 V1] = svd(F);
D1(3,3)=0.0;
Fp = U1*D1*V1';



[xp(1,1); xp(1,2); 1]'*Fp*[x(1,1); x(1,2); 1]
check SVD
   1.2212e-15

Rank A = 9

ans =

    0.1032