diff --git a/Projects/MufasaTests/project1.lpi b/Projects/MufasaTests/project1.lpi index 3fc1108..e3e8e1d 100644 --- a/Projects/MufasaTests/project1.lpi +++ b/Projects/MufasaTests/project1.lpi @@ -11,7 +11,7 @@ - + @@ -30,15 +30,15 @@ - + - - + + - + @@ -51,10 +51,10 @@ - - + + - + @@ -67,10 +67,10 @@ - - - - + + + + @@ -85,35 +85,31 @@ - - - + - - - + - - + + - - + + - + @@ -139,9 +135,11 @@ - - + + + + @@ -149,127 +147,141 @@ + + + + + + + + + + + + + + - + - - + + - - + + - - + + - - + + - - + + - - + + - + - + - + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - + - - + + - - + + - + - + - + - - + + - - + + - - + + - - + + - - + + - - + + @@ -290,12 +302,6 @@ - - - - - - diff --git a/Projects/MufasaTests/project1.lpr b/Projects/MufasaTests/project1.lpr index 283de52..64368a5 100644 --- a/Projects/MufasaTests/project1.lpr +++ b/Projects/MufasaTests/project1.lpr @@ -79,7 +79,8 @@ begin bmp := TMufasaBitmap.Create; {$WARNING Change This Path!} - bmp.LoadFromFile('/home/merlijn/Programs/mufasa/UpText/text5.bmp'); + //bmp.LoadFromFile('/home/merlijn/Programs/mufasa/UpText/text5.bmp'); + bmp.LoadFromFile('/home/merlijn/Programs/mufasa/hoi.bmp'); writeln(inttostr(bmp.Width) + ', ' + inttostr(bmp.height)); @@ -87,9 +88,9 @@ begin Time := GetTickCount; for i := 0 to 100 do - C.MOCR.GetUpTextAt(0,0); + C.MOCR.GetUpTextAt(10,10); writeln('Time: ' + FloatToStr(((GetTickCount - Time) / (i + 1)))); - writeln(C.MOCR.GetUpTextAt(0,0)); + writeln(C.MOCR.GetUpTextAt(10,10)); C.Free; bmp.OnDestroy:=nil; diff --git a/Projects/SAMufasaGUI/testunit.pas b/Projects/SAMufasaGUI/testunit.pas index 47d2e2c..afe7057 100644 --- a/Projects/SAMufasaGUI/testunit.pas +++ b/Projects/SAMufasaGUI/testunit.pas @@ -29,7 +29,7 @@ unit TestUnit; interface uses - Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs, + cthreads, Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs, StdCtrls, Menus, ComCtrls, ExtCtrls, SynEdit, SynHighlighterPas, SynMemo, //Client, MufasaTypes, @@ -298,6 +298,7 @@ begin begin //Terminate the thread the tough way. writeln('Terminating the Scriptthread'); Writeln('Exit code terminate: ' +inttostr(KillThread(ScriptThread.Handle))); + WaitForThreadTerminate(ScriptThread.Handle, 0); ScriptThread.Free; ScriptState := ss_None; end; diff --git a/Units/MMLAddon/PSInc/Wrappers/ocr.inc b/Units/MMLAddon/PSInc/Wrappers/ocr.inc new file mode 100644 index 0000000..665d64d --- /dev/null +++ b/Units/MMLAddon/PSInc/Wrappers/ocr.inc @@ -0,0 +1,4 @@ +function rs_GetUpText: String; +begin + Result := CurrThread.Client.MOCR.GetUpTextAt(9,9); +end; diff --git a/Units/MMLAddon/PSInc/pscompile.inc b/Units/MMLAddon/PSInc/pscompile.inc index cfdbf82..c3c6acf 100644 --- a/Units/MMLAddon/PSInc/pscompile.inc +++ b/Units/MMLAddon/PSInc/pscompile.inc @@ -97,6 +97,10 @@ Sender.AddFunction(@SetColorToleranceSpeed, 'procedure SetColorToleranceSpeed(ct Sender.AddFunction(@MoveMouse, 'procedure MoveMouse(x, y: integer);'); Sender.AddFunction(@GetMousePos, 'procedure GetMousePos(var x, y: integer);'); +{ OCR} + +Sender.AddFunction(@rs_GetUpText, 'function rs_GetUpText: string;'); + {Bitmaps} Sender.AddFunction(@CreateBitmap,'function CreateBitmap(w,h :integer) : integer;'); diff --git a/Units/MMLAddon/mmlpsthread.pas b/Units/MMLAddon/mmlpsthread.pas index 6e0f60b..1d14370 100644 --- a/Units/MMLAddon/mmlpsthread.pas +++ b/Units/MMLAddon/mmlpsthread.pas @@ -149,6 +149,8 @@ begin SyncInfo:= TheSyncInfo; SetLength(PluginsToLoad,0); Client := TClient.Create; + Client.MOCR.InitTOCR(AppPath + DS + 'Fonts'); + PSScript := TPSScript.Create(nil); PSScript.UsePreProcessor:= True; PSScript.OnNeedFile := @RequireFile; @@ -188,6 +190,7 @@ end; {$I PSInc/Wrappers/math.inc} {$I PSInc/Wrappers/mouse.inc} {$I PSInc/Wrappers/dtm.inc} +{$I PSInc/Wrappers/ocr.inc} procedure TMMLPSThread.OnProcessDirective(Sender: TPSPreProcessor; Parser: TPSPascalPreProcessorParser; const Active: Boolean; diff --git a/Units/MMLCore/ocr.pas b/Units/MMLCore/ocr.pas index f371990..eecd544 100644 --- a/Units/MMLCore/ocr.pas +++ b/Units/MMLCore/ocr.pas @@ -646,10 +646,10 @@ begin ww := 300; hh := 20; - if ww > w then - ww := w; - if hh > h then - hh := h; + if ww + atX > w then + ww := w - atX; + if hh + atY > h then + hh := h - atY; bmp := TMufasaBitmap.Create; // bmp.SetSize(ww - atX, hh - atY); CopyCLientToBitmap will automatically resize -> Resize bool is true. @@ -658,6 +658,7 @@ begin n := ExtractText(bmp.FData, bmp.Width, bmp.Height); Result := ocrDetect(n, bmp.Width, bmp.Height, OCRData[0]); + bmp.SaveToFile('/tmp/output.bmp'); bmp.Free; end;