% TRAIN_OCR Training of OCR classifier based on multiclass SVM.
%
% Description:
% The following steps are performed:
% - Training set is created from data in directory ExamplesDir.
% - Multi-class SVM is trained.
% - The trained SVM model is saved.
%
% (c) Statistical Pattern Recognition Toolbox, (C) 1999-2003,
% Written by Vojtech Franc and Vaclav Hlavac,
% <a href="http://www.cvut.cz">Czech Technical University Prague</a>,
% <a href="http://www.feld.cvut.cz">Faculty of Electrical engineering</a>,
% <a href="http://cmp.felk.cvut.cz">Center for Machine Perception</a>
% Modifications:
% 4-jun-2004, VF
% 9-sep-2003, VF
ExamplesDir = '../../data/ocr_numerals/';
OCRFileName = 'ocrmodel';
options.ker = 'rbf';
options.arg = 5;
options.C = [inf];
options.verb = 100;
options.solver ='smo';
fprintf('Creating training set:\n');
TrainingDataFile = [ExamplesDir 'OcrTrndata.mat'];
mergesets( ExamplesDir, TrainingDataFile );
data = load(TrainingDataFile );
fprintf('Training multi-class SVM classifier.\n');
options.solver = 'imdm';
model = bsvm2(data,options);
model.labels = ['1' '2' '3' '4' '5' '6' '7' '8' '9' '0'];
fprintf('Saving found classifier to file %s...', OCRFileName);
savestruct(model,OCRFileName);
fprintf('done.\n');