1 | %this is a script to test the self calibration stuff
|
---|
2 | %torr_test_calib_sc.m
|
---|
3 | %main()
|
---|
4 | %profile on
|
---|
5 | clear all;
|
---|
6 | m3 = 256;
|
---|
7 | method = 'mapsac';
|
---|
8 | %method = 'linear';
|
---|
9 |
|
---|
10 |
|
---|
11 | % % do we want the same result each time
|
---|
12 | % randn('state',0)
|
---|
13 | % rand('state',0)
|
---|
14 | no_test = 1;
|
---|
15 | for(i = 1:no_test)
|
---|
16 |
|
---|
17 | % [true_F,x1,y1,x2,y2,nx1,ny1,nx2,ny2] = ...
|
---|
18 | % torr_gen_2view_matches(foc, no_matches, noise_sigma, translation_mult, translation_adder, ...
|
---|
19 | % rotation_multplier, min_Z,Z_RAN,m3);
|
---|
20 | [true_F,x1,y1,x2,y2,nx1,ny1,nx2,ny2,true_C,true_R,true_TX, true_E] = torr_gen_2view_matches;
|
---|
21 |
|
---|
22 | % m3 = 256
|
---|
23 | x_a = [x1,y1,repmat(m3,length(x1),1)];
|
---|
24 | x_a_prime = [x2,y2,repmat(m3,length(x1),1)];
|
---|
25 |
|
---|
26 | err_calc_a = [];
|
---|
27 | for k = 1:length(x1),
|
---|
28 | err_calc_a = [err_calc_a; (x_a_prime(k,:)) * true_F * (x_a(k,:)')];
|
---|
29 | end
|
---|
30 |
|
---|
31 | %total sum of error
|
---|
32 | disp('======================================================================');
|
---|
33 | disp(sprintf('Sum of squared error for true_F: x_prime*F*x = %d',sum(err_calc_a.^2)));
|
---|
34 | disp('======================================================================');
|
---|
35 |
|
---|
36 | no_matches = length(nx1);
|
---|
37 |
|
---|
38 | %if we set this to one then the result should be the same as the groundtruth...
|
---|
39 | no_noise = 1;
|
---|
40 | if (no_noise)
|
---|
41 | disp('just using noise free points');
|
---|
42 | nx1 = x1;
|
---|
43 | nx2 = x2;
|
---|
44 | ny1 = y1;
|
---|
45 | ny2 = y2;
|
---|
46 | end
|
---|
47 |
|
---|
48 |
|
---|
49 |
|
---|
50 | matches = [nx1,ny1,nx2,ny2];
|
---|
51 | perfect_matches = [x1,y1,x2,y2];
|
---|
52 | set_rank2 = 1;
|
---|
53 |
|
---|
54 | %first estimate F
|
---|
55 | %disp('First Match');
|
---|
56 | %matches(1,:)
|
---|
57 | [f, e1, n_inliers,inlier_index,nF] = torr_estimateF( perfect_matches, m3, [], method, set_rank2);
|
---|
58 |
|
---|
59 | x_b = [x1,y1,repmat(m3,length(x1),1)];
|
---|
60 | x_b_prime = [x2,y2,repmat(m3,length(x1),1)];
|
---|
61 |
|
---|
62 | err_calc_b = [];
|
---|
63 | for k = 1:length(x1),
|
---|
64 | err_calc_b = [err_calc_b; (x_a_prime(k,:)) * nF * (x_a(k,:)')];
|
---|
65 | end
|
---|
66 |
|
---|
67 | %total sum of error
|
---|
68 | disp('======================================================================');
|
---|
69 | disp(sprintf('Sum of squared error for mapsac nF: x_prime*nF*x = %d',sum(err_calc_b.^2)));
|
---|
70 | disp('======================================================================');
|
---|
71 |
|
---|
72 | end
|
---|
73 |
|
---|
74 |
|
---|
75 | method = 'linear';
|
---|
76 | %first estimate F
|
---|
77 | %disp('First Match');
|
---|
78 | %matches(1,:)
|
---|
79 | [f, e1, n_inliers,inlier_index,nF] = torr_estimateF( perfect_matches, m3, [], method, set_rank2);
|
---|
80 |
|
---|
81 | x_b = [x1,y1,repmat(m3,length(x1),1)];
|
---|
82 | x_b_prime = [x2,y2,repmat(m3,length(x1),1)];
|
---|
83 |
|
---|
84 | err_calc_b = [];
|
---|
85 | for k = 1:length(x1),
|
---|
86 | err_calc_b = [err_calc_b; (x_a_prime(k,:)) * nF * (x_a(k,:)')];
|
---|
87 | end
|
---|
88 |
|
---|
89 | %total sum of error
|
---|
90 | disp('======================================================================');
|
---|
91 | disp(sprintf('Sum of squared error for linear nF: x_prime*nF*x = %d',sum(err_calc_b.^2)));
|
---|
92 | disp('======================================================================');
|
---|