source: trunk/src/toolbox_calib/go_calib_optim.m @ 758

Last change on this file since 758 was 725, checked in by sommeria, 11 years ago

toolbox_calib added to svn

File size: 2.9 KB
Line 
1%go_calib_optim
2%
3%Main calibration function. Computes the intrinsic andextrinsic parameters.
4%Runs as a script.
5%
6%INPUT: x_1,x_2,x_3,...: Feature locations on the images
7%       X_1,X_2,X_3,...: Corresponding grid coordinates
8%
9%OUTPUT: fc: Camera focal length
10%        cc: Principal point coordinates
11%        alpha_c: Skew coefficient
12%        kc: Distortion coefficients
13%        KK: The camera matrix (containing fc and cc)
14%        omc_1,omc_2,omc_3,...: 3D rotation vectors attached to the grid positions in space
15%        Tc_1,Tc_2,Tc_3,...: 3D translation vectors attached to the grid positions in space
16%        Rc_1,Rc_2,Rc_3,...: 3D rotation matrices corresponding to the omc vectors
17%
18%Method: Minimizes the pixel reprojection error in the least squares sense over the intrinsic
19%        camera parameters, and the extrinsic parameters (3D locations of the grids in space)
20%
21%Note: If the intrinsic camera parameters (fc, cc, kc) do not exist before, they are initialized through
22%      the function init_intrinsic_param.m. Otherwise, the variables in memory are used as initial guesses.
23%
24%Note: The row vector active_images consists of zeros and ones. To deactivate an image, set the
25%      corresponding entry in the active_images vector to zero.
26%
27%VERY IMPORTANT: This function works for 2D and 3D calibration rigs, except for init_intrinsic_param.m
28%that is so far implemented to work only with 2D rigs.
29%In the future, a more general function will be there.
30%For now, if using a 3D calibration rig, set quick_init to 1 for an easy initialization of the focal length
31
32if ~exist('rosette_calibration','var')
33    rosette_calibration = 0;
34end;
35
36if ~exist('n_ima'),
37   data_calib; % Load the images
38   click_calib; % Extract the corners
39end;
40
41
42check_active_images;
43
44check_extracted_images;
45
46check_active_images;
47
48desactivated_images = [];
49
50recompute_extrinsic = (length(ind_active) < 100); % if there are too many images, do not spend time recomputing the extrinsic parameters twice..
51
52if (rosette_calibration)
53  %%% Special Setting for the Rosette:
54  est_dist = ones(5,1);
55end;
56
57
58%%% MAIN OPTIMIZATION CALL!!!!! (look into this function for the details of implementation)
59go_calib_optim_iter;
60
61
62if ~isempty(desactivated_images),
63   
64   param_list_save = param_list;
65   
66   fprintf(1,'\nNew optimization including the images that have been deactivated during the previous optimization.\n');
67   active_images(desactivated_images) = ones(1,length(desactivated_images));
68   desactivated_images = [];
69   
70   go_calib_optim_iter;
71   
72   if ~isempty(desactivated_images),
73      fprintf(1,['List of images left desactivated: ' num2str(desactivated_images) '\n' ] );
74   end;
75   
76   param_list = [param_list_save(:,1:end-1) param_list];
77   
78end;
79
80
81%%%%%%%%%%%%%%%%%%%% GRAPHICAL OUTPUT %%%%%%%%%%%%%%%%%%%%%%%%
82
83%graphout_calib;
84
Note: See TracBrowser for help on using the repository browser.