[37] | 1 | % By Philip Torr 2002
|
---|
| 2 | % copyright Microsoft Corp.
|
---|
| 3 | %main()
|
---|
| 4 | %profile on
|
---|
| 5 | m3 = 170;
|
---|
| 6 | sse2t = 0;
|
---|
| 7 | %method = 5;
|
---|
| 8 | %
|
---|
| 9 |
|
---|
| 10 | state_rand = 400;
|
---|
| 11 | randn('state',state_rand)
|
---|
| 12 | rand('state',state_rand)
|
---|
| 13 |
|
---|
| 14 | trans = 0;
|
---|
| 15 | true_epipole = torr_get_right_epipole(true_F,m3);
|
---|
| 16 | method
|
---|
| 17 |
|
---|
| 18 | for(i = 1:1)
|
---|
| 19 |
|
---|
| 20 | %generate a load of stuffs
|
---|
| 21 | torr_genf;
|
---|
| 22 |
|
---|
| 23 | nX1 = [nx1,ny1, ones(length(x1),1) * m3];
|
---|
| 24 | nX2 = [nx2,ny2, ones(length(x2),1) * m3];
|
---|
| 25 |
|
---|
| 26 | %mine
|
---|
| 27 | %f_torr = estf(nx1,ny1,nx2,ny2, no_matches,m3);
|
---|
| 28 |
|
---|
| 29 | %the F matrix is defined like:
|
---|
| 30 | % (nx2, ny2, m3) f(1 2 3) nx1
|
---|
| 31 | % (4 5 6) ny1
|
---|
| 32 | % (7 8 9) m3
|
---|
| 33 |
|
---|
| 34 |
|
---|
| 35 |
|
---|
| 36 | if method == 7
|
---|
| 37 | nf = estf(nx1,ny1,nx2,ny2, no_matches,m3);
|
---|
| 38 | nF = reshape(nf,3,3)';
|
---|
| 39 | else
|
---|
| 40 | [nF , nf]= fm_linear(nX1, nX2, eye(3), method);
|
---|
| 41 | end
|
---|
| 42 | %calc noisy epipole
|
---|
| 43 | noisy_epipole = torr_get_right_epipole(nF,m3);
|
---|
| 44 | epipole_distance = sqrt(norm(true_epipole -noisy_epipole))
|
---|
| 45 |
|
---|
| 46 |
|
---|
| 47 | ne1 = torr_errf2(nf,x1,y1,x2,y2, no_matches, m3);
|
---|
| 48 |
|
---|
| 49 | sne1 = sort(ne1);
|
---|
| 50 | sse_n = norm(sne1(20:no_matches-20))
|
---|
| 51 | % nf'
|
---|
| 52 |
|
---|
| 53 | theta2 = 2 * pi * rand;
|
---|
| 54 | rot2 = [ cos(theta2), sin(theta2); -sin(theta2), cos(theta2)];
|
---|
| 55 |
|
---|
| 56 | theta3 = 2 * pi * rand;
|
---|
| 57 | rot3 = [ cos(theta3), sin(theta3); -sin(theta3), cos(theta3)];
|
---|
| 58 |
|
---|
| 59 | nRxy1 = [nx1 ny1] * rot2 + trans;
|
---|
| 60 | Rxy1 = [x1 y1] * rot2 + trans;
|
---|
| 61 |
|
---|
| 62 | nRxy2 = [nx2 ny2] * rot3 - trans;
|
---|
| 63 | Rxy2 = [x2 y2] * rot3 - trans;
|
---|
| 64 |
|
---|
| 65 |
|
---|
| 66 | nRX1 = [nRxy1(:,1),nRxy1(:,2), ones(length(x1),1) * m3];
|
---|
| 67 | nRX2 = [nRxy2(:,1),nRxy2(:,2), ones(length(x2),1) * m3];
|
---|
| 68 |
|
---|
| 69 | %
|
---|
| 70 | if method == 7
|
---|
| 71 | nRf = estf(nRxy1(:,1),nRxy1(:,2), nRxy2(:,1),nRxy2(:,2), no_matches,m3);
|
---|
| 72 | nRF = reshape(nf,3,3)';
|
---|
| 73 | else
|
---|
| 74 | [nRF , nRf]= fm_linear(nRX1, nRX2, eye(3), method);
|
---|
| 75 | end
|
---|
| 76 |
|
---|
| 77 |
|
---|
| 78 | Rne1 = torr_errf2(nRf,Rxy1(:,1),Rxy1(:,2), Rxy2(:,1),Rxy2(:,2), no_matches, m3);
|
---|
| 79 |
|
---|
| 80 | sRne1 = sort(Rne1);
|
---|
| 81 | Rsse_n = norm(sRne1(20:no_matches-20))
|
---|
| 82 | % nRf'
|
---|
| 83 |
|
---|
| 84 |
|
---|
| 85 |
|
---|
| 86 | G1 = [rot2' [trans trans]'/m3; 0 0 1];
|
---|
| 87 | G2 = [rot3' [-trans -trans]'/m3; 0 0 1];
|
---|
| 88 |
|
---|
| 89 | nF2 =G2' * nRF * G1
|
---|
| 90 | nf2 = reshape(nF2',9,1);
|
---|
| 91 | nF
|
---|
| 92 | true_F
|
---|
| 93 | end
|
---|
| 94 |
|
---|
| 95 |
|
---|
| 96 | if draw_epipole
|
---|
| 97 | torr_display_epipoles(nF,nF2,perfect_matches, x1,y1, u1, v1)
|
---|
| 98 | end
|
---|
| 99 | %profile off
|
---|
| 100 | %
|
---|
| 101 | %
|
---|
| 102 | % some crap
|
---|
| 103 | %
|
---|
| 104 | % >> XX2 = [x2(1), y2(1), m3]
|
---|
| 105 | %
|
---|
| 106 | % XX2 =
|
---|
| 107 | %
|
---|
| 108 | % 101.4245 -119.2097 256.0000
|
---|
| 109 | %
|
---|
| 110 | % >> XX1 = [x1(1), y1(1), m3]
|
---|
| 111 | %
|
---|
| 112 | % XX1 =
|
---|
| 113 | %
|
---|
| 114 | % 49.3714 -140.5000 256.0000
|
---|
| 115 | %
|
---|
| 116 | % >>
|
---|
| 117 | %
|
---|
| 118 | %
|
---|
| 119 | %
|
---|
| 120 | %
|
---|
| 121 |
|
---|
| 122 |
|
---|
| 123 | % e = fm_error_hs(F, n1, n2, nowarn); |
---|