source: trunk/src/toolbox_calib/comp_ext_calib.m @ 910

Last change on this file since 910 was 908, checked in by g7moreau, 9 years ago
  • Update Copyright to 2015
File size: 3.0 KB
Line 
1%=======================================================================
2% Copyright 2008-2015, 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%%% Computes the extrinsic parameters for all the active calibration images
20
21check_active_images;
22
23N_points_views = zeros(1,n_ima);
24
25for kk = 1:n_ima,
26   
27    if exist(['x_' num2str(kk)]),
28       
29        eval(['x_kk = x_' num2str(kk) ';']);
30        eval(['X_kk = X_' num2str(kk) ';']);
31       
32        if (isnan(x_kk(1,1))),
33            if active_images(kk),
34                fprintf(1,'Warning: Cannot calibrate with image %d. Need to extract grid corners first.\n',kk)
35                fprintf(1,'         Set active_images(%d)=1; and run Extract grid corners.\n',kk)
36            end;
37        end;
38        if active_images(kk),
39            N_points_views(kk) = size(x_kk,2);
40            [omckk,Tckk] = compute_extrinsic_init(x_kk,X_kk,fc,cc,kc,alpha_c);
41            [omckk,Tckk,Rckk,JJ_kk] = compute_extrinsic_refine(omckk,Tckk,x_kk,X_kk,fc,cc,kc,alpha_c,20,thresh_cond);
42            if check_cond,
43                if (cond(JJ_kk)> thresh_cond),
44                    active_images(kk) = 0;
45                    omckk = NaN*ones(3,1);
46                    Tckk = NaN*ones(3,1);
47                    fprintf(1,'\nWarning: View #%d ill-conditioned. This image is now set inactive.\n',kk)
48                    desactivated_images = [desactivated_images kk];
49                end;
50            end;
51            if isnan(omckk(1,1)),
52                %fprintf(1,'\nWarning: Desactivating image %d. Re-activate it later by typing:\nactive_images(%d)=1;\nand re-run optimization\n',[kk kk])
53                active_images(kk) = 0;
54            end;
55        else
56            omckk = NaN*ones(3,1);
57            Tckk = NaN*ones(3,1);
58        end;
59       
60    else
61       
62        omckk = NaN*ones(3,1);
63        Tckk = NaN*ones(3,1);
64       
65        if active_images(kk),
66            fprintf(1,'Warning: Cannot calibrate with image %d. Need to extract grid corners first.\n',kk)
67            fprintf(1,'         Set active_images(%d)=1; and run Extract grid corners.\n',kk)
68        end;
69       
70        active_images(kk) = 0;
71       
72    end;
73   
74    eval(['omc_' num2str(kk) ' = omckk;']);
75    eval(['Tc_' num2str(kk) ' = Tckk;']);
76   
77end;
78
79
80check_active_images;
Note: See TracBrowser for help on using the repository browser.