[37] | 1 | % By Philip Torr 2002
|
---|
| 2 | % copyright Microsoft Corp.
|
---|
| 3 | % so we display an epipolar line from image 1 into image 2
|
---|
| 4 | %%%%%%%
|
---|
| 5 |
|
---|
| 6 |
|
---|
| 7 | function torr_display_epipolar(f,ax_handle2,ax_handle3,m3)
|
---|
| 8 |
|
---|
| 9 | % (x2 y2 m3) F (x1 y1 m3)'
|
---|
| 10 | % (image 2) F ( image 1)'
|
---|
| 11 |
|
---|
| 12 | %while 1
|
---|
| 13 |
|
---|
| 14 | %this takes one image and draws the corresponding epipolar line.
|
---|
| 15 | Fmat = [[f(1) f(2) f(3)]; [f(4) f(5) f(6)];[f(7) f(8) f(9)]];
|
---|
| 16 |
|
---|
| 17 |
|
---|
| 18 |
|
---|
| 19 | [U,S,V] = svd(Fmat);
|
---|
| 20 | S(3,3) = 0;
|
---|
| 21 | F2 = U*S*V';
|
---|
| 22 |
|
---|
| 23 | [v,d] = eig(F2);
|
---|
| 24 | ee = v(:,1);
|
---|
| 25 | %Fmat * ee
|
---|
| 26 |
|
---|
| 27 |
|
---|
| 28 |
|
---|
| 29 | axes(ax_handle2);
|
---|
| 30 | hold on
|
---|
| 31 | [Xcur,Ycur] = GINPUT;
|
---|
| 32 | n_plots = length(Xcur);
|
---|
| 33 |
|
---|
| 34 | plot(Xcur,Ycur, 'w+','LineWidth',2);
|
---|
| 35 | % plot(matches12(i,1), matches12(i,2), 'b+','LineWidth',2);
|
---|
| 36 | xxx1 = [Xcur,Ycur, ones(n_plots,1) * m3];
|
---|
| 37 |
|
---|
| 38 | % (x2 y2 m3) F (x1 y1 m3)'
|
---|
| 39 | % (image 2) F ( image 1)'
|
---|
| 40 |
|
---|
| 41 | el2 = F2 * xxx1';
|
---|
| 42 | %is this the wrogn way round>
|
---|
| 43 | el2 = el2';
|
---|
| 44 |
|
---|
| 45 |
|
---|
| 46 | axes(ax_handle3);
|
---|
| 47 |
|
---|
| 48 | %define two points x1 = 0, x2 =
|
---|
| 49 | % note x 1 + y 2 + m3 3 = 0
|
---|
| 50 | % y = (-m3 3 - x 1 ) / 2
|
---|
| 51 |
|
---|
| 52 |
|
---|
| 53 | x1 = ones(n_plots,1) * -20000;
|
---|
| 54 | % y1 = - (el2(:,3) * m3) ./el2(:,2);
|
---|
| 55 | y1 = (- (el2(:,3) * m3) - (x1(:) .* el2(:,1))) ./el2(:,2);
|
---|
| 56 |
|
---|
| 57 | x2 = ones(n_plots,1) * 20000;
|
---|
| 58 | y2 = (- (el2(:,3) * m3) - (x2(:) .* el2(:,1))) ./el2(:,2);
|
---|
| 59 |
|
---|
| 60 |
|
---|
| 61 |
|
---|
| 62 | hold on
|
---|
| 63 | a = [x1,x2]';
|
---|
| 64 | b = [ y1,y2 ]';
|
---|
| 65 | % plot(x1,y1, 'g+');
|
---|
| 66 | line(a,b,'Color','r');
|
---|
| 67 |
|
---|
| 68 | hold off
|
---|
| 69 |
|
---|
| 70 | %end |
---|