source: proiecte/pmake3d/make3d_original/Make3dSingleImageStanford_version0.1/third_party/BlueCCal/CalTechCal/analyse_error.m @ 37

Last change on this file since 37 was 37, checked in by (none), 14 years ago

Added original make3d

File size: 4.2 KB
Line 
1% Color code for each image:
2
3if ~exist('n_ima')|~exist('fc'),
4    fprintf(1,'No calibration data available.\n');
5    return;
6end;
7
8check_active_images;
9
10if n_ima ~=0,
11if ~exist(['ex_' num2str(ind_active(1)) ]),
12    fprintf(1,'Need to calibrate before analysing reprojection error. Maybe need to load Calib_Results.mat file.\n');
13    return;
14end;
15end;
16
17
18%if ~exist('no_grid'),
19no_grid = 0;
20%end;
21
22colors = 'brgkcm';
23
24
25figure(5);
26
27for kk = 1:n_ima,
28    if exist(['y_' num2str(kk)]),
29        if active_images(kk) & eval(['~isnan(y_' num2str(kk) '(1,1))']),
30           
31            if ~no_grid,
32                eval(['XX_kk = X_' num2str(kk) ';']);
33                N_kk = size(XX_kk,2);
34               
35                if ~exist(['n_sq_x_' num2str(kk)]),
36                    no_grid = 1;
37                end;
38               
39                if ~no_grid,
40                    eval(['n_sq_x = n_sq_x_' num2str(kk) ';']);
41                    eval(['n_sq_y = n_sq_y_' num2str(kk) ';']);
42                    if (N_kk ~= ((n_sq_x+1)*(n_sq_y+1))),
43                        no_grid = 1;
44                    end;
45                end;
46            end;
47           
48            eval(['plot(ex_' num2str(kk) '(1,:),ex_' num2str(kk) '(2,:),''' colors(rem(kk-1,6)+1) '+'');']);
49           
50            hold on;
51        end;
52    end;
53end;
54
55hold off;
56axis('equal');
57if 1, %~no_grid,
58    title('Reprojection error (in pixel) - To exit: right button');
59else
60    title('Reprojection error (in pixel)');   
61end;
62xlabel('x');
63ylabel('y');
64
65set(5,'color',[1 1 1]);
66set(5,'Name','error','NumberTitle','off');
67
68if n_ima == 0,
69   
70        text(.5,.5,'No image data available','fontsize',24,'horizontalalignment' ,'center');
71
72else
73
74err_std = std(ex')';
75
76fprintf(1,'Pixel error:          err = [ %3.5f   %3.5f] (all active images)\n\n',err_std);
77
78
79b = 1;
80
81while b==1,
82   
83    [xp,yp,b] = ginput3(1);
84   
85    if b==1,
86        ddd = (ex(1,:)-xp).^2 + (ex(2,:)-yp).^2;
87       
88        [mind,indmin] = min(ddd);
89       
90       
91        done = 0;
92        kk_ima = 1;
93        while (~done)&(kk_ima<=n_ima),
94            %fprintf(1,'%d...',kk_ima);
95            eval(['ex_kk = ex_' num2str(kk_ima) ';']);
96            sol_kk = find((ex_kk(1,:) == ex(1,indmin))&(ex_kk(2,:) == ex(2,indmin)));
97            if isempty(sol_kk),
98                kk_ima = kk_ima + 1;
99            else
100                done = 1;
101            end;
102        end;
103       
104        eval(['x_kk = x_' num2str(kk_ima) ';']);   
105        xpt = x_kk(:,sol_kk);
106       
107        if ~no_grid,
108           
109            eval(['n_sq_x = n_sq_x_' num2str(kk_ima) ';']);
110            eval(['n_sq_y = n_sq_y_' num2str(kk_ima) ';']);
111           
112            Nx = n_sq_x+1;
113            Ny = n_sq_y+1;
114           
115            y1 = floor((sol_kk-1)./Nx);
116            x1 = sol_kk - 1 - Nx*y1; %rem(sol_kk-1,Nx);
117           
118            y1 = (n_sq_y+1) - y1;
119            x1 = x1 + 1;
120           
121           
122            fprintf(1,'\n');
123            fprintf(1,'Selected image: %d\n',kk_ima);
124            fprintf(1,'Selected point index: %d\n',sol_kk);
125            fprintf(1,'Pattern coordinates (in units of (dX,dY)): (X,Y)=(%d,%d)\n',[x1-1 y1-1]);
126            fprintf(1,'Image coordinates (in pixel): (%3.2f,%3.2f)\n',[xpt']);
127            fprintf(1,'Pixel error = (%3.5f,%3.5f)\n',[ex(1,indmin) ex(2,indmin)]);
128           
129                       
130        else
131           
132            fprintf(1,'\n');
133            fprintf(1,'Selected image: %d\n',kk_ima);
134            fprintf(1,'Selected point index: %d\n',sol_kk);
135            fprintf(1,'Image coordinates (in pixel): (%3.2f,%3.2f)\n',[xpt']);
136            fprintf(1,'Pixel error = (%3.5f,%3.5f)\n',[ex(1,indmin) ex(2,indmin)]);
137           
138           
139        end;
140       
141       
142        if exist(['wintx_' num2str(kk_ima)]),
143           
144            eval(['wintx = wintx_' num2str(kk_ima) ';']);
145            eval(['winty = winty_' num2str(kk_ima) ';']);
146           
147            fprintf(1,'Window size: (wintx,winty) = (%d,%d)\n',[wintx winty]);
148        end;
149       
150       
151    end;
152   
153end;
154
155disp('done');
156
157end;
Note: See TracBrowser for help on using the repository browser.