function LearnActiveBasisTemplate(category)
% LearnActiveBasisTemplate - Learns an active basis template.
%

rootFolder = pwd;
imageNames = [];
imageNames = [imageNames; dir(sprintf('%s/image/%s/*.jpg',rootFolder,category))];
imageNames = [imageNames; dir(sprintf('%s/image/%s/*.bmp',rootFolder,category))];
imageNames = [imageNames; dir(sprintf('%s/image/%s/*.png',rootFolder,category))];
n = numel(imageNames);
imagepaths = cell(n,1);
for i = 1:n
    imagepaths{i} = sprintf('%s/image/%s/%s', rootFolder, category, imageNames(i).name);
end

% find the corresponding template parameter
load template_params
nT = length(templateParameters);
for iT = 1:nT
    if strcmp(templateParameters(iT).category,category) == 1
        templateSize = templateParameters(iT).templateSize;
        nsketch = templateParameters(iT).nElement_activebasis;
        GaborScale = templateParameters(iT).GaborScale;
        break;
    end
end

cd activebasis
ABlearn(category, imagepaths, nsketch, templateSize, GaborScale);
cd ..


