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