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

Last change on this file since 876 was 810, checked in by g7moreau, 10 years ago
  • Add license
File size: 6.0 KB
Line 
1%=======================================================================
2% Copyright 2008-2014, LEGI UMR 5519 / CNRS UJF G-INP, Grenoble, France
3%   http://www.legi.grenoble-inp.fr
4%   Joel.Sommeria - Joel.Sommeria (A) legi.cnrs.fr
5%
6%     This file is part of the toolbox UVMAT.
7%
8%     UVMAT is free software; you can redistribute it and/or modify
9%     it under the terms of the GNU General Public License as published
10%     by the Free Software Foundation; either version 2 of the license,
11%     or (at your option) any later version.
12%
13%     UVMAT is distributed in the hope that it will be useful,
14%     but WITHOUT ANY WARRANTY; without even the implied warranty of
15%     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16%     GNU General Public License (see LICENSE.txt) for more details.
17%=======================================================================
18
19%if exist('images_read');
20%   active_images = active_images & images_read;
21%end;
22
23var2fix = 'dX_default';
24
25fixvariable;
26
27var2fix = 'dY_default';
28
29fixvariable;
30
31var2fix = 'map';
32
33fixvariable;
34
35
36if ~exist('n_ima'),
37    data_calib;
38end;
39
40check_active_images;
41
42if ~exist(['I_' num2str(ind_active(1))]),
43    ima_read_calib;
44    if isempty(ind_read),
45        disp('Cannot extract corners without images');
46        return;
47    end;
48end;
49
50
51fprintf(1,'\nExtraction of the grid corners on the images\n');
52
53
54if (exist('map')~=1), map = gray(256); end;
55
56
57if exist('dX'),
58    dX_default = dX;
59end;
60
61if exist('dY'),
62    dY_default = dY;
63end;
64
65if exist('n_sq_x'),
66    n_sq_x_default = n_sq_x;
67end;
68
69if exist('n_sq_y'),
70    n_sq_y_default = n_sq_y;
71end;
72
73
74if ~exist('dX_default')|~exist('dY_default');
75   
76    % Setup of JY - 3D calibration rig at Intel (new at Intel) - use units in mm to match Zhang
77    dX_default = 30;
78    dY_default = 30;
79   
80    % Setup of JY - 3D calibration rig at Google - use units in mm to match Zhang
81    dX_default = 100;
82    dY_default = 100;
83   
84end;
85
86
87if ~exist('n_sq_x_default')|~exist('n_sq_y_default'),
88    n_sq_x_default = 10;
89    n_sq_y_default = 10;
90end;
91
92if ~exist('wintx_default')|~exist('winty_default'),
93    wintx_default = max(round(nx/128),round(ny/96));
94    winty_default = wintx_default;
95    clear wintx winty
96end;
97
98
99if ~exist('wintx') | ~exist('winty'),
100    clear_windows; % Clear all the window sizes (to re-initiate)
101end;
102
103
104
105if ~exist('dont_ask'),
106    dont_ask = 0;
107end;
108
109
110if ~dont_ask,
111    ima_numbers = input('Number(s) of image(s) to process ([] = all images) = ');
112else
113    ima_numbers = [];
114end;
115
116if isempty(ima_numbers),
117    ima_proc = 1:n_ima;
118else
119    ima_proc = ima_numbers;
120end;
121
122
123% Useful option to add images:
124kk_first = ima_proc(1); %input('Start image number ([]=1=first): ');
125
126
127if exist(['wintx_' num2str(kk_first)]),
128   
129    eval(['wintxkk = wintx_' num2str(kk_first) ';']);
130   
131    if isempty(wintxkk) | isnan(wintxkk),
132       
133        disp('Window size for corner finder (wintx and winty):');
134        wintx = input(['wintx ([] = ' num2str(wintx_default) ') = ']);
135        if isempty(wintx), wintx = wintx_default; end;
136        wintx = round(wintx);
137        winty = input(['winty ([] = ' num2str(winty_default) ') = ']);
138        if isempty(winty), winty = winty_default; end;
139        winty = round(winty);
140       
141        fprintf(1,'Window size = %dx%d\n',2*wintx+1,2*winty+1);
142       
143    end;
144   
145else
146   
147    disp('Window size for corner finder (wintx and winty):');
148    wintx = input(['wintx ([] = ' num2str(wintx_default) ') = ']);
149    if isempty(wintx), wintx = wintx_default; end;
150    wintx = round(wintx);
151    winty = input(['winty ([] = ' num2str(winty_default) ') = ']);
152    if isempty(winty), winty = winty_default; end;
153    winty = round(winty);
154   
155    fprintf(1,'Window size = %dx%d\n',2*wintx+1,2*winty+1);
156   
157end;
158
159
160if ~dont_ask,
161    fprintf(1,'Do you want to use the automatic square counting mechanism (0=[]=default)\n');
162    manual_squares = input('  or do you always want to enter the number of squares manually (1,other)? ');
163    if isempty(manual_squares),
164        manual_squares = 0;
165    else
166        manual_squares = ~~manual_squares;
167    end;
168else
169    manual_squares = 0;
170end;
171
172
173for kk = ima_proc,
174    if exist(['I_' num2str(kk)]),
175        click_ima_calib;
176        active_images(kk) = 1;
177    else
178        eval(['dX_' num2str(kk) ' = NaN;']);
179        eval(['dY_' num2str(kk) ' = NaN;']); 
180       
181        eval(['wintx_' num2str(kk) ' = NaN;']);
182        eval(['winty_' num2str(kk) ' = NaN;']);
183       
184        eval(['x_' num2str(kk) ' = NaN*ones(2,1);']);
185        eval(['X_' num2str(kk) ' = NaN*ones(3,1);']);
186       
187        eval(['n_sq_x_' num2str(kk) ' = NaN;']);
188        eval(['n_sq_y_' num2str(kk) ' = NaN;']);
189    end;
190end;
191
192
193check_active_images;
194
195
196
197% Fix potential non-existing variables:
198
199for kk = 1:n_ima,
200    if ~exist(['x_' num2str(kk)]),
201        eval(['dX_' num2str(kk) ' = NaN;']);
202        eval(['dY_' num2str(kk) ' = NaN;']); 
203       
204        eval(['x_' num2str(kk) ' = NaN*ones(2,1);']);
205        eval(['X_' num2str(kk) ' = NaN*ones(3,1);']);
206       
207        eval(['n_sq_x_' num2str(kk) ' = NaN;']);
208        eval(['n_sq_y_' num2str(kk) ' = NaN;']);
209    end;
210   
211    if ~exist(['wintx_' num2str(kk)]) | ~exist(['winty_' num2str(kk)]),
212       
213        eval(['wintx_' num2str(kk) ' = NaN;']);
214        eval(['winty_' num2str(kk) ' = NaN;']);
215       
216    end;
217end;
218
219string_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';
220
221for kk = 1:n_ima,
222    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)];
223end;
224
225eval(string_save);
226
227disp('done');
228
229return;
230
231go_calib_optim;
232
Note: See TracBrowser for help on using the repository browser.