2014-05-18 12:36:01 +02:00
|
|
|
|
program uCompressHaar;
|
|
|
|
|
|
|
|
|
|
{$APPTYPE CONSOLE}
|
|
|
|
|
{$R *.res}
|
|
|
|
|
|
|
|
|
|
uses
|
|
|
|
|
System.SysUtils,
|
|
|
|
|
System.Classes,
|
2014-05-18 18:19:44 +02:00
|
|
|
|
System.Character,
|
2014-05-18 12:36:01 +02:00
|
|
|
|
System.ZLib;
|
|
|
|
|
|
2014-05-18 18:19:44 +02:00
|
|
|
|
function CreateResourceName(const FileName: String): string;
|
|
|
|
|
begin
|
|
|
|
|
Result := StringReplace(FileName, 'haarcascade', 'H', [rfIgnoreCase, rfReplaceAll]);
|
|
|
|
|
Result := StringReplace(Result, 'frontalface', 'FF', [rfIgnoreCase, rfReplaceAll]);
|
|
|
|
|
Result := StringReplace(Result, 'mcs', 'M', [rfIgnoreCase, rfReplaceAll]);
|
|
|
|
|
Result := StringReplace(Result, 'right', 'R', [rfIgnoreCase, rfReplaceAll]);
|
|
|
|
|
Result := StringReplace(Result, 'left', 'L', [rfIgnoreCase, rfReplaceAll]);
|
|
|
|
|
Result := StringReplace(Result, '.xml', '', [rfIgnoreCase, rfReplaceAll]);
|
|
|
|
|
Result := ToUpper(StringReplace(Result, '_', '', [rfIgnoreCase, rfReplaceAll]));
|
|
|
|
|
end;
|
|
|
|
|
|
2014-05-18 12:36:01 +02:00
|
|
|
|
Var
|
|
|
|
|
S: TSearchRec;
|
|
|
|
|
ZC: TZCompressionStream;
|
|
|
|
|
Fs, Fd: TFileStream;
|
2014-05-22 16:23:41 +02:00
|
|
|
|
// S_rc: TStringList;
|
|
|
|
|
// S_inc: TStringList;
|
2014-05-18 18:19:44 +02:00
|
|
|
|
iFileName, oFileName: string;
|
|
|
|
|
rName: String;
|
2014-05-18 12:36:01 +02:00
|
|
|
|
|
2014-05-22 16:23:41 +02:00
|
|
|
|
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> haarcascade.rc <20>
|
|
|
|
|
/// haarcascade.inc <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
/// <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> TocvHaarCascadeType
|
|
|
|
|
///
|
|
|
|
|
/// <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
2014-05-18 12:36:01 +02:00
|
|
|
|
begin
|
|
|
|
|
try
|
2014-05-22 16:23:41 +02:00
|
|
|
|
// S_rc := TStringList.Create;
|
|
|
|
|
// S_rc.Add('// Created uCompressHaar.exe');
|
|
|
|
|
// S_inc := TStringList.Create;
|
|
|
|
|
// S_inc.Add('// Created uCompressHaar.exe');
|
|
|
|
|
// S_inc.Add('const');
|
|
|
|
|
// S_inc.Add('FrontalFaceXML: array [TocvHaarCascadeType] of TocvHaarCascadeRecord =');
|
|
|
|
|
// S_inc.Add('(');
|
2014-05-18 18:30:32 +02:00
|
|
|
|
if FindFirst('*.xml', faAnyFile, S) = 0 then
|
2014-05-18 12:36:01 +02:00
|
|
|
|
repeat
|
2014-05-18 18:30:32 +02:00
|
|
|
|
iFileName := S.Name;
|
|
|
|
|
oFileName := S.Name + '.z';
|
2014-05-18 18:19:44 +02:00
|
|
|
|
Fs := TFileStream.Create(iFileName, fmOpenRead);
|
|
|
|
|
Fd := TFileStream.Create(oFileName, fmCreate);
|
|
|
|
|
ZC := TZCompressionStream.Create(clMax, Fd);
|
2014-05-18 12:36:01 +02:00
|
|
|
|
try
|
2014-05-18 18:19:44 +02:00
|
|
|
|
WriteLn(S.Size:8, ' ', S.Name);
|
2014-05-18 12:36:01 +02:00
|
|
|
|
ZC.CopyFrom(Fs, S.Size);
|
2014-05-18 18:19:44 +02:00
|
|
|
|
rName := CreateResourceName(S.Name);
|
2014-05-22 16:23:41 +02:00
|
|
|
|
// S_rc.Add(rName + ' RCDATA "' + S.Name + '.z"');
|
|
|
|
|
// S_inc.Add(Format('(Name: ''%s''; FileName: ''%s''),', [rName, S.Name]));
|
2014-05-18 12:36:01 +02:00
|
|
|
|
finally
|
|
|
|
|
ZC.Free;
|
|
|
|
|
Fs.Free;
|
|
|
|
|
Fd.Free;
|
|
|
|
|
end;
|
|
|
|
|
until FindNext(S) <> 0;
|
|
|
|
|
FindClose(S);
|
2014-05-22 16:23:41 +02:00
|
|
|
|
// S_rc.SaveToFile('haarcascade.rc');
|
|
|
|
|
// rName := S_inc[S_inc.Count - 1];
|
|
|
|
|
// Delete(rName, Length(rName), 1);
|
|
|
|
|
// S_inc[S_inc.Count - 1] := rName;
|
|
|
|
|
// S_inc.Add(');');
|
|
|
|
|
// S_inc.SaveToFile('haarcascade.inc');
|
|
|
|
|
// S_rc.Free;
|
|
|
|
|
// S_inc.Free;
|
2014-05-18 12:36:01 +02:00
|
|
|
|
except
|
|
|
|
|
on E: Exception do
|
2014-05-18 18:19:44 +02:00
|
|
|
|
WriteLn(E.ClassName, ': ', E.Message);
|
2014-05-18 12:36:01 +02:00
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
end.
|