mirror of
https://github.com/moparisthebest/Simba
synced 2024-11-04 16:35:15 -05:00
More OCR changes, but mainly OCRBench changes.
git-svn-id: http://www.villavu.com/repositories/merlijn/mufasa@314 3f818213-9676-44b0-a9b4-5e4c4e03d09d
This commit is contained in:
parent
19abae25e1
commit
80ce9744c6
@ -7,7 +7,7 @@
|
|||||||
<TargetFileExt Value=""/>
|
<TargetFileExt Value=""/>
|
||||||
<Icon Value="0"/>
|
<Icon Value="0"/>
|
||||||
<UseXPManifest Value="True"/>
|
<UseXPManifest Value="True"/>
|
||||||
<ActiveEditorIndexAtStart Value="0"/>
|
<ActiveEditorIndexAtStart Value="3"/>
|
||||||
</General>
|
</General>
|
||||||
<VersionInfo>
|
<VersionInfo>
|
||||||
<ProjectVersion Value=""/>
|
<ProjectVersion Value=""/>
|
||||||
@ -31,12 +31,12 @@
|
|||||||
<PackageName Value="LCL"/>
|
<PackageName Value="LCL"/>
|
||||||
</Item1>
|
</Item1>
|
||||||
</RequiredPackages>
|
</RequiredPackages>
|
||||||
<Units Count="9">
|
<Units Count="11">
|
||||||
<Unit0>
|
<Unit0>
|
||||||
<Filename Value="project1.lpr"/>
|
<Filename Value="project1.lpr"/>
|
||||||
<IsPartOfProject Value="True"/>
|
<IsPartOfProject Value="True"/>
|
||||||
<UnitName Value="project1"/>
|
<UnitName Value="project1"/>
|
||||||
<UsageCount Value="24"/>
|
<UsageCount Value="27"/>
|
||||||
</Unit0>
|
</Unit0>
|
||||||
<Unit1>
|
<Unit1>
|
||||||
<Filename Value="unit1.pas"/>
|
<Filename Value="unit1.pas"/>
|
||||||
@ -44,10 +44,10 @@
|
|||||||
<ComponentName Value="Form1"/>
|
<ComponentName Value="Form1"/>
|
||||||
<ResourceBaseClass Value="Form"/>
|
<ResourceBaseClass Value="Form"/>
|
||||||
<UnitName Value="Unit1"/>
|
<UnitName Value="Unit1"/>
|
||||||
<CursorPos X="95" Y="72"/>
|
<CursorPos X="64" Y="131"/>
|
||||||
<TopLine Value="44"/>
|
<TopLine Value="102"/>
|
||||||
<EditorIndex Value="0"/>
|
<EditorIndex Value="0"/>
|
||||||
<UsageCount Value="24"/>
|
<UsageCount Value="27"/>
|
||||||
<Loaded Value="True"/>
|
<Loaded Value="True"/>
|
||||||
</Unit1>
|
</Unit1>
|
||||||
<Unit2>
|
<Unit2>
|
||||||
@ -58,9 +58,7 @@
|
|||||||
<UnitName Value="colourhistory"/>
|
<UnitName Value="colourhistory"/>
|
||||||
<CursorPos X="10" Y="457"/>
|
<CursorPos X="10" Y="457"/>
|
||||||
<TopLine Value="437"/>
|
<TopLine Value="437"/>
|
||||||
<EditorIndex Value="5"/>
|
<UsageCount Value="13"/>
|
||||||
<UsageCount Value="12"/>
|
|
||||||
<Loaded Value="True"/>
|
|
||||||
</Unit2>
|
</Unit2>
|
||||||
<Unit3>
|
<Unit3>
|
||||||
<Filename Value="../SAMufasaGUI/testunit.pas"/>
|
<Filename Value="../SAMufasaGUI/testunit.pas"/>
|
||||||
@ -78,25 +76,25 @@
|
|||||||
<CursorPos X="21" Y="52"/>
|
<CursorPos X="21" Y="52"/>
|
||||||
<TopLine Value="32"/>
|
<TopLine Value="32"/>
|
||||||
<EditorIndex Value="2"/>
|
<EditorIndex Value="2"/>
|
||||||
<UsageCount Value="12"/>
|
<UsageCount Value="14"/>
|
||||||
<Loaded Value="True"/>
|
<Loaded Value="True"/>
|
||||||
</Unit4>
|
</Unit4>
|
||||||
<Unit5>
|
<Unit5>
|
||||||
<Filename Value="../../Units/MMLCore/ocr.pas"/>
|
<Filename Value="../../Units/MMLCore/ocr.pas"/>
|
||||||
<UnitName Value="ocr"/>
|
<UnitName Value="ocr"/>
|
||||||
<CursorPos X="10" Y="290"/>
|
<CursorPos X="86" Y="342"/>
|
||||||
<TopLine Value="313"/>
|
<TopLine Value="315"/>
|
||||||
<EditorIndex Value="3"/>
|
<EditorIndex Value="3"/>
|
||||||
<UsageCount Value="12"/>
|
<UsageCount Value="14"/>
|
||||||
<Loaded Value="True"/>
|
<Loaded Value="True"/>
|
||||||
</Unit5>
|
</Unit5>
|
||||||
<Unit6>
|
<Unit6>
|
||||||
<Filename Value="../../Units/MMLCore/bitmaps.pas"/>
|
<Filename Value="../../Units/MMLCore/bitmaps.pas"/>
|
||||||
<UnitName Value="bitmaps"/>
|
<UnitName Value="bitmaps"/>
|
||||||
<CursorPos X="49" Y="368"/>
|
<CursorPos X="25" Y="436"/>
|
||||||
<TopLine Value="337"/>
|
<TopLine Value="416"/>
|
||||||
<EditorIndex Value="4"/>
|
<EditorIndex Value="6"/>
|
||||||
<UsageCount Value="11"/>
|
<UsageCount Value="13"/>
|
||||||
<Loaded Value="True"/>
|
<Loaded Value="True"/>
|
||||||
</Unit6>
|
</Unit6>
|
||||||
<Unit7>
|
<Unit7>
|
||||||
@ -105,7 +103,7 @@
|
|||||||
<CursorPos X="58" Y="184"/>
|
<CursorPos X="58" Y="184"/>
|
||||||
<TopLine Value="160"/>
|
<TopLine Value="160"/>
|
||||||
<EditorIndex Value="1"/>
|
<EditorIndex Value="1"/>
|
||||||
<UsageCount Value="11"/>
|
<UsageCount Value="13"/>
|
||||||
<Loaded Value="True"/>
|
<Loaded Value="True"/>
|
||||||
</Unit7>
|
</Unit7>
|
||||||
<Unit8>
|
<Unit8>
|
||||||
@ -114,127 +112,145 @@
|
|||||||
<TopLine Value="1205"/>
|
<TopLine Value="1205"/>
|
||||||
<UsageCount Value="10"/>
|
<UsageCount Value="10"/>
|
||||||
</Unit8>
|
</Unit8>
|
||||||
|
<Unit9>
|
||||||
|
<Filename Value="../../Units/MMLAddon/tpa.pas"/>
|
||||||
|
<UnitName Value="tpa"/>
|
||||||
|
<CursorPos X="68" Y="798"/>
|
||||||
|
<TopLine Value="779"/>
|
||||||
|
<EditorIndex Value="5"/>
|
||||||
|
<UsageCount Value="11"/>
|
||||||
|
<Loaded Value="True"/>
|
||||||
|
</Unit9>
|
||||||
|
<Unit10>
|
||||||
|
<Filename Value="../../Units/MMLCore/mufasatypesutil.pas"/>
|
||||||
|
<UnitName Value="mufasatypesutil"/>
|
||||||
|
<CursorPos X="1" Y="1"/>
|
||||||
|
<TopLine Value="1"/>
|
||||||
|
<EditorIndex Value="4"/>
|
||||||
|
<UsageCount Value="10"/>
|
||||||
|
<Loaded Value="True"/>
|
||||||
|
</Unit10>
|
||||||
</Units>
|
</Units>
|
||||||
<JumpHistory Count="30" HistoryIndex="29">
|
<JumpHistory Count="30" HistoryIndex="29">
|
||||||
<Position1>
|
<Position1>
|
||||||
<Filename Value="unit1.pas"/>
|
<Filename Value="unit1.pas"/>
|
||||||
<Caret Line="65" Column="43" TopLine="33"/>
|
<Caret Line="87" Column="27" TopLine="56"/>
|
||||||
</Position1>
|
</Position1>
|
||||||
<Position2>
|
<Position2>
|
||||||
<Filename Value="unit1.pas"/>
|
<Filename Value="unit1.pas"/>
|
||||||
<Caret Line="55" Column="70" TopLine="22"/>
|
<Caret Line="72" Column="4" TopLine="56"/>
|
||||||
</Position2>
|
</Position2>
|
||||||
<Position3>
|
<Position3>
|
||||||
<Filename Value="unit1.pas"/>
|
<Filename Value="unit1.pas"/>
|
||||||
<Caret Line="54" Column="70" TopLine="22"/>
|
<Caret Line="70" Column="70" TopLine="56"/>
|
||||||
</Position3>
|
</Position3>
|
||||||
<Position4>
|
<Position4>
|
||||||
<Filename Value="unit1.pas"/>
|
<Filename Value="../../Units/MMLCore/ocrutil.pas"/>
|
||||||
<Caret Line="30" Column="60" TopLine="22"/>
|
<Caret Line="169" Column="23" TopLine="156"/>
|
||||||
</Position4>
|
</Position4>
|
||||||
<Position5>
|
<Position5>
|
||||||
<Filename Value="unit1.pas"/>
|
<Filename Value="unit1.pas"/>
|
||||||
<Caret Line="31" Column="60" TopLine="22"/>
|
<Caret Line="71" Column="29" TopLine="44"/>
|
||||||
</Position5>
|
</Position5>
|
||||||
<Position6>
|
<Position6>
|
||||||
<Filename Value="unit1.pas"/>
|
<Filename Value="../../Units/MMLCore/ocrutil.pas"/>
|
||||||
<Caret Line="32" Column="60" TopLine="22"/>
|
<Caret Line="184" Column="58" TopLine="160"/>
|
||||||
</Position6>
|
</Position6>
|
||||||
<Position7>
|
<Position7>
|
||||||
<Filename Value="unit1.pas"/>
|
<Filename Value="unit1.pas"/>
|
||||||
<Caret Line="31" Column="60" TopLine="22"/>
|
<Caret Line="74" Column="107" TopLine="58"/>
|
||||||
</Position7>
|
</Position7>
|
||||||
<Position8>
|
<Position8>
|
||||||
<Filename Value="unit1.pas"/>
|
<Filename Value="../../Units/MMLCore/ocr.pas"/>
|
||||||
<Caret Line="33" Column="60" TopLine="22"/>
|
<Caret Line="57" Column="33" TopLine="37"/>
|
||||||
</Position8>
|
</Position8>
|
||||||
<Position9>
|
<Position9>
|
||||||
<Filename Value="unit1.pas"/>
|
<Filename Value="../../Units/MMLAddon/tpa.pas"/>
|
||||||
<Caret Line="84" Column="50" TopLine="44"/>
|
<Caret Line="30" Column="64" TopLine="25"/>
|
||||||
</Position9>
|
</Position9>
|
||||||
<Position10>
|
<Position10>
|
||||||
<Filename Value="../../Units/MMLCore/ocr.pas"/>
|
<Filename Value="../../Units/MMLAddon/tpa.pas"/>
|
||||||
<Caret Line="81" Column="22" TopLine="60"/>
|
<Caret Line="63" Column="20" TopLine="44"/>
|
||||||
</Position10>
|
</Position10>
|
||||||
<Position11>
|
<Position11>
|
||||||
<Filename Value="unit1.pas"/>
|
<Filename Value="../../Units/MMLCore/ocr.pas"/>
|
||||||
<Caret Line="75" Column="33" TopLine="49"/>
|
<Caret Line="89" Column="20" TopLine="70"/>
|
||||||
</Position11>
|
</Position11>
|
||||||
<Position12>
|
<Position12>
|
||||||
<Filename Value="unit1.pas"/>
|
<Filename Value="unit1.pas"/>
|
||||||
<Caret Line="79" Column="15" TopLine="42"/>
|
<Caret Line="94" Column="57" TopLine="71"/>
|
||||||
</Position12>
|
</Position12>
|
||||||
<Position13>
|
<Position13>
|
||||||
<Filename Value="../../Units/MMLCore/bitmaps.pas"/>
|
<Filename Value="unit1.pas"/>
|
||||||
<Caret Line="98" Column="21" TopLine="75"/>
|
<Caret Line="96" Column="57" TopLine="71"/>
|
||||||
</Position13>
|
</Position13>
|
||||||
<Position14>
|
<Position14>
|
||||||
<Filename Value="../../Units/MMLCore/ocr.pas"/>
|
<Filename Value="unit1.pas"/>
|
||||||
<Caret Line="31" Column="54" TopLine="25"/>
|
<Caret Line="98" Column="61" TopLine="82"/>
|
||||||
</Position14>
|
</Position14>
|
||||||
<Position15>
|
<Position15>
|
||||||
<Filename Value="../../Units/MMLCore/ocrutil.pas"/>
|
<Filename Value="unit1.pas"/>
|
||||||
<Caret Line="180" Column="111" TopLine="157"/>
|
<Caret Line="114" Column="13" TopLine="88"/>
|
||||||
</Position15>
|
</Position15>
|
||||||
<Position16>
|
<Position16>
|
||||||
<Filename Value="../../Units/MMLCore/ocrutil.pas"/>
|
<Filename Value="unit1.pas"/>
|
||||||
<Caret Line="181" Column="13" TopLine="160"/>
|
<Caret Line="96" Column="61" TopLine="77"/>
|
||||||
</Position16>
|
</Position16>
|
||||||
<Position17>
|
<Position17>
|
||||||
<Filename Value="../../Units/MMLCore/ocrutil.pas"/>
|
<Filename Value="unit1.pas"/>
|
||||||
<Caret Line="57" Column="51" TopLine="36"/>
|
<Caret Line="103" Column="10" TopLine="77"/>
|
||||||
</Position17>
|
</Position17>
|
||||||
<Position18>
|
<Position18>
|
||||||
<Filename Value="unit1.pas"/>
|
<Filename Value="unit1.pas"/>
|
||||||
<Caret Line="72" Column="83" TopLine="57"/>
|
<Caret Line="102" Column="8" TopLine="84"/>
|
||||||
</Position18>
|
</Position18>
|
||||||
<Position19>
|
<Position19>
|
||||||
<Filename Value="unit1.pas"/>
|
<Filename Value="../../Units/MMLCore/ocr.pas"/>
|
||||||
<Caret Line="78" Column="38" TopLine="65"/>
|
<Caret Line="42" Column="36" TopLine="25"/>
|
||||||
</Position19>
|
</Position19>
|
||||||
<Position20>
|
<Position20>
|
||||||
<Filename Value="../../Units/MMLCore/ocr.pas"/>
|
<Filename Value="unit1.pas"/>
|
||||||
<Caret Line="42" Column="34" TopLine="25"/>
|
<Caret Line="108" Column="47" TopLine="84"/>
|
||||||
</Position20>
|
</Position20>
|
||||||
<Position21>
|
<Position21>
|
||||||
<Filename Value="../../Units/MMLCore/ocr.pas"/>
|
<Filename Value="../../Units/MMLCore/ocr.pas"/>
|
||||||
<Caret Line="78" Column="70" TopLine="62"/>
|
<Caret Line="333" Column="23" TopLine="301"/>
|
||||||
</Position21>
|
</Position21>
|
||||||
<Position22>
|
<Position22>
|
||||||
<Filename Value="../../Units/MMLCore/ocr.pas"/>
|
<Filename Value="unit1.pas"/>
|
||||||
<Caret Line="290" Column="10" TopLine="265"/>
|
<Caret Line="109" Column="28" TopLine="89"/>
|
||||||
</Position22>
|
</Position22>
|
||||||
<Position23>
|
<Position23>
|
||||||
<Filename Value="unit1.pas"/>
|
<Filename Value="../../Units/MMLCore/ocr.pas"/>
|
||||||
<Caret Line="75" Column="17" TopLine="46"/>
|
<Caret Line="356" Column="43" TopLine="325"/>
|
||||||
</Position23>
|
</Position23>
|
||||||
<Position24>
|
<Position24>
|
||||||
<Filename Value="unit1.pas"/>
|
<Filename Value="../../Units/MMLCore/ocr.pas"/>
|
||||||
<Caret Line="76" Column="21" TopLine="56"/>
|
<Caret Line="343" Column="17" TopLine="324"/>
|
||||||
</Position24>
|
</Position24>
|
||||||
<Position25>
|
<Position25>
|
||||||
<Filename Value="unit1.pas"/>
|
<Filename Value="../../Units/MMLCore/ocr.pas"/>
|
||||||
<Caret Line="87" Column="27" TopLine="56"/>
|
<Caret Line="346" Column="11" TopLine="331"/>
|
||||||
</Position25>
|
</Position25>
|
||||||
<Position26>
|
<Position26>
|
||||||
<Filename Value="unit1.pas"/>
|
<Filename Value="../../Units/MMLCore/ocr.pas"/>
|
||||||
<Caret Line="72" Column="4" TopLine="56"/>
|
<Caret Line="355" Column="37" TopLine="331"/>
|
||||||
</Position26>
|
</Position26>
|
||||||
<Position27>
|
<Position27>
|
||||||
<Filename Value="unit1.pas"/>
|
<Filename Value="../../Units/MMLCore/ocr.pas"/>
|
||||||
<Caret Line="70" Column="70" TopLine="56"/>
|
<Caret Line="351" Column="33" TopLine="332"/>
|
||||||
</Position27>
|
</Position27>
|
||||||
<Position28>
|
<Position28>
|
||||||
<Filename Value="../../Units/MMLCore/ocrutil.pas"/>
|
<Filename Value="../../Units/MMLCore/bitmaps.pas"/>
|
||||||
<Caret Line="169" Column="23" TopLine="156"/>
|
<Caret Line="368" Column="49" TopLine="337"/>
|
||||||
</Position28>
|
</Position28>
|
||||||
<Position29>
|
<Position29>
|
||||||
<Filename Value="unit1.pas"/>
|
<Filename Value="../../Units/MMLCore/ocr.pas"/>
|
||||||
<Caret Line="71" Column="29" TopLine="44"/>
|
<Caret Line="351" Column="37" TopLine="332"/>
|
||||||
</Position29>
|
</Position29>
|
||||||
<Position30>
|
<Position30>
|
||||||
<Filename Value="../../Units/MMLCore/ocrutil.pas"/>
|
<Filename Value="../../Units/MMLCore/ocr.pas"/>
|
||||||
<Caret Line="184" Column="58" TopLine="160"/>
|
<Caret Line="377" Column="57" TopLine="347"/>
|
||||||
</Position30>
|
</Position30>
|
||||||
</JumpHistory>
|
</JumpHistory>
|
||||||
</ProjectOptions>
|
</ProjectOptions>
|
||||||
@ -256,7 +272,8 @@
|
|||||||
</Options>
|
</Options>
|
||||||
</Linking>
|
</Linking>
|
||||||
<Other>
|
<Other>
|
||||||
<CustomOptions Value="-dOCRDEBUG"/>
|
<CustomOptions Value="-dOCRDEBUG
|
||||||
|
-dOCRTPA"/>
|
||||||
<CompilerPath Value="$(CompPath)"/>
|
<CompilerPath Value="$(CompPath)"/>
|
||||||
</Other>
|
</Other>
|
||||||
</CompilerOptions>
|
</CompilerOptions>
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
object Form1: TForm1
|
object Form1: TForm1
|
||||||
Left = 493
|
Left = 462
|
||||||
Height = 305
|
Height = 306
|
||||||
Top = 293
|
Top = 264
|
||||||
Width = 609
|
Width = 609
|
||||||
ActiveControl = BitmapButton
|
ActiveControl = BitmapButton
|
||||||
Caption = 'Form1'
|
Caption = 'Form1'
|
||||||
ClientHeight = 305
|
ClientHeight = 306
|
||||||
ClientWidth = 609
|
ClientWidth = 609
|
||||||
|
OnCreate = FormCreate
|
||||||
LCLVersion = '0.9.29'
|
LCLVersion = '0.9.29'
|
||||||
object OCRButton: TButton
|
object OCRButton: TButton
|
||||||
Left = 512
|
Left = 512
|
||||||
@ -47,15 +48,33 @@ object Form1: TForm1
|
|||||||
Top = 112
|
Top = 112
|
||||||
Width = 79
|
Width = 79
|
||||||
Caption = 'Shadow?'
|
Caption = 'Shadow?'
|
||||||
|
OnChange = FShadowChange
|
||||||
TabOrder = 3
|
TabOrder = 3
|
||||||
end
|
end
|
||||||
|
object SplitEdit: TEdit
|
||||||
|
Left = 512
|
||||||
|
Height = 27
|
||||||
|
Top = 168
|
||||||
|
Width = 88
|
||||||
|
TabOrder = 4
|
||||||
|
Text = '1'
|
||||||
|
end
|
||||||
|
object SplitLabel: TLabel
|
||||||
|
Left = 512
|
||||||
|
Height = 18
|
||||||
|
Top = 144
|
||||||
|
Width = 88
|
||||||
|
AutoSize = False
|
||||||
|
Caption = 'Split Spacing:'
|
||||||
|
ParentColor = False
|
||||||
|
end
|
||||||
object OCRFileOpen: TOpenDialog
|
object OCRFileOpen: TOpenDialog
|
||||||
Filter = '.bmp'
|
Filter = '.bmp'
|
||||||
left = 528
|
left = 416
|
||||||
top = 192
|
top = 277
|
||||||
end
|
end
|
||||||
object UpCharsDialog: TSelectDirectoryDialog
|
object UpCharsDialog: TSelectDirectoryDialog
|
||||||
left = 528
|
left = 448
|
||||||
top = 160
|
top = 277
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -14,6 +14,8 @@ type
|
|||||||
|
|
||||||
TForm1 = class(TForm)
|
TForm1 = class(TForm)
|
||||||
BitmapButton: TButton;
|
BitmapButton: TButton;
|
||||||
|
SplitLabel: TLabel;
|
||||||
|
SplitEdit: TEdit;
|
||||||
FShadow: TCheckBox;
|
FShadow: TCheckBox;
|
||||||
PathButton: TButton;
|
PathButton: TButton;
|
||||||
OCRButton: TButton;
|
OCRButton: TButton;
|
||||||
@ -21,6 +23,8 @@ type
|
|||||||
OCRFileOpen: TOpenDialog;
|
OCRFileOpen: TOpenDialog;
|
||||||
UpCharsDialog: TSelectDirectoryDialog;
|
UpCharsDialog: TSelectDirectoryDialog;
|
||||||
procedure BitmapButtonClick(Sender: TObject);
|
procedure BitmapButtonClick(Sender: TObject);
|
||||||
|
procedure FormCreate(Sender: TObject);
|
||||||
|
procedure FShadowChange(Sender: TObject);
|
||||||
procedure OCRButtonClick(Sender: TObject);
|
procedure OCRButtonClick(Sender: TObject);
|
||||||
procedure PathButtonClick(Sender: TObject);
|
procedure PathButtonClick(Sender: TObject);
|
||||||
private
|
private
|
||||||
@ -48,6 +52,7 @@ Var
|
|||||||
x,y: integer;
|
x,y: integer;
|
||||||
s: string;
|
s: string;
|
||||||
Shadow: boolean;
|
Shadow: boolean;
|
||||||
|
Spacing: Integer;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
if not FileExists(BitmapPath) then
|
if not FileExists(BitmapPath) then
|
||||||
@ -70,6 +75,7 @@ begin
|
|||||||
Form1.Image1.Canvas.Brush.Color := 0;
|
Form1.Image1.Canvas.Brush.Color := 0;
|
||||||
Form1.Image1.Canvas.Rectangle(0, 0, Form1.Image1.Canvas.Width, Form1.Image1.Canvas.Height);
|
Form1.Image1.Canvas.Rectangle(0, 0, Form1.Image1.Canvas.Width, Form1.Image1.Canvas.Height);
|
||||||
|
|
||||||
|
// create and init client
|
||||||
C := TClient.Create;
|
C := TClient.Create;
|
||||||
bmp := TMufasaBitmap.Create;
|
bmp := TMufasaBitmap.Create;
|
||||||
bmp.LoadFromFile(BitmapPath);
|
bmp.LoadFromFile(BitmapPath);
|
||||||
@ -77,15 +83,39 @@ begin
|
|||||||
|
|
||||||
Shadow :=FShadow.Checked;
|
Shadow :=FShadow.Checked;
|
||||||
|
|
||||||
|
try
|
||||||
|
Spacing := StrToInt(Form1.SplitEdit.Text);
|
||||||
|
except
|
||||||
|
if shadow then
|
||||||
|
begin
|
||||||
|
MessageBox(0,pchar('Spacing could not be parsed.' +
|
||||||
|
'Defaulting to 2' ), Pchar('Space Error'), MB_OK);
|
||||||
|
Spacing := 2;
|
||||||
|
end
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
MessageBox(0,pchar('Spacing could not be parsed.' +
|
||||||
|
'Defaulting to 1' ), Pchar('Space Error'), MB_OK);
|
||||||
|
Spacing := 1;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
writeln('Spacing: ' + Inttostr(spacing));
|
||||||
|
// DS + .. + DS because InitOCR wants the directory of the Fonts, not UpChars
|
||||||
|
// only.
|
||||||
C.MOCR.InitTOCR(UpTextPath + DS + '..' + DS, Shadow);
|
C.MOCR.InitTOCR(UpTextPath + DS + '..' + DS, Shadow);
|
||||||
s := C.MOCR.GetUpTextAt(7,7, Shadow);
|
s := C.MOCR.GetUpTextAtEx(7,7, Shadow, Spacing);
|
||||||
|
|
||||||
|
// write to debugbmp
|
||||||
for y := 0 to C.MOCR.debugbmp.Height - 1 do
|
for y := 0 to C.MOCR.debugbmp.Height - 1 do
|
||||||
for x := 0 to C.MOCR.debugbmp.Width -1 do
|
for x := 0 to C.MOCR.debugbmp.Width -1 do
|
||||||
Form1.Image1.Canvas.Pixels[x,y] := C.MOCR.debugbmp.FastGetPixel(x,y);
|
Form1.Image1.Canvas.Pixels[x,y] := C.MOCR.debugbmp.FastGetPixel(x,y);
|
||||||
|
|
||||||
|
// print ocr'ed text
|
||||||
Form1.Image1.Canvas.Font.Color:=clRed;
|
Form1.Image1.Canvas.Font.Color:=clRed;
|
||||||
Form1.Image1.Canvas.TextOut(0, C.MOCR.debugbmp.Height, s);
|
Form1.Image1.Canvas.TextOut(0, C.MOCR.debugbmp.Height, s);
|
||||||
|
|
||||||
|
Form1.Image1.Picture.SaveToFile('/tmp/ocrbench.bmp');
|
||||||
|
|
||||||
C.Free;
|
C.Free;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -95,6 +125,20 @@ begin
|
|||||||
BitmapPath := OCRFileOpen.FileName;
|
BitmapPath := OCRFileOpen.FileName;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TForm1.FormCreate(Sender: TObject);
|
||||||
|
begin
|
||||||
|
{BitmapPath := '/home/merlijn/Programs/mufasa/pics/uptext2.bmp';
|
||||||
|
UpTextPath := '/home/merlijn/Programs/mufasa/Fonts/UpChars';}
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TForm1.FShadowChange(Sender: TObject);
|
||||||
|
begin
|
||||||
|
if Form1.FShadow.Checked then
|
||||||
|
Form1.SplitEdit.Text:='2'
|
||||||
|
else
|
||||||
|
Form1.SplitEdit.Text:='1';
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TForm1.PathButtonClick(Sender: TObject);
|
procedure TForm1.PathButtonClick(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
if UpCharsDialog.Execute then
|
if UpCharsDialog.Execute then
|
||||||
|
@ -98,7 +98,7 @@ threadvar
|
|||||||
CurrThread : TMMLPSThread;
|
CurrThread : TMMLPSThread;
|
||||||
implementation
|
implementation
|
||||||
uses
|
uses
|
||||||
dtmutil,
|
colour_conv,dtmutil,
|
||||||
{$ifdef mswindows}windows,{$endif}
|
{$ifdef mswindows}windows,{$endif}
|
||||||
uPSC_std, uPSC_controls,uPSC_classes,uPSC_graphics,uPSC_stdctrls,uPSC_forms,
|
uPSC_std, uPSC_controls,uPSC_classes,uPSC_graphics,uPSC_stdctrls,uPSC_forms,
|
||||||
uPSC_extctrls, //Compile-libs
|
uPSC_extctrls, //Compile-libs
|
||||||
@ -108,7 +108,6 @@ uses
|
|||||||
Graphics, //For Graphics types
|
Graphics, //For Graphics types
|
||||||
math, //Maths!
|
math, //Maths!
|
||||||
strutils,
|
strutils,
|
||||||
colour_conv,
|
|
||||||
input,
|
input,
|
||||||
tpa, //Tpa stuff
|
tpa, //Tpa stuff
|
||||||
forms,//Forms
|
forms,//Forms
|
||||||
|
@ -38,7 +38,8 @@ uses
|
|||||||
constructor Create(Owner: TObject);
|
constructor Create(Owner: TObject);
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
function InitTOCR(path: string; shadow: Boolean): boolean;
|
function InitTOCR(path: string; shadow: Boolean): boolean;
|
||||||
function getTextPointsIn(sx, sy, w, h: Integer; shadow: boolean): TNormArray;
|
function getTextPointsIn(sx, sy, w, h: Integer; shadow: boolean; spacing: Integer): TNormArray;
|
||||||
|
function GetUpTextAtEx(atX, atY: integer; shadow: boolean; Spacing: Integer): string;
|
||||||
function GetUpTextAt(atX, atY: integer; shadow: boolean): string;
|
function GetUpTextAt(atX, atY: integer; shadow: boolean): string;
|
||||||
private
|
private
|
||||||
Client: TObject;
|
Client: TObject;
|
||||||
@ -54,7 +55,7 @@ uses
|
|||||||
implementation
|
implementation
|
||||||
|
|
||||||
uses
|
uses
|
||||||
colour_conv, client, files;
|
colour_conv, client, files, tpa, mufasatypesutil;
|
||||||
|
|
||||||
const
|
const
|
||||||
ocr_Limit_High = 190;
|
ocr_Limit_High = 190;
|
||||||
@ -75,7 +76,7 @@ const
|
|||||||
Non optimised. ;-)
|
Non optimised. ;-)
|
||||||
}
|
}
|
||||||
|
|
||||||
function TMOCR.getTextPointsIn(sx, sy, w, h: Integer; shadow: boolean): TNormArray;
|
function TMOCR.getTextPointsIn(sx, sy, w, h: Integer; shadow: boolean; spacing: integer): TNormArray;
|
||||||
var
|
var
|
||||||
bmp: TMufasaBitmap;
|
bmp: TMufasaBitmap;
|
||||||
x,y: integer;
|
x,y: integer;
|
||||||
@ -84,7 +85,12 @@ var
|
|||||||
{$IFDEF OCRDEBUG}
|
{$IFDEF OCRDEBUG}
|
||||||
dx,dy: integer;
|
dx,dy: integer;
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
{$IFDEF OCRTPA}
|
||||||
|
t: tpointarray;
|
||||||
|
at, atf,att: T2DPointArray;
|
||||||
|
pc: integer;
|
||||||
|
max_len: integer;
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
begin
|
begin
|
||||||
bmp := TMufasaBitmap.Create;
|
bmp := TMufasaBitmap.Create;
|
||||||
@ -97,7 +103,7 @@ begin
|
|||||||
|
|
||||||
{$IFDEF OCRDEBUG}
|
{$IFDEF OCRDEBUG}
|
||||||
debugbmp := TMufasaBitmap.Create;
|
debugbmp := TMufasaBitmap.Create;
|
||||||
debugbmp.SetSize(w, (h + 2) * 4);
|
debugbmp.SetSize(w, (h + 2) * 5);
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
|
||||||
{$IFDEF OCRSAVEBITMAP}
|
{$IFDEF OCRSAVEBITMAP}
|
||||||
@ -266,11 +272,6 @@ begin
|
|||||||
for y := 0 to bmp.Height - 1 do
|
for y := 0 to bmp.Height - 1 do
|
||||||
for x := 0 to bmp.Width - 1 do
|
for x := 0 to bmp.Width - 1 do
|
||||||
begin
|
begin
|
||||||
{ if bmp.fastgetpixel(x,y) <> clPurple then
|
|
||||||
begin
|
|
||||||
bmp.FastSetPixel(x,y,0);
|
|
||||||
continue;
|
|
||||||
end; }
|
|
||||||
if bmp.fastgetpixel(x,y) = clPurple then
|
if bmp.fastgetpixel(x,y) = clPurple then
|
||||||
begin
|
begin
|
||||||
bmp.FastSetPixel(x,y,0);
|
bmp.FastSetPixel(x,y,0);
|
||||||
@ -292,17 +293,33 @@ begin
|
|||||||
for y := 0 to bmp.Height -1 do
|
for y := 0 to bmp.Height -1 do
|
||||||
bmp.fastsetpixel(0, y, 0);
|
bmp.fastsetpixel(0, y, 0);
|
||||||
|
|
||||||
|
{$IFDEF OCRTPA}
|
||||||
|
pc := 0;
|
||||||
|
setlength(t, bmp.Height * bmp.Width);
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
setlength(n, bmp.Height * bmp.Width);
|
setlength(n, bmp.Height * bmp.Width);
|
||||||
|
|
||||||
for y := 0 to bmp.Height - 1 do
|
for y := 0 to bmp.Height - 1 do
|
||||||
for x := 0 to bmp.Width - 1 do
|
for x := 0 to bmp.Width - 1 do
|
||||||
begin
|
begin
|
||||||
if bmp.fastgetpixel(x,y) > 0 then
|
if bmp.fastgetpixel(x,y) > 0 then
|
||||||
n[x + y * bmp.width] := 1
|
begin
|
||||||
|
n[x + y * bmp.width] := 1;
|
||||||
|
{$IFDEF OCRTPA}
|
||||||
|
t[pc] := point(x,y);
|
||||||
|
inc(pc);
|
||||||
|
{$ENDIF}
|
||||||
|
end
|
||||||
else
|
else
|
||||||
n[x + y * bmp.width] := 0;
|
n[x
|
||||||
|
+ y * bmp.width] := 0;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{$IFDEF OCRTPA}
|
||||||
|
setlength(t,pc);
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
result := n;
|
result := n;
|
||||||
{$IFDEF OCRSAVEBITMAP}
|
{$IFDEF OCRSAVEBITMAP}
|
||||||
bmp.SaveToFile('/tmp/ocrfinal.bmp');
|
bmp.SaveToFile('/tmp/ocrfinal.bmp');
|
||||||
@ -312,6 +329,64 @@ begin
|
|||||||
for dx := 0 to bmp.width - 1 do
|
for dx := 0 to bmp.width - 1 do
|
||||||
debugbmp.fastsetpixel(dx,dy+h+h+h,bmp.fastgetpixel(dx,dy));
|
debugbmp.fastsetpixel(dx,dy+h+h+h,bmp.fastgetpixel(dx,dy));
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
|
||||||
|
{$IFDEF OCRTPA}
|
||||||
|
at:=splittpaex(t,spacing,bmp.height);
|
||||||
|
|
||||||
|
{
|
||||||
|
// this was to split extra large points into smaller ones, but it usually won't help
|
||||||
|
if shadow then
|
||||||
|
max_len := 30
|
||||||
|
else
|
||||||
|
max_len := 50;
|
||||||
|
|
||||||
|
for x := 0 to high(at) do
|
||||||
|
begin
|
||||||
|
if length(at[x]) > max_len then
|
||||||
|
begin
|
||||||
|
setlength(t,0);
|
||||||
|
// t := at[x];
|
||||||
|
att := splittpaex(at[x], 1, bmp.height);
|
||||||
|
for y := 0 to high(att) do
|
||||||
|
begin
|
||||||
|
setlength(atf,length(atf)+1);
|
||||||
|
atf[high(atf)] := convtpaarr(att[y]);
|
||||||
|
end;
|
||||||
|
end else
|
||||||
|
begin
|
||||||
|
setlength(atf,length(atf)+1);
|
||||||
|
atf[high(atf)] := convtpaarr(at[x]);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
for x := 0 to high(atf) do
|
||||||
|
begin
|
||||||
|
pc := random(clWhite);
|
||||||
|
for y := 0 to high(atf[x]) do
|
||||||
|
bmp.FastSetPixel(atf[x][y].x, atf[x][y].y, pc);
|
||||||
|
end; }
|
||||||
|
|
||||||
|
for x := 0 to high(at) do
|
||||||
|
begin
|
||||||
|
if length(at[x]) > 70 then
|
||||||
|
begin
|
||||||
|
for y := 0 to high(at[x]) do
|
||||||
|
bmp.FastSetPixel(at[x][y].x, at[x][y].y, clOlive);
|
||||||
|
end else
|
||||||
|
begin
|
||||||
|
pc := random(clWhite);
|
||||||
|
for y := 0 to high(at[x]) do
|
||||||
|
bmp.FastSetPixel(at[x][y].x, at[x][y].y, pc);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
{$IFDEF OCRDEBUG}
|
||||||
|
for dy := 0 to bmp.height - 1 do
|
||||||
|
for dx := 0 to bmp.width - 1 do
|
||||||
|
debugbmp.fastsetpixel(dx,dy+h+h+h+h,bmp.fastgetpixel(dx,dy));
|
||||||
|
{$ENDIF}
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
|
|
||||||
bmp.Free;
|
bmp.Free;
|
||||||
{ Dangerous removes all pixels that had no pixels on x-1 or x+1}
|
{ Dangerous removes all pixels that had no pixels on x-1 or x+1}
|
||||||
{ for y := 0 to bmp.Height - 2 do
|
{ for y := 0 to bmp.Height - 2 do
|
||||||
@ -369,19 +444,25 @@ begin
|
|||||||
result := false;
|
result := false;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TMOCR.GetUpTextAt(atX, atY: integer; shadow: boolean): string;
|
function TMOCR.GetUpTextAtEx(atX, atY: integer; shadow: boolean; spacing: Integer): string;
|
||||||
|
|
||||||
var
|
var
|
||||||
n:Tnormarray;
|
n:Tnormarray;
|
||||||
ww, hh: integer;
|
ww, hh: integer;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
ww := 400;
|
ww := 400;
|
||||||
hh := 20;
|
hh := 20;
|
||||||
|
|
||||||
n := getTextPointsIn(atX, atY, ww, hh, shadow);
|
n := getTextPointsIn(atX, atY, ww, hh, shadow, spacing);
|
||||||
Result := ocrDetect(n, ww, hh, OCRData[0]);
|
Result := ocrDetect(n, ww, hh, OCRData[0]);
|
||||||
//writeln(result);
|
end;
|
||||||
|
|
||||||
|
function TMOCR.GetUpTextAt(atX, atY: integer; shadow: boolean): string;
|
||||||
|
|
||||||
|
begin
|
||||||
|
if shadow then
|
||||||
|
result := GetUpTextAtEx(atX, atY, shadow, 2)
|
||||||
|
else
|
||||||
|
result := GetUpTextAtEx(atX, atY, shadow, 1);
|
||||||
end;
|
end;
|
||||||
{
|
{
|
||||||
function TMOCR.GetUpTextAt(atX, atY: integer): string;
|
function TMOCR.GetUpTextAt(atX, atY: integer): string;
|
||||||
|
Loading…
Reference in New Issue
Block a user