Home > @RealAdaBooster > loadFromFid.m

loadFromFid

PURPOSE ^

LOADFROMFID load classifier from binary file

SYNOPSIS ^

function [ tcl ] = loadFromFid( cl, fid )

DESCRIPTION ^

LOADFROMFID load classifier from binary file
   Load RealAda boost classifier from binary file

   Inputs:
       cl: dummy realAda classifier object (RealAdaBooster)
       fid : file descriptor
   Outputs:
       tcl: instance of RealAdaboost classifier

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [ tcl ] = loadFromFid( cl, fid )
0002 %LOADFROMFID load classifier from binary file
0003 %   Load RealAda boost classifier from binary file
0004 %
0005 %   Inputs:
0006 %       cl: dummy realAda classifier object (RealAdaBooster)
0007 %       fid : file descriptor
0008 %   Outputs:
0009 %       tcl: instance of RealAdaboost classifier
0010 
0011 %% Read weak classifier name
0012 [nameLength, count] = fread(fid, 1, 'uint16');
0013 if count <= 0
0014     error('Error reading from file\n');
0015 end
0016 [weakClNameData, count] = fread(fid, nameLength, '*uint8');
0017 if count <= 0
0018     error('Error reading from file\n');
0019 end
0020 weakClName = deserialize(weakClNameData);
0021 weakCl = eval(weakClName);
0022 
0023 %% Read err bound
0024 [tcl.errBound, count] = fread(fid, 1, 'double');
0025 if count <= 0
0026     error('Error reading from file\n');
0027 end
0028 %% Read untrained weak classifier
0029 tcl.weakCl = loadFromFid(weakCl,fid);
0030 %% Read trained weak classifiers
0031 
0032 [numWeakClassifiers, count] = fread(fid, 1, 'uint16');
0033 if count <= 0
0034     error('Error reading from file\n');
0035 end
0036 tcl.trndCls = cell(1, numWeakClassifiers);
0037 
0038 % read classifier data
0039 for i = 1:numWeakClassifiers
0040     tcl.trndCls{i} = loadFromFid(weakCl, fid);
0041 end
0042 
0043 %% Read number of stages
0044 [tcl.nStages, count] = fread(fid, 1, 'uint16');
0045 if count <= 0
0046     error('Error reading from file\n');
0047 end
0048 
0049 %% Read last instances weights
0050 
0051 % read length of weights
0052 [dataSize, count] = fread(fid, 1, 'uint16');
0053 if count <= 0
0054     error('Error reading from file\n');
0055 end
0056 % read weights array
0057 [data, count] = fread(fid, dataSize, '*uint8');
0058 if count <= 0
0059     error('Error reading from file\n');
0060 end
0061 tcl.lastExWeights = deserialize(data);
0062 %% Read cls weights
0063 % read length of weights
0064 [dataSize, count] = fread(fid, 1, 'uint16');
0065 if count <= 0
0066     error('Error reading from file\n');
0067 end
0068 % read weights array
0069 [data, count] = fread(fid, dataSize, '*uint8');
0070 if count <= 0
0071     error('Error reading from file\n');
0072 end
0073 tcl.clsWeights = deserialize(data);
0074 
0075 %% read threshold
0076 [tcl.thresh, count] = fread(fid, 1, 'double');
0077 if count <= 0
0078     error('Error reading from file\n');
0079 end
0080 %% write detection rate
0081 [tcl.detectionRate, count] = fread(fid, 1, 'double');
0082 if count <= 0
0083     error('Error reading from file\n');
0084 end
0085 
0086 %% create real ada object
0087 tcl = class(tcl, 'RealAdaBooster', Classifier(getNumClasses(weakCl)));
0088 
0089 end
0090

Generated on Sun 29-Sep-2013 01:25:24 by m2html © 2005