# LearnAdaboostTemplate

## PURPOSE

LearnAdaboostTemplate - Learns an adaboost "template", i.e. strong classifier.

## SYNOPSIS

function LearnAdaboostTemplate(category)

## DESCRIPTION

     LearnAdaboostTemplate - Learns an adaboost "template", i.e. strong classifier.

## CROSS-REFERENCE INFORMATION

This function calls:

- adaboostLearn LearnAdaboostTemplate - Learns an adaboost "template", i.e. strong classifier.

This function is called by:

- StartFromHere StartFromHere - The entry point of this project.

## SOURCE CODE

    0001 function LearnAdaboostTemplate(category)
    0002 % LearnAdaboostTemplate - Learns an adaboost "template", i.e. strong classifier.
    0003 %
    0004
    0005 disp(sprintf('Learning adaboost template for %s.',category));
    0006
    0007 rootFolder = pwd;
    0008
    0009 %% find the corresponding template parameter
    0010 load template_params
    0011 nT = length(templateParameters);
    0012 for iT = 1:nT
    0013     if strcmp(templateParameters(iT).category,category) == 1
    0014         templateSize = templateParameters(iT).templateSize;
    0015         nsketch = templateParameters(iT).nElement_adaboost;
    0016         GaborScale = templateParameters(iT).GaborScale;
    0017         break;
    0018     end
    0019 end
    0020
    0021 %% collect the paths of positive training images
    0022 imageNames = [];
    0023 imageNames = [imageNames; dir(sprintf('%s/image/%s/*.jpg',rootFolder,category))];
    0024 imageNames = [imageNames; dir(sprintf('%s/image/%s/*.bmp',rootFolder,category))];
    0025 imageNames = [imageNames; dir(sprintf('%s/image/%s/*.png',rootFolder,category))];
    0026 n = numel(imageNames);
    0027 posImagePaths = cell(n,1);
    0028 for i = 1:n
    0029     posImagePaths{i} = sprintf('%s/image/%s/%s', rootFolder, category, imageNames(i).name);
    0030 end
    0031
    0032 %% collect the paths of negative training images
    0033 imageNames = [];
    0034 negFolderName = sprintf('neg_%d_%d',templateSize(1),templateSize(2));
    0035 imageNames = [imageNames; dir(sprintf('%s/image/%s/*.jpg',rootFolder,negFolderName))];
    0036 imageNames = [imageNames; dir(sprintf('%s/image/%s/*.bmp',rootFolder,negFolderName))];
    0037 imageNames = [imageNames; dir(sprintf('%s/image/%s/*.png',rootFolder,negFolderName))];
    0038 n = numel(imageNames);
    0039 negImagePaths = cell(n,1);
    0040 for i = 1:n
    0041     negImagePaths{i} = sprintf('%s/image/%s/%s', rootFolder, negFolderName, imageNames(i).name);
    0042 end
    0043
    0044 %% start learning
    0045 cd adaboost
    0046
    0047 adaboostLearn(category, posImagePaths, negImagePaths, nsketch, templateSize, GaborScale);
    0048 cd ..
    0049