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

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

Added original make3d

File size: 2.3 KB
Line 
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
12function selfcalib = goradf(config,par2estimate,INL_TOL)
13
14% assignment of the parameters to estimate
15initFOV = par2estimate(1);
16center_optim = par2estimate(2);
17est_dist = par2estimate(3:6)';
18
19% if problem with desactivated images -> some problems with the estimation in general
20desactivated_images = [];
21
22idxcams = config.cal.cams2use;
23selfcalib.goradproblem = 0;
24
25count = 0;
26
27for 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
79end
80
81return
82                                                                                                                                                                                                                                                     
Note: See TracBrowser for help on using the repository browser.