1 | % main function to launch the estimation |
---|
2 | % of the non-linear parameters by using the CalTech |
---|
3 | % calibration toolbox and the output from the Svoboda's |
---|
4 | % Multicamera self-calibration |
---|
5 | % |
---|
6 | % How to create the input data: |
---|
7 | % 1) Run the MultiCamSelfCam |
---|
8 | % 2) Run the MultiCamValidation |
---|
9 | % |
---|
10 | % $Id: goradf.m,v 2.2 2003/07/30 10:32:22 svoboda Exp $ |
---|
11 | |
---|
12 | function selfcalib = goradf(config,par2estimate,INL_TOL) |
---|
13 | |
---|
14 | % assignment of the parameters to estimate |
---|
15 | initFOV = par2estimate(1); |
---|
16 | center_optim = par2estimate(2); |
---|
17 | est_dist = par2estimate(3:6)'; |
---|
18 | |
---|
19 | % if problem with desactivated images -> some problems with the estimation in general |
---|
20 | desactivated_images = []; |
---|
21 | |
---|
22 | idxcams = config.cal.cams2use; |
---|
23 | selfcalib.goradproblem = 0; |
---|
24 | |
---|
25 | count = 0; |
---|
26 | |
---|
27 | for i = idxcams, |
---|
28 | count = count+1; |
---|
29 | [X_1,x_1] = preparedata(sprintf(config.files.points4cal,i)); |
---|
30 | % handle image resolutions correctly |
---|
31 | nx = config.cal.Res(count,1); |
---|
32 | ny = config.cal.Res(count,2); |
---|
33 | go_calib_optim_iter |
---|
34 | if any(isnan(param)) | any(err_std > 2*INL_TOL) |
---|
35 | % when the iteration fails insert null distortion |
---|
36 | % it is better than nonsense |
---|
37 | KK = [700 0 320; 0 700 240; 0 0 1]; % void calibration matrix |
---|
38 | kc(1:4) = [0,0,0,0]; |
---|
39 | selfcalib.goradproblem=1; |
---|
40 | else |
---|
41 | visualize_distortions |
---|
42 | figure(2), |
---|
43 | eval(['print -depsc ', config.paths.data, sprintf('NonLinModel.cam%d.eps',i)]) |
---|
44 | end |
---|
45 | % |
---|
46 | disp(sprintf('***** camera %d **********************************',i)) |
---|
47 | % |
---|
48 | outputfile = sprintf(config.files.rad,i); |
---|
49 | fprintf(1,'\nExport of intrinsic calibration data to blue-c configuration file\n'); |
---|
50 | % outputfile = input('File basename: ', 's'); |
---|
51 | configfile = outputfile; |
---|
52 | disp(['Writing ' configfile]); |
---|
53 | |
---|
54 | fid = fopen(configfile, 'w'); |
---|
55 | |
---|
56 | fprintf(fid, 'K11 = %.16f\n', KK(1,1)); |
---|
57 | fprintf(fid, 'K12 = %.16f\n', KK(1,2)); |
---|
58 | fprintf(fid, 'K13 = %.16f\n', KK(1,3)); |
---|
59 | fprintf(fid, 'K21 = %.16f\n', KK(2,1)); |
---|
60 | fprintf(fid, 'K22 = %.16f\n', KK(2,2)); |
---|
61 | fprintf(fid, 'K23 = %.16f\n', KK(2,3)); |
---|
62 | fprintf(fid, 'K31 = %.16f\n', KK(3,1)); |
---|
63 | fprintf(fid, 'K32 = %.16f\n', KK(3,2)); |
---|
64 | fprintf(fid, 'K33 = %.16f\n\n', KK(3,3)); |
---|
65 | |
---|
66 | fprintf(fid, 'kc1 = %.16f\n', kc(1)); |
---|
67 | fprintf(fid, 'kc2 = %.16f\n', kc(2)); |
---|
68 | fprintf(fid, 'kc3 = %.16f\n', kc(3)); |
---|
69 | fprintf(fid, 'kc4 = %.16f\n', kc(4)); |
---|
70 | |
---|
71 | status = fclose(fid); |
---|
72 | |
---|
73 | % disp('Press any key to continue'), pause |
---|
74 | |
---|
75 | %%% |
---|
76 | % clear already estimated parameters |
---|
77 | clear fc kc alpha_c cc nx ny |
---|
78 | |
---|
79 | end |
---|
80 | |
---|
81 | return |
---|
82 | |
---|