0001 function [ tcl ] = loadFromFid( cl, fid )
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
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
0024 [tcl.errBound, count] = fread(fid, 1, 'double');
0025 if count <= 0
0026 error('Error reading from file\n');
0027 end
0028
0029 tcl.weakCl = loadFromFid(weakCl,fid);
0030
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
0039 for i = 1:numWeakClassifiers
0040 tcl.trndCls{i} = loadFromFid(weakCl, fid);
0041 end
0042
0043
0044 [tcl.nStages, count] = fread(fid, 1, 'uint16');
0045 if count <= 0
0046 error('Error reading from file\n');
0047 end
0048
0049
0050
0051
0052 [dataSize, count] = fread(fid, 1, 'uint16');
0053 if count <= 0
0054 error('Error reading from file\n');
0055 end
0056
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
0063
0064 [dataSize, count] = fread(fid, 1, 'uint16');
0065 if count <= 0
0066 error('Error reading from file\n');
0067 end
0068
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
0076 [tcl.thresh, count] = fread(fid, 1, 'double');
0077 if count <= 0
0078 error('Error reading from file\n');
0079 end
0080
0081 [tcl.detectionRate, count] = fread(fid, 1, 'double');
0082 if count <= 0
0083 error('Error reading from file\n');
0084 end
0085
0086
0087 tcl = class(tcl, 'RealAdaBooster', Classifier(getNumClasses(weakCl)));
0088
0089 end
0090