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

Last change on this file since 1033 was 926, checked in by sommeria, 8 years ago

geometry cqlib updated

File size: 2.5 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
32
33if ~exist('n_ima'),
34   data_calib; % Load the images
35   click_calib; % Extract the corners
36end;
37
38
39check_active_images;
40check_extracted_images;
41check_active_images;
42desactivated_images = [];
43
44recompute_extrinsic = (length(ind_active) < 100); % if there are too many images, do not spend time recomputing the extrinsic parameters twice..
45
46%%% MAIN OPTIMIZATION CALL!!!!! (look into this function for the details of implementation)
47go_calib_optim_iter;
48
49if ~isempty(desactivated_images),
50   param_list_save = param_list;
51   fprintf(1,'\nNew optimization including the images that have been deactivated during the previous optimization.\n');
52   active_images(desactivated_images) = ones(1,length(desactivated_images));
53   desactivated_images = [];
54   go_calib_optim_iter;
55   if ~isempty(desactivated_images),
56      fprintf(1,['List of images left desactivated: ' num2str(desactivated_images) '\n' ] );
57   end;
58   param_list = [param_list_save(:,1:end-1) param_list];
59end;
Note: See TracBrowser for help on using the repository browser.