| function LMdownloadCollection(loginname, varargin) |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
|
|
| |
| |
|
|
| webpageanno = ['http://labelme.csail.mit.edu/Annotations/users/' loginname]; |
| webpageimg = ['http://labelme.csail.mit.edu/Images/users/' loginname]; |
|
|
| Narguments = length(varargin); |
|
|
| switch Narguments |
| case {0,1} |
| error('Not enough input arguments.') |
| case 2 |
| disp('Download all the collections') |
| HOMEIMAGES = varargin{1}; |
| HOMEANNOTATIONS = varargin{2}; |
| folderlist = urldir(webpageimg, 'DIR'); |
| folderlist = {folderlist(:).name}; |
| if strcmp(folderlist{1}(1),'/'); |
| folderlist = folderlist(2:end); |
| end |
| case 3 |
| folderlist = varargin{1}; |
| HOMEIMAGES = varargin{2}; |
| HOMEANNOTATIONS = varargin{3}; |
| end |
|
|
| Nfolders = length(folderlist); |
|
|
| |
| disp('create folders'); |
| for i = 1:Nfolders |
| mkdir(HOMEIMAGES, folderlist{i}); |
| mkdir(HOMEANNOTATIONS, folderlist{i}); |
| end |
|
|
|
|
| disp('download images and annotations...') |
| for f = 1:Nfolders |
| disp(sprintf('Downloading folder %s (%d/%d)...', folderlist{f}, f, Nfolders)) |
| |
| wpi = [webpageimg '/' folderlist{f}]; |
| wpa = [webpageanno '/' folderlist{f}]; |
|
|
| if Narguments~=4 |
| images = urldir(wpi, 'img'); |
| if length(images)>0 |
| images = {images(:).name}; |
| end |
| |
| annotations = urldir(wpa, 'txt'); |
| if length(annotations)>0 |
| annotations = {annotations(:).name}; |
| end |
| else |
| j = strmatch(folderlist{f}, folders, 'exact'); |
| images = filelist(j); |
| annotations = strrep(filelist(j), '.jpg', '.xml'); |
| end |
| |
| |
| Nimages = length(images); |
| for i = 1:Nimages |
| disp(sprintf(' Downloading image %s (%d/%d)...', images{i}, i, Nimages)) |
| [F,STATUS] = urlwrite([wpi '/' images{i}], fullfile(HOMEIMAGES,folderlist{f},images{i})); |
| end |
| |
| Nanno= length(annotations); |
| for i = 1:Nanno |
| disp(sprintf(' Downloading annotation %s (%d/%d)...', annotations{i}, i, Nanno)) |
| [F,STATUS] = urlwrite([wpa '/' annotations{i}], fullfile(HOMEANNOTATIONS,folderlist{f},annotations{i})); |
| if STATUS == 0 |
| disp(sprintf('annotation file %s does not exist', annotations{i})) |
| end |
| end |
| end |
|
|