source: trunk/src/toolbox_calib/click_calib.m @ 1088

Last change on this file since 1088 was 926, checked in by sommeria, 9 years ago

geometry cqlib updated

File size: 4.9 KB
Line 
1%if exist('images_read');
2%   active_images = active_images & images_read;
3%end;
4
5var2fix = 'dX_default';
6
7fixvariable;
8
9var2fix = 'dY_default';
10
11fixvariable;
12
13var2fix = 'map';
14
15fixvariable;
16
17
18if ~exist('n_ima'),
19    data_calib;
20end;
21
22check_active_images;
23
24if ~exist(['I_' num2str(ind_active(1))]),
25    ima_read_calib;
26    if isempty(ind_read),
27        disp('Cannot extract corners without images');
28        return;
29    end;
30end;
31
32
33fprintf(1,'\nExtraction of the grid corners on the images\n');
34
35
36if (exist('map')~=1), map = gray(256); end;
37
38
39if exist('dX'),
40    dX_default = dX;
41end;
42
43if exist('dY'),
44    dY_default = dY;
45end;
46
47if exist('n_sq_x'),
48    n_sq_x_default = n_sq_x;
49end;
50
51if exist('n_sq_y'),
52    n_sq_y_default = n_sq_y;
53end;
54
55
56if ~exist('dX_default')|~exist('dY_default');
57   
58    % Setup of JY - 3D calibration rig at Intel (new at Intel) - use units in mm to match Zhang
59    dX_default = 30;
60    dY_default = 30;
61   
62    % Setup of JY - 3D calibration rig at Google - use units in mm to match Zhang
63    dX_default = 100;
64    dY_default = 100;
65   
66end;
67
68
69if ~exist('n_sq_x_default')|~exist('n_sq_y_default'),
70    n_sq_x_default = 10;
71    n_sq_y_default = 10;
72end;
73
74if ~exist('wintx_default')|~exist('winty_default'),
75    wintx_default = max(round(nx/128),round(ny/96));
76    winty_default = wintx_default;
77    clear wintx winty
78end;
79
80
81if ~exist('wintx') | ~exist('winty'),
82    clear_windows; % Clear all the window sizes (to re-initiate)
83end;
84
85
86
87if ~exist('dont_ask'),
88    dont_ask = 0;
89end;
90
91
92if ~dont_ask,
93    ima_numbers = input('Number(s) of image(s) to process ([] = all images) = ');
94else
95    ima_numbers = [];
96end;
97
98if isempty(ima_numbers),
99    ima_proc = 1:n_ima;
100else
101    ima_proc = ima_numbers;
102end;
103
104
105% Useful option to add images:
106kk_first = ima_proc(1); %input('Start image number ([]=1=first): ');
107
108
109if exist(['wintx_' num2str(kk_first)]),
110   
111    eval(['wintxkk = wintx_' num2str(kk_first) ';']);
112   
113    if isempty(wintxkk) | isnan(wintxkk),
114       
115        disp('Window size for corner finder (wintx and winty):');
116        wintx = input(['wintx ([] = ' num2str(wintx_default) ') = ']);
117        if isempty(wintx), wintx = wintx_default; end;
118        wintx = round(wintx);
119        winty = input(['winty ([] = ' num2str(winty_default) ') = ']);
120        if isempty(winty), winty = winty_default; end;
121        winty = round(winty);
122       
123        fprintf(1,'Window size = %dx%d\n',2*wintx+1,2*winty+1);
124       
125    end;
126   
127else
128   
129    disp('Window size for corner finder (wintx and winty):');
130    wintx = input(['wintx ([] = ' num2str(wintx_default) ') = ']);
131    if isempty(wintx), wintx = wintx_default; end;
132    wintx = round(wintx);
133    winty = input(['winty ([] = ' num2str(winty_default) ') = ']);
134    if isempty(winty), winty = winty_default; end;
135    winty = round(winty);
136   
137    fprintf(1,'Window size = %dx%d\n',2*wintx+1,2*winty+1);
138   
139end;
140
141
142if ~dont_ask,
143    fprintf(1,'Do you want to use the automatic square counting mechanism (0=[]=default)\n');
144    manual_squares = input('  or do you always want to enter the number of squares manually (1,other)? ');
145    if isempty(manual_squares),
146        manual_squares = 0;
147    else
148        manual_squares = ~~manual_squares;
149    end;
150else
151    manual_squares = 0;
152end;
153
154
155for kk = ima_proc,
156    if exist(['I_' num2str(kk)]),
157        click_ima_calib;
158        active_images(kk) = 1;
159    else
160        eval(['dX_' num2str(kk) ' = NaN;']);
161        eval(['dY_' num2str(kk) ' = NaN;']); 
162       
163        eval(['wintx_' num2str(kk) ' = NaN;']);
164        eval(['winty_' num2str(kk) ' = NaN;']);
165       
166        eval(['x_' num2str(kk) ' = NaN*ones(2,1);']);
167        eval(['X_' num2str(kk) ' = NaN*ones(3,1);']);
168       
169        eval(['n_sq_x_' num2str(kk) ' = NaN;']);
170        eval(['n_sq_y_' num2str(kk) ' = NaN;']);
171    end;
172end;
173
174
175check_active_images;
176
177
178
179% Fix potential non-existing variables:
180
181for kk = 1:n_ima,
182    if ~exist(['x_' num2str(kk)]),
183        eval(['dX_' num2str(kk) ' = NaN;']);
184        eval(['dY_' num2str(kk) ' = NaN;']); 
185       
186        eval(['x_' num2str(kk) ' = NaN*ones(2,1);']);
187        eval(['X_' num2str(kk) ' = NaN*ones(3,1);']);
188       
189        eval(['n_sq_x_' num2str(kk) ' = NaN;']);
190        eval(['n_sq_y_' num2str(kk) ' = NaN;']);
191    end;
192   
193    if ~exist(['wintx_' num2str(kk)]) | ~exist(['winty_' num2str(kk)]),
194       
195        eval(['wintx_' num2str(kk) ' = NaN;']);
196        eval(['winty_' num2str(kk) ' = NaN;']);
197       
198    end;
199end;
200
201string_save = 'save calib_data active_images ind_active wintx winty n_ima type_numbering N_slots first_num image_numbers format_image calib_name Hcal Wcal nx ny map dX_default dY_default dX dY wintx_default winty_default';
202
203for kk = 1:n_ima,
204    string_save = [string_save ' X_' num2str(kk) ' x_' num2str(kk) ' n_sq_x_' num2str(kk) ' n_sq_y_' num2str(kk) ' wintx_' num2str(kk) ' winty_' num2str(kk) ' dX_' num2str(kk) ' dY_' num2str(kk)];
205end;
206
207eval(string_save);
208
209disp('done');
210
211return;
212
213go_calib_optim;
214
Note: See TracBrowser for help on using the repository browser.