[810] | 1 | %=======================================================================
|
---|
| 2 | % Copyright 2008-2014, 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 |
|
---|
[725] | 19 | % This small script looks in the direcory and checks if the images are there.
|
---|
| 20 | %
|
---|
| 21 | % This works only on Matlab 5.x (otherwise, the dir commands works differently)
|
---|
| 22 |
|
---|
| 23 | % (c) Jean-Yves Bouguet - Dec. 27th, 1999
|
---|
| 24 |
|
---|
| 25 | l = dir([calib_name '*']);
|
---|
| 26 |
|
---|
| 27 | Nl = size(l,1);
|
---|
| 28 | Nima_valid = 0;
|
---|
| 29 | ind_valid = [];
|
---|
| 30 | loc_extension = [];
|
---|
| 31 | length_name = size(calib_name,2);
|
---|
| 32 |
|
---|
| 33 | if Nl > 0,
|
---|
| 34 |
|
---|
| 35 | for pp = 1:Nl,
|
---|
| 36 |
|
---|
| 37 | filenamepp = l(pp).name;
|
---|
| 38 | if isempty(calib_name),
|
---|
| 39 | iii = 1;
|
---|
| 40 | else
|
---|
| 41 | iii = findstr(filenamepp,calib_name);
|
---|
| 42 | end;
|
---|
| 43 |
|
---|
| 44 | loc_ext = findstr(filenamepp,format_image);
|
---|
| 45 | string_num = filenamepp(length_name+1:loc_ext - 2);
|
---|
| 46 |
|
---|
| 47 | if isempty(str2num(string_num)),
|
---|
| 48 | iii = [];
|
---|
| 49 | end;
|
---|
| 50 |
|
---|
| 51 |
|
---|
| 52 | if ~isempty(iii),
|
---|
| 53 | if (iii(1) ~= 1),
|
---|
| 54 | iii = [];
|
---|
| 55 | end;
|
---|
| 56 | end;
|
---|
| 57 |
|
---|
| 58 |
|
---|
| 59 |
|
---|
| 60 | if ~isempty(iii) & ~isempty(loc_ext),
|
---|
| 61 |
|
---|
| 62 | Nima_valid = Nima_valid + 1;
|
---|
| 63 | ind_valid = [ind_valid pp];
|
---|
| 64 | loc_extension = [loc_extension loc_ext(1)];
|
---|
| 65 |
|
---|
| 66 | end;
|
---|
| 67 |
|
---|
| 68 | end;
|
---|
| 69 |
|
---|
| 70 | if (Nima_valid==0),
|
---|
| 71 |
|
---|
| 72 | % try the upper case format:
|
---|
| 73 |
|
---|
| 74 | format_image = upper(format_image);
|
---|
| 75 |
|
---|
| 76 |
|
---|
| 77 |
|
---|
| 78 | for pp = 1:Nl,
|
---|
| 79 |
|
---|
| 80 | filenamepp = l(pp).name;
|
---|
| 81 |
|
---|
| 82 | if isempty(calib_name),
|
---|
| 83 | iii = 1;
|
---|
| 84 | else
|
---|
| 85 | iii = findstr(filenamepp,calib_name);
|
---|
| 86 | end;
|
---|
| 87 |
|
---|
| 88 | loc_ext = findstr(filenamepp,format_image);
|
---|
| 89 | string_num = filenamepp(length_name+1:loc_ext - 2);
|
---|
| 90 |
|
---|
| 91 | if isempty(str2num(string_num)),
|
---|
| 92 | iii = [];
|
---|
| 93 | end;
|
---|
| 94 |
|
---|
| 95 |
|
---|
| 96 | if ~isempty(iii),
|
---|
| 97 | if (iii(1) ~= 1),
|
---|
| 98 | iii = [];
|
---|
| 99 | end;
|
---|
| 100 | end;
|
---|
| 101 |
|
---|
| 102 |
|
---|
| 103 |
|
---|
| 104 | if ~isempty(iii) & ~isempty(loc_ext),
|
---|
| 105 |
|
---|
| 106 | Nima_valid = Nima_valid + 1;
|
---|
| 107 | ind_valid = [ind_valid pp];
|
---|
| 108 | loc_extension = [loc_extension loc_ext(1)];
|
---|
| 109 |
|
---|
| 110 | end;
|
---|
| 111 |
|
---|
| 112 | end;
|
---|
| 113 |
|
---|
| 114 | if (Nima_valid==0),
|
---|
| 115 |
|
---|
| 116 | fprintf(1,'No image found. File format may be wrong.\n');
|
---|
| 117 |
|
---|
| 118 | else
|
---|
| 119 |
|
---|
| 120 |
|
---|
| 121 | % Get all the string numbers:
|
---|
| 122 |
|
---|
| 123 | string_length = zeros(1,Nima_valid);
|
---|
| 124 | indices = zeros(1,Nima_valid);
|
---|
| 125 |
|
---|
| 126 |
|
---|
| 127 | for ppp = 1:Nima_valid,
|
---|
| 128 |
|
---|
| 129 | name = l(ind_valid(ppp)).name;
|
---|
| 130 | string_num = name(length_name+1:loc_extension(ppp) - 2);
|
---|
| 131 | string_length(ppp) = size(string_num,2);
|
---|
| 132 | indices(ppp) = str2num(string_num);
|
---|
| 133 |
|
---|
| 134 | end;
|
---|
| 135 |
|
---|
| 136 | % Number of images...
|
---|
| 137 | first_num = min(indices);
|
---|
| 138 | n_ima = max(indices) - first_num + 1;
|
---|
| 139 |
|
---|
| 140 | if min(string_length) == max(string_length),
|
---|
| 141 |
|
---|
| 142 | N_slots = min(string_length);
|
---|
| 143 | type_numbering = 1;
|
---|
| 144 |
|
---|
| 145 | else
|
---|
| 146 |
|
---|
| 147 | N_slots = 1;
|
---|
| 148 | type_numbering = 0;
|
---|
| 149 |
|
---|
| 150 | end;
|
---|
| 151 |
|
---|
| 152 | image_numbers = first_num:n_ima-1+first_num;
|
---|
| 153 |
|
---|
| 154 | %%% By default, all the images are active for calibration:
|
---|
| 155 |
|
---|
| 156 | active_images = ones(1,n_ima);
|
---|
| 157 |
|
---|
| 158 |
|
---|
| 159 |
|
---|
| 160 | end;
|
---|
| 161 |
|
---|
| 162 | else
|
---|
| 163 |
|
---|
| 164 | % Get all the string numbers:
|
---|
| 165 |
|
---|
| 166 | string_length = zeros(1,Nima_valid);
|
---|
| 167 | indices = zeros(1,Nima_valid);
|
---|
| 168 |
|
---|
| 169 |
|
---|
| 170 | for ppp = 1:Nima_valid,
|
---|
| 171 |
|
---|
| 172 | name = l(ind_valid(ppp)).name;
|
---|
| 173 | string_num = name(length_name+1:loc_extension(ppp) - 2);
|
---|
| 174 | string_length(ppp) = size(string_num,2);
|
---|
| 175 | indices(ppp) = str2num(string_num);
|
---|
| 176 |
|
---|
| 177 | end;
|
---|
| 178 |
|
---|
| 179 | % Number of images...
|
---|
| 180 | first_num = min(indices);
|
---|
| 181 | n_ima = max(indices) - first_num + 1;
|
---|
| 182 |
|
---|
| 183 | if min(string_length) == max(string_length),
|
---|
| 184 |
|
---|
| 185 | N_slots = min(string_length);
|
---|
| 186 | type_numbering = 1;
|
---|
| 187 |
|
---|
| 188 | else
|
---|
| 189 |
|
---|
| 190 | N_slots = 1;
|
---|
| 191 | type_numbering = 0;
|
---|
| 192 |
|
---|
| 193 | end;
|
---|
| 194 |
|
---|
| 195 | image_numbers = first_num:n_ima-1+first_num;
|
---|
| 196 |
|
---|
| 197 | %%% By default, all the images are active for calibration:
|
---|
| 198 |
|
---|
| 199 | active_images = ones(1,n_ima);
|
---|
| 200 |
|
---|
| 201 | end;
|
---|
| 202 |
|
---|
| 203 | else
|
---|
| 204 |
|
---|
| 205 | fprintf(1,'No image found. Basename may be wrong.\n');
|
---|
| 206 |
|
---|
| 207 | end;
|
---|
| 208 |
|
---|