1 | % By Philip Torr 2002
|
---|
2 | % copyright Microsoft Corp.
|
---|
3 | % so we display an epipolar line in an image
|
---|
4 |
|
---|
5 |
|
---|
6 | function torr_display_epipoles(Fmat1,matches, m3)
|
---|
7 |
|
---|
8 | x1 = matches(:,1);
|
---|
9 | y1 = matches(:,2);
|
---|
10 | u1 = matches(:,3) - x1;
|
---|
11 | v1 = matches(:,4) - y1;
|
---|
12 |
|
---|
13 |
|
---|
14 | if nargin < 7
|
---|
15 | m3 = 256
|
---|
16 | end
|
---|
17 |
|
---|
18 | % (x2 y2 m3) F (x1 y1 m3)'
|
---|
19 | % (image 2) F ( image 1)'
|
---|
20 |
|
---|
21 | f1 = figure
|
---|
22 | m1 = max(max(matches));
|
---|
23 | m2 = min(min(matches));
|
---|
24 | m2 = -m2;
|
---|
25 | g = max(m1,m2);
|
---|
26 |
|
---|
27 | axis([-g g -g g])
|
---|
28 | hold on
|
---|
29 |
|
---|
30 | plot (matches(:,1), matches(:,2),'r+')
|
---|
31 | plot (matches(:,3), matches(:,4),'r+')
|
---|
32 |
|
---|
33 | quiver(x1, y1, u1, v1, 0)
|
---|
34 |
|
---|
35 | hold off
|
---|
36 |
|
---|
37 | f2 = figure
|
---|
38 | m1 = max(max(matches));
|
---|
39 | m2 = min(min(matches));
|
---|
40 | m2 = -m2;
|
---|
41 | g = max(m1,m2);
|
---|
42 |
|
---|
43 | axis([-g g -g g])
|
---|
44 | hold on
|
---|
45 |
|
---|
46 | plot (matches(:,1), matches(:,2),'r+')
|
---|
47 | plot (matches(:,3), matches(:,4),'r+')
|
---|
48 |
|
---|
49 | quiver(x1, y1, u1, v1, 0)
|
---|
50 |
|
---|
51 | hold off
|
---|
52 |
|
---|
53 | button = 1;
|
---|
54 |
|
---|
55 | while ~isempty(button)
|
---|
56 |
|
---|
57 | %this takes one image and draws the corresponding epipolar line.
|
---|
58 | % Fmat = [[f(1) f(2) f(3)]; [f(4) f(5) f(6)];[f(7) f(8) f(9)]]
|
---|
59 | %
|
---|
60 |
|
---|
61 |
|
---|
62 | figure(f1);
|
---|
63 | %
|
---|
64 | % [U,S,V] = svd(Fmat);
|
---|
65 | % S(3,3) = 0;
|
---|
66 | % F2 = U*S*V';
|
---|
67 |
|
---|
68 | % [v,d] = eig(Fmat1);
|
---|
69 | % epipole = v(:,3);
|
---|
70 | % epipole = epipole * (m3/epipole(3);
|
---|
71 | % %Fmat * ee
|
---|
72 | %
|
---|
73 |
|
---|
74 |
|
---|
75 | hold on
|
---|
76 | [Xcur,Ycur,button] = GINPUT(1);
|
---|
77 | plot(Xcur,Ycur, 'g+');
|
---|
78 |
|
---|
79 | xxx1 = [Xcur,Ycur, 256.0];
|
---|
80 |
|
---|
81 | % (x2 y2 m3) F (x1 y1 m3)'
|
---|
82 | % (image 2) F ( image 1)'
|
---|
83 |
|
---|
84 | el2 = Fmat1 * xxx1';
|
---|
85 |
|
---|
86 |
|
---|
87 | figure(f2)
|
---|
88 |
|
---|
89 | %define two points x1 = 0, x2 =
|
---|
90 | % note x 1 + y 2 + m3 3 = 0
|
---|
91 | % y = (-m3 3 - x 1 ) / 2
|
---|
92 |
|
---|
93 | nr = 512;
|
---|
94 | nc = 512;
|
---|
95 |
|
---|
96 | x1 = -100000;
|
---|
97 | % y1 = - el2(3) * 256/el2(2);
|
---|
98 | y1 =( -x1 * el2(1) - el2(3) * 256)/el2(2);
|
---|
99 |
|
---|
100 | x2 = nr;
|
---|
101 | y2 = (- el2(3) * 256 - x2 * el2(1))/el2(2);
|
---|
102 |
|
---|
103 |
|
---|
104 |
|
---|
105 | hold on
|
---|
106 | a = [x1,x2];
|
---|
107 |
|
---|
108 | figure(f1);
|
---|
109 | b = [ y1,y2 ];
|
---|
110 | % plot(x1,y1, 'g+');
|
---|
111 | plot(Xcur,Ycur, 'gs');
|
---|
112 |
|
---|
113 | figure(f2);
|
---|
114 | line(a,b,'Color','r');
|
---|
115 |
|
---|
116 |
|
---|
117 |
|
---|
118 | end
|
---|
119 |
|
---|
120 | %
|
---|
121 | % function g = display_mat(matches, x1,y1, u1, v1)
|
---|
122 | %
|
---|
123 | % m1 = max(max(matches));
|
---|
124 | % m2 = min(min(matches));
|
---|
125 | % m2 = -m2;
|
---|
126 | % g = max(m1,m2);
|
---|
127 | %
|
---|
128 | % axis([-g g -g g])
|
---|
129 | % hold on
|
---|
130 | %
|
---|
131 | % for(i = 1:length(x1))
|
---|
132 | % plot (matches(i,1), matches(i,2),'r+')
|
---|
133 | % plot (matches(i,3), matches(i,4),'r+')
|
---|
134 | % end
|
---|
135 | %
|
---|
136 | % quiver(x1, y1, u1, v1, 0)
|
---|
137 | %
|
---|
138 | % hold off |
---|