mirror of
https://github.com/moparisthebest/Simba
synced 2024-11-25 10:42:20 -05:00
OCR inner api changes. Added ``suppport'' for shadows.
Changed OCRBench a bit more. git-svn-id: http://www.villavu.com/repositories/merlijn/mufasa@308 3f818213-9676-44b0-a9b4-5e4c4e03d09d
This commit is contained in:
parent
f4c25beb0e
commit
64ba5b72ec
@ -7,7 +7,7 @@
|
|||||||
<TargetFileExt Value=""/>
|
<TargetFileExt Value=""/>
|
||||||
<Icon Value="0"/>
|
<Icon Value="0"/>
|
||||||
<UseXPManifest Value="True"/>
|
<UseXPManifest Value="True"/>
|
||||||
<ActiveEditorIndexAtStart Value="2"/>
|
<ActiveEditorIndexAtStart Value="0"/>
|
||||||
</General>
|
</General>
|
||||||
<VersionInfo>
|
<VersionInfo>
|
||||||
<ProjectVersion Value=""/>
|
<ProjectVersion Value=""/>
|
||||||
@ -31,12 +31,12 @@
|
|||||||
<PackageName Value="LCL"/>
|
<PackageName Value="LCL"/>
|
||||||
</Item1>
|
</Item1>
|
||||||
</RequiredPackages>
|
</RequiredPackages>
|
||||||
<Units Count="7">
|
<Units Count="9">
|
||||||
<Unit0>
|
<Unit0>
|
||||||
<Filename Value="project1.lpr"/>
|
<Filename Value="project1.lpr"/>
|
||||||
<IsPartOfProject Value="True"/>
|
<IsPartOfProject Value="True"/>
|
||||||
<UnitName Value="project1"/>
|
<UnitName Value="project1"/>
|
||||||
<UsageCount Value="21"/>
|
<UsageCount Value="24"/>
|
||||||
</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="75" Y="77"/>
|
<CursorPos X="95" Y="72"/>
|
||||||
<TopLine Value="55"/>
|
<TopLine Value="44"/>
|
||||||
<EditorIndex Value="0"/>
|
<EditorIndex Value="0"/>
|
||||||
<UsageCount Value="21"/>
|
<UsageCount Value="24"/>
|
||||||
<Loaded Value="True"/>
|
<Loaded Value="True"/>
|
||||||
</Unit1>
|
</Unit1>
|
||||||
<Unit2>
|
<Unit2>
|
||||||
@ -58,8 +58,8 @@
|
|||||||
<UnitName Value="colourhistory"/>
|
<UnitName Value="colourhistory"/>
|
||||||
<CursorPos X="10" Y="457"/>
|
<CursorPos X="10" Y="457"/>
|
||||||
<TopLine Value="437"/>
|
<TopLine Value="437"/>
|
||||||
<EditorIndex Value="4"/>
|
<EditorIndex Value="5"/>
|
||||||
<UsageCount Value="11"/>
|
<UsageCount Value="12"/>
|
||||||
<Loaded Value="True"/>
|
<Loaded Value="True"/>
|
||||||
</Unit2>
|
</Unit2>
|
||||||
<Unit3>
|
<Unit3>
|
||||||
@ -77,110 +77,165 @@
|
|||||||
<UnitName Value="Client"/>
|
<UnitName Value="Client"/>
|
||||||
<CursorPos X="21" Y="52"/>
|
<CursorPos X="21" Y="52"/>
|
||||||
<TopLine Value="32"/>
|
<TopLine Value="32"/>
|
||||||
<EditorIndex Value="1"/>
|
<EditorIndex Value="2"/>
|
||||||
<UsageCount Value="10"/>
|
<UsageCount Value="12"/>
|
||||||
<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="23" Y="100"/>
|
<CursorPos X="10" Y="290"/>
|
||||||
<TopLine Value="90"/>
|
<TopLine Value="313"/>
|
||||||
<EditorIndex Value="2"/>
|
<EditorIndex Value="3"/>
|
||||||
<UsageCount Value="10"/>
|
<UsageCount Value="12"/>
|
||||||
<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="3" Y="35"/>
|
<CursorPos X="49" Y="368"/>
|
||||||
<TopLine Value="27"/>
|
<TopLine Value="337"/>
|
||||||
<EditorIndex Value="3"/>
|
<EditorIndex Value="4"/>
|
||||||
<UsageCount Value="10"/>
|
<UsageCount Value="11"/>
|
||||||
<Loaded Value="True"/>
|
<Loaded Value="True"/>
|
||||||
</Unit6>
|
</Unit6>
|
||||||
|
<Unit7>
|
||||||
|
<Filename Value="../../Units/MMLCore/ocrutil.pas"/>
|
||||||
|
<UnitName Value="ocrutil"/>
|
||||||
|
<CursorPos X="58" Y="184"/>
|
||||||
|
<TopLine Value="160"/>
|
||||||
|
<EditorIndex Value="1"/>
|
||||||
|
<UsageCount Value="11"/>
|
||||||
|
<Loaded Value="True"/>
|
||||||
|
</Unit7>
|
||||||
|
<Unit8>
|
||||||
|
<Filename Value="../../../../Documents/lazarus/lcl/interfaces/gtk/gtkwidgetset.inc"/>
|
||||||
|
<CursorPos X="41" Y="1226"/>
|
||||||
|
<TopLine Value="1205"/>
|
||||||
|
<UsageCount Value="10"/>
|
||||||
|
</Unit8>
|
||||||
</Units>
|
</Units>
|
||||||
<JumpHistory Count="20" HistoryIndex="19">
|
<JumpHistory Count="30" HistoryIndex="29">
|
||||||
<Position1>
|
<Position1>
|
||||||
<Filename Value="unit1.pas"/>
|
<Filename Value="unit1.pas"/>
|
||||||
<Caret Line="9" Column="19" TopLine="1"/>
|
<Caret Line="65" Column="43" TopLine="33"/>
|
||||||
</Position1>
|
</Position1>
|
||||||
<Position2>
|
<Position2>
|
||||||
<Filename Value="unit1.pas"/>
|
<Filename Value="unit1.pas"/>
|
||||||
<Caret Line="25" Column="36" TopLine="1"/>
|
<Caret Line="55" Column="70" TopLine="22"/>
|
||||||
</Position2>
|
</Position2>
|
||||||
<Position3>
|
<Position3>
|
||||||
<Filename Value="../SAMufasaGUI/colourhistory.pas"/>
|
<Filename Value="unit1.pas"/>
|
||||||
<Caret Line="30" Column="67" TopLine="181"/>
|
<Caret Line="54" Column="70" TopLine="22"/>
|
||||||
</Position3>
|
</Position3>
|
||||||
<Position4>
|
<Position4>
|
||||||
<Filename Value="unit1.pas"/>
|
<Filename Value="unit1.pas"/>
|
||||||
<Caret Line="47" Column="87" TopLine="19"/>
|
<Caret Line="30" Column="60" TopLine="22"/>
|
||||||
</Position4>
|
</Position4>
|
||||||
<Position5>
|
<Position5>
|
||||||
<Filename Value="unit1.pas"/>
|
<Filename Value="unit1.pas"/>
|
||||||
<Caret Line="57" Column="34" TopLine="33"/>
|
<Caret Line="31" Column="60" TopLine="22"/>
|
||||||
</Position5>
|
</Position5>
|
||||||
<Position6>
|
<Position6>
|
||||||
<Filename Value="unit1.pas"/>
|
<Filename Value="unit1.pas"/>
|
||||||
<Caret Line="64" Column="7" TopLine="33"/>
|
<Caret Line="32" Column="60" TopLine="22"/>
|
||||||
</Position6>
|
</Position6>
|
||||||
<Position7>
|
<Position7>
|
||||||
<Filename Value="../../Units/MMLCore/client.pas"/>
|
<Filename Value="unit1.pas"/>
|
||||||
<Caret Line="52" Column="21" TopLine="32"/>
|
<Caret Line="31" Column="60" TopLine="22"/>
|
||||||
</Position7>
|
</Position7>
|
||||||
<Position8>
|
<Position8>
|
||||||
<Filename Value="../../Units/MMLCore/ocr.pas"/>
|
<Filename Value="unit1.pas"/>
|
||||||
<Caret Line="40" Column="31" TopLine="17"/>
|
<Caret Line="33" Column="60" TopLine="22"/>
|
||||||
</Position8>
|
</Position8>
|
||||||
<Position9>
|
<Position9>
|
||||||
<Filename Value="unit1.pas"/>
|
<Filename Value="unit1.pas"/>
|
||||||
<Caret Line="65" Column="43" TopLine="33"/>
|
<Caret Line="84" Column="50" TopLine="44"/>
|
||||||
</Position9>
|
</Position9>
|
||||||
<Position10>
|
<Position10>
|
||||||
<Filename Value="unit1.pas"/>
|
<Filename Value="../../Units/MMLCore/ocr.pas"/>
|
||||||
<Caret Line="55" Column="70" TopLine="22"/>
|
<Caret Line="81" Column="22" TopLine="60"/>
|
||||||
</Position10>
|
</Position10>
|
||||||
<Position11>
|
<Position11>
|
||||||
<Filename Value="unit1.pas"/>
|
<Filename Value="unit1.pas"/>
|
||||||
<Caret Line="54" Column="70" TopLine="22"/>
|
<Caret Line="75" Column="33" TopLine="49"/>
|
||||||
</Position11>
|
</Position11>
|
||||||
<Position12>
|
<Position12>
|
||||||
<Filename Value="unit1.pas"/>
|
<Filename Value="unit1.pas"/>
|
||||||
<Caret Line="30" Column="60" TopLine="22"/>
|
<Caret Line="79" Column="15" TopLine="42"/>
|
||||||
</Position12>
|
</Position12>
|
||||||
<Position13>
|
<Position13>
|
||||||
<Filename Value="unit1.pas"/>
|
<Filename Value="../../Units/MMLCore/bitmaps.pas"/>
|
||||||
<Caret Line="31" Column="60" TopLine="22"/>
|
<Caret Line="98" Column="21" TopLine="75"/>
|
||||||
</Position13>
|
</Position13>
|
||||||
<Position14>
|
<Position14>
|
||||||
<Filename Value="unit1.pas"/>
|
<Filename Value="../../Units/MMLCore/ocr.pas"/>
|
||||||
<Caret Line="32" Column="60" TopLine="22"/>
|
<Caret Line="31" Column="54" TopLine="25"/>
|
||||||
</Position14>
|
</Position14>
|
||||||
<Position15>
|
<Position15>
|
||||||
<Filename Value="unit1.pas"/>
|
<Filename Value="../../Units/MMLCore/ocrutil.pas"/>
|
||||||
<Caret Line="31" Column="60" TopLine="22"/>
|
<Caret Line="180" Column="111" TopLine="157"/>
|
||||||
</Position15>
|
</Position15>
|
||||||
<Position16>
|
<Position16>
|
||||||
<Filename Value="unit1.pas"/>
|
<Filename Value="../../Units/MMLCore/ocrutil.pas"/>
|
||||||
<Caret Line="33" Column="60" TopLine="22"/>
|
<Caret Line="181" Column="13" TopLine="160"/>
|
||||||
</Position16>
|
</Position16>
|
||||||
<Position17>
|
<Position17>
|
||||||
<Filename Value="unit1.pas"/>
|
<Filename Value="../../Units/MMLCore/ocrutil.pas"/>
|
||||||
<Caret Line="84" Column="50" TopLine="44"/>
|
<Caret Line="57" Column="51" TopLine="36"/>
|
||||||
</Position17>
|
</Position17>
|
||||||
<Position18>
|
<Position18>
|
||||||
<Filename Value="../../Units/MMLCore/ocr.pas"/>
|
<Filename Value="unit1.pas"/>
|
||||||
<Caret Line="81" Column="22" TopLine="60"/>
|
<Caret Line="72" Column="83" TopLine="57"/>
|
||||||
</Position18>
|
</Position18>
|
||||||
<Position19>
|
<Position19>
|
||||||
<Filename Value="../../Units/MMLCore/ocr.pas"/>
|
<Filename Value="unit1.pas"/>
|
||||||
<Caret Line="49" Column="22" TopLine="74"/>
|
<Caret Line="78" Column="38" TopLine="65"/>
|
||||||
</Position19>
|
</Position19>
|
||||||
<Position20>
|
<Position20>
|
||||||
<Filename Value="unit1.pas"/>
|
<Filename Value="../../Units/MMLCore/ocr.pas"/>
|
||||||
<Caret Line="75" Column="33" TopLine="49"/>
|
<Caret Line="42" Column="34" TopLine="25"/>
|
||||||
</Position20>
|
</Position20>
|
||||||
|
<Position21>
|
||||||
|
<Filename Value="../../Units/MMLCore/ocr.pas"/>
|
||||||
|
<Caret Line="78" Column="70" TopLine="62"/>
|
||||||
|
</Position21>
|
||||||
|
<Position22>
|
||||||
|
<Filename Value="../../Units/MMLCore/ocr.pas"/>
|
||||||
|
<Caret Line="290" Column="10" TopLine="265"/>
|
||||||
|
</Position22>
|
||||||
|
<Position23>
|
||||||
|
<Filename Value="unit1.pas"/>
|
||||||
|
<Caret Line="75" Column="17" TopLine="46"/>
|
||||||
|
</Position23>
|
||||||
|
<Position24>
|
||||||
|
<Filename Value="unit1.pas"/>
|
||||||
|
<Caret Line="76" Column="21" TopLine="56"/>
|
||||||
|
</Position24>
|
||||||
|
<Position25>
|
||||||
|
<Filename Value="unit1.pas"/>
|
||||||
|
<Caret Line="87" Column="27" TopLine="56"/>
|
||||||
|
</Position25>
|
||||||
|
<Position26>
|
||||||
|
<Filename Value="unit1.pas"/>
|
||||||
|
<Caret Line="72" Column="4" TopLine="56"/>
|
||||||
|
</Position26>
|
||||||
|
<Position27>
|
||||||
|
<Filename Value="unit1.pas"/>
|
||||||
|
<Caret Line="70" Column="70" TopLine="56"/>
|
||||||
|
</Position27>
|
||||||
|
<Position28>
|
||||||
|
<Filename Value="../../Units/MMLCore/ocrutil.pas"/>
|
||||||
|
<Caret Line="169" Column="23" TopLine="156"/>
|
||||||
|
</Position28>
|
||||||
|
<Position29>
|
||||||
|
<Filename Value="unit1.pas"/>
|
||||||
|
<Caret Line="71" Column="29" TopLine="44"/>
|
||||||
|
</Position29>
|
||||||
|
<Position30>
|
||||||
|
<Filename Value="../../Units/MMLCore/ocrutil.pas"/>
|
||||||
|
<Caret Line="184" Column="58" TopLine="160"/>
|
||||||
|
</Position30>
|
||||||
</JumpHistory>
|
</JumpHistory>
|
||||||
</ProjectOptions>
|
</ProjectOptions>
|
||||||
<CompilerOptions>
|
<CompilerOptions>
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
object Form1: TForm1
|
object Form1: TForm1
|
||||||
Left = 492
|
Left = 493
|
||||||
Height = 305
|
Height = 305
|
||||||
Top = 266
|
Top = 293
|
||||||
Width = 609
|
Width = 609
|
||||||
|
ActiveControl = BitmapButton
|
||||||
Caption = 'Form1'
|
Caption = 'Form1'
|
||||||
ClientHeight = 305
|
ClientHeight = 305
|
||||||
ClientWidth = 609
|
ClientWidth = 609
|
||||||
@ -40,6 +41,14 @@ object Form1: TForm1
|
|||||||
OnClick = PathButtonClick
|
OnClick = PathButtonClick
|
||||||
TabOrder = 2
|
TabOrder = 2
|
||||||
end
|
end
|
||||||
|
object FShadow: TCheckBox
|
||||||
|
Left = 507
|
||||||
|
Height = 20
|
||||||
|
Top = 112
|
||||||
|
Width = 79
|
||||||
|
Caption = 'Shadow?'
|
||||||
|
TabOrder = 3
|
||||||
|
end
|
||||||
object OCRFileOpen: TOpenDialog
|
object OCRFileOpen: TOpenDialog
|
||||||
Filter = '.bmp'
|
Filter = '.bmp'
|
||||||
left = 528
|
left = 528
|
||||||
|
@ -14,6 +14,7 @@ type
|
|||||||
|
|
||||||
TForm1 = class(TForm)
|
TForm1 = class(TForm)
|
||||||
BitmapButton: TButton;
|
BitmapButton: TButton;
|
||||||
|
FShadow: TCheckBox;
|
||||||
PathButton: TButton;
|
PathButton: TButton;
|
||||||
OCRButton: TButton;
|
OCRButton: TButton;
|
||||||
Image1: TImage;
|
Image1: TImage;
|
||||||
@ -45,9 +46,10 @@ Var
|
|||||||
C: TClient;
|
C: TClient;
|
||||||
bmp: TMufasaBitmap;
|
bmp: TMufasaBitmap;
|
||||||
x,y: integer;
|
x,y: integer;
|
||||||
|
s: string;
|
||||||
|
Shadow: boolean;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
writeln(BitmapPath);
|
|
||||||
if not FileExists(BitmapPath) then
|
if not FileExists(BitmapPath) then
|
||||||
begin
|
begin
|
||||||
MessageBox(0,pchar('You did not set a valid bitmap'), Pchar('Bitmap Error'),
|
MessageBox(0,pchar('You did not set a valid bitmap'), Pchar('Bitmap Error'),
|
||||||
@ -65,16 +67,24 @@ begin
|
|||||||
Exit;
|
Exit;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Form1.Image1.Canvas.Brush.Color := 0;
|
||||||
|
Form1.Image1.Canvas.Rectangle(0, 0, Form1.Image1.Canvas.Width, Form1.Image1.Canvas.Height);
|
||||||
|
|
||||||
C := TClient.Create;
|
C := TClient.Create;
|
||||||
bmp := TMufasaBitmap.Create;
|
bmp := TMufasaBitmap.Create;
|
||||||
bmp.LoadFromFile(BitmapPath);
|
bmp.LoadFromFile(BitmapPath);
|
||||||
C.MWindow.SetTarget(bmp);
|
C.MWindow.SetTarget(bmp);
|
||||||
C.MOCR.InitTOCR(UpTextPath + DS + '..' + DS);
|
|
||||||
writeln(C.MOCR.GetUpTextAt(7,7));
|
Shadow :=FShadow.Checked;
|
||||||
|
|
||||||
|
C.MOCR.InitTOCR(UpTextPath + DS + '..' + DS, Shadow);
|
||||||
|
s := C.MOCR.GetUpTextAt(7,7, Shadow);
|
||||||
|
|
||||||
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);
|
||||||
|
Form1.Image1.Canvas.Font.Color:=clRed;
|
||||||
|
Form1.Image1.Canvas.TextOut(0, C.MOCR.debugbmp.Height, s);
|
||||||
|
|
||||||
C.Free;
|
C.Free;
|
||||||
end;
|
end;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
object ColourHistoryForm: TColourHistoryForm
|
object ColourHistoryForm: TColourHistoryForm
|
||||||
Left = 373
|
Left = 374
|
||||||
Height = 250
|
Height = 250
|
||||||
Top = 308
|
Top = 335
|
||||||
Width = 490
|
Width = 490
|
||||||
ActiveControl = SelectionName
|
ActiveControl = SelectionName
|
||||||
Caption = 'Colour Picker History'
|
Caption = 'Colour Picker History'
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
{ This is an automatically generated lazarus resource file }
|
{ This is an automatically generated lazarus resource file }
|
||||||
|
|
||||||
LazarusResources.Add('TColourHistoryForm','FORMDATA',[
|
LazarusResources.Add('TColourHistoryForm','FORMDATA',[
|
||||||
'TPF0'#18'TColourHistoryForm'#17'ColourHistoryForm'#4'Left'#3'u'#1#6'Height'#3
|
'TPF0'#18'TColourHistoryForm'#17'ColourHistoryForm'#4'Left'#3'v'#1#6'Height'#3
|
||||||
+#250#0#3'Top'#3'4'#1#5'Width'#3#234#1#13'ActiveControl'#7#13'SelectionName'#7
|
+#250#0#3'Top'#3'O'#1#5'Width'#3#234#1#13'ActiveControl'#7#13'SelectionName'#7
|
||||||
+'Caption'#6#21'Colour Picker History'#12'ClientHeight'#3#227#0#11'ClientWidt'
|
+'Caption'#6#21'Colour Picker History'#12'ClientHeight'#3#227#0#11'ClientWidt'
|
||||||
+'h'#3#234#1#21'Constraints.MinHeight'#3#200#0#20'Constraints.MinWidth'#3#234
|
+'h'#3#234#1#21'Constraints.MinHeight'#3#200#0#20'Constraints.MinWidth'#3#234
|
||||||
+#1#4'Menu'#7#10'CHMainMenu'#8'OnCreate'#7#10'FormCreate'#6'OnHide'#7#15'UnSe'
|
+#1#4'Menu'#7#10'CHMainMenu'#8'OnCreate'#7#10'FormCreate'#6'OnHide'#7#15'UnSe'
|
||||||
|
@ -37,9 +37,9 @@ uses
|
|||||||
TMOCR = class(TObject)
|
TMOCR = class(TObject)
|
||||||
constructor Create(Owner: TObject);
|
constructor Create(Owner: TObject);
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
function InitTOCR(path: string): boolean;
|
function InitTOCR(path: string; shadow: Boolean): boolean;
|
||||||
function getTextPointsIn(sx, sy, w, h: Integer): TNormArray;
|
function getTextPointsIn(sx, sy, w, h: Integer; shadow: boolean): TNormArray;
|
||||||
function GetUpTextAt(atX, atY: integer): string;
|
function GetUpTextAt(atX, atY: integer; shadow: boolean): string;
|
||||||
private
|
private
|
||||||
Client: TObject;
|
Client: TObject;
|
||||||
OCRData: TocrDataArray;
|
OCRData: TocrDataArray;
|
||||||
@ -75,7 +75,7 @@ const
|
|||||||
Non optimised. ;-)
|
Non optimised. ;-)
|
||||||
}
|
}
|
||||||
|
|
||||||
function TMOCR.getTextPointsIn(sx, sy, w, h: Integer): TNormArray;
|
function TMOCR.getTextPointsIn(sx, sy, w, h: Integer; shadow: boolean): TNormArray;
|
||||||
var
|
var
|
||||||
bmp: TMufasaBitmap;
|
bmp: TMufasaBitmap;
|
||||||
x,y: integer;
|
x,y: integer;
|
||||||
@ -250,6 +250,19 @@ begin
|
|||||||
bmp.SaveToFile('/tmp/ocrdebug.bmp');
|
bmp.SaveToFile('/tmp/ocrdebug.bmp');
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
|
||||||
|
if shadow then
|
||||||
|
begin
|
||||||
|
for y := 0 to bmp.Height - 1 do
|
||||||
|
for x := 0 to bmp.Width - 1 do
|
||||||
|
begin
|
||||||
|
if bmp.fastgetpixel(x,y) <> clPurple then
|
||||||
|
begin
|
||||||
|
bmp.FastSetPixel(x,y,0);
|
||||||
|
continue;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end else
|
||||||
|
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
|
||||||
@ -274,6 +287,7 @@ begin
|
|||||||
continue;
|
continue;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
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);
|
||||||
@ -337,7 +351,7 @@ begin
|
|||||||
inherited Destroy;
|
inherited Destroy;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TMOCR.InitTOCR(path: string): boolean;
|
function TMOCR.InitTOCR(path: string; shadow: boolean): boolean;
|
||||||
begin
|
begin
|
||||||
{ This must be dynamic }
|
{ This must be dynamic }
|
||||||
|
|
||||||
@ -345,17 +359,17 @@ begin
|
|||||||
result := true;
|
result := true;
|
||||||
OCRPath := path + DS;
|
OCRPath := path + DS;
|
||||||
if DirectoryExists(path + DS + 'UpChars' + DS) then
|
if DirectoryExists(path + DS + 'UpChars' + DS) then
|
||||||
OCRData[0] := ocrutil.InitOCR(path + DS + 'UpChars' + DS)
|
OCRData[0] := ocrutil.InitOCR(path + DS + 'UpChars' + DS, shadow)
|
||||||
else
|
else
|
||||||
result := false;
|
result := false;
|
||||||
|
|
||||||
if DirectoryExists(path + DS + 'StatChars' + DS) then
|
if DirectoryExists(path + DS + 'StatChars' + DS) then
|
||||||
OCRData[1] := ocrutil.InitOCR(path + DS + 'StatChars' + DS)
|
OCRData[1] := ocrutil.InitOCR(path + DS + 'StatChars' + DS, shadow)
|
||||||
else
|
else
|
||||||
result := false;
|
result := false;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TMOCR.GetUpTextAt(atX, atY: integer): string;
|
function TMOCR.GetUpTextAt(atX, atY: integer; shadow: boolean): string;
|
||||||
|
|
||||||
var
|
var
|
||||||
n:Tnormarray;
|
n:Tnormarray;
|
||||||
@ -365,7 +379,7 @@ begin
|
|||||||
ww := 400;
|
ww := 400;
|
||||||
hh := 20;
|
hh := 20;
|
||||||
|
|
||||||
n := getTextPointsIn(atX, atY, ww, hh);
|
n := getTextPointsIn(atX, atY, ww, hh, shadow);
|
||||||
Result := ocrDetect(n, ww, hh, OCRData[0]);
|
Result := ocrDetect(n, ww, hh, OCRData[0]);
|
||||||
//writeln(result);
|
//writeln(result);
|
||||||
end;
|
end;
|
||||||
|
@ -53,8 +53,8 @@ type
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
procedure findBounds(glyphs: TocrGlyphMaskArray; out width,height: integer);
|
procedure findBounds(glyphs: TocrGlyphMaskArray; out width,height: integer);
|
||||||
function LoadGlyphMasks(path: string): TocrGlyphMaskArray;
|
function LoadGlyphMasks(path: string; shadow: boolean): TocrGlyphMaskArray;
|
||||||
function InitOCR(path: string): TocrData;
|
function InitOCR(path: string; shadow: boolean): TocrData;
|
||||||
function GuessGlyph(glyph: TNormArray; ocrdata: TocrData): char;
|
function GuessGlyph(glyph: TNormArray; ocrdata: TocrData): char;
|
||||||
function PointsToNorm(points: TpointArray; out w,h: integer): TNormArray;
|
function PointsToNorm(points: TpointArray; out w,h: integer): TNormArray;
|
||||||
function ImageToNorm(src: tRGBArray; w,h: integer): TNormArray;
|
function ImageToNorm(src: tRGBArray; w,h: integer): TNormArray;
|
||||||
@ -153,17 +153,22 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
{This Loads the actual data from the .bmp, but does not init all fields}
|
{This Loads the actual data from the .bmp, but does not init all fields}
|
||||||
function LoadGlyphMasks(path: string): TocrGlyphMaskArray;
|
function LoadGlyphMasks(path: string; shadow: boolean): TocrGlyphMaskArray;
|
||||||
var
|
var
|
||||||
strs: array of string;
|
strs: array of string;
|
||||||
bmp: array of Tbmp; {-> TMufasaBitmap, and why use an array? }
|
bmp: array of Tbmp; {-> TMufasaBitmap, and why use an array? }
|
||||||
len,size,i,j: integer;
|
len,size,i,j: integer;
|
||||||
color: tRGB;
|
color: tRGB;
|
||||||
|
shadow_i: byte;
|
||||||
begin
|
begin
|
||||||
strs:= GetFiles(path,'bmp');
|
strs:= GetFiles(path,'bmp');
|
||||||
len:= length(strs);
|
len:= length(strs);
|
||||||
SetLength(result,len);
|
SetLength(result,len);
|
||||||
SetLength(bmp,len);
|
SetLength(bmp,len);
|
||||||
|
if shadow then
|
||||||
|
shadow_i := 0
|
||||||
|
else
|
||||||
|
shadow_i := 255;
|
||||||
for i:= 0 to len-1 do
|
for i:= 0 to len-1 do
|
||||||
begin
|
begin
|
||||||
bmp[i]:= ReadBmp(path + strs[i]);
|
bmp[i]:= ReadBmp(path + strs[i]);
|
||||||
@ -172,8 +177,9 @@ begin
|
|||||||
for j:= 0 to size-1 do
|
for j:= 0 to size-1 do
|
||||||
begin
|
begin
|
||||||
color:= bmp[i].data[j];
|
color:= bmp[i].data[j];
|
||||||
if (color.r = 255) and (color.g = 255) and (color.b = 255) then
|
{ if (color.r = 255) and (color.g = 255 and not shadow_i) and
|
||||||
//if (color.r = 255) and (color.g = 0) and (color.b = 0) then
|
(color.b = 255 and not shadow_i) then}
|
||||||
|
if (color.r = 255) and (color.g = shadow_i) and (color.b = shadow_i) then
|
||||||
result[i].mask[j]:= 1
|
result[i].mask[j]:= 1
|
||||||
else
|
else
|
||||||
result[i].mask[j]:= 0;
|
result[i].mask[j]:= 0;
|
||||||
@ -186,7 +192,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
{Fully initalizes a TocrData structure, this is LoadFont or whatever, call it first}
|
{Fully initalizes a TocrData structure, this is LoadFont or whatever, call it first}
|
||||||
function InitOCR(path: string): TocrData;
|
function InitOCR(path: string; shadow: boolean): TocrData;
|
||||||
var
|
var
|
||||||
masks: TocrGlyphMaskArray;
|
masks: TocrGlyphMaskArray;
|
||||||
t,b,l,r,w,h,mw: integer;
|
t,b,l,r,w,h,mw: integer;
|
||||||
@ -195,7 +201,7 @@ var
|
|||||||
pos: integer;
|
pos: integer;
|
||||||
ascii: char;
|
ascii: char;
|
||||||
begin
|
begin
|
||||||
masks:= LoadGlyphMasks(path);
|
masks:= LoadGlyphMasks(path, shadow);
|
||||||
w:= 0;
|
w:= 0;
|
||||||
h:= 0;
|
h:= 0;
|
||||||
findBounds(masks,w,h);
|
findBounds(masks,w,h);
|
||||||
|
Loading…
Reference in New Issue
Block a user