-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
494 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
// Random left returns numbers weighted to the left number | ||
|
||
const | ||
SampleCount = 1000000; | ||
Range = 10; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
unit simba.import_bitmapfontocr; | ||
|
||
{$i simba.inc} | ||
|
||
interface | ||
|
||
uses | ||
Classes, SysUtils, | ||
simba.base, simba.script; | ||
|
||
procedure ImportBitmapFontOCR(Script: TSimbaScript); | ||
|
||
implementation | ||
|
||
uses | ||
lptypes, lpvartypes, | ||
simba.pixelocr, | ||
simba.image; | ||
|
||
type | ||
PPixelFont = ^TPixelFont; | ||
PPixelOCR = ^TPixelOCR; | ||
|
||
procedure _LapePixelOCR_LoadFont(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV | ||
begin | ||
PPixelFont(Result)^ := PPixelOCR(Params^[0])^.LoadFont(PString(Params^[1])^, PInteger(Params^[2])^); | ||
end; | ||
|
||
procedure _LapePixelOCR_Recognize1(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV | ||
begin | ||
PString(Result)^ := PPixelOCR(Params^[0])^.Recognize(PSimbaImage(Params^[1])^, PPixelFont(Params^[2])^, PPoint(Params^[3])^); | ||
end; | ||
|
||
procedure _LapePixelOCR_Recognize2(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV | ||
begin | ||
PString(Result)^ := PPixelOCR(Params^[0])^.Recognize(PSimbaImage(Params^[1])^, PPixelFont(Params^[2])^, PBox(Params^[3])^); | ||
end; | ||
|
||
procedure _LapePixelOCR_RecognizeLines(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV | ||
begin | ||
PStringArray(Result)^ := PPixelOCR(Params^[0])^.RecognizeLines(PSimbaImage(Params^[1])^, PPixelFont(Params^[2])^, PBox(Params^[3])^); | ||
end; | ||
|
||
procedure ImportBitmapFontOCR(Script: TSimbaScript); | ||
begin | ||
with Script.Compiler do | ||
begin | ||
addGlobalType([ | ||
'record', | ||
' Glyphs: array of record', | ||
' Value: Char;', | ||
' Width: Integer;', | ||
' Height: Integer;', | ||
'', | ||
' points: TPointArray;', | ||
' shadow: TPointArray;', | ||
' background: TPointArray;', | ||
'', | ||
' BestMatch: Integer;', | ||
' end;', | ||
'', | ||
' Height: Integer;', | ||
' SpaceWidth: Integer;', | ||
'end;'], | ||
'TPixelFont' | ||
); | ||
|
||
addGlobalType([ | ||
'record', | ||
' Text: String;', | ||
' Hits: Integer;', | ||
' Bounds: TBox;', | ||
'end;'], | ||
'TPixelOCRMatch' | ||
); | ||
|
||
addGlobalType([ | ||
'record', | ||
' Tolerance: Single;', | ||
' ShadowTolerance: Single;', | ||
' Blacklist: set of Char;', | ||
' MaxWalk: Integer;', | ||
' Matches: array of TPixelOCRMatch;', | ||
'end'], | ||
'TPixelOCR' | ||
); | ||
|
||
addGlobalFunc('function TPixelOCR.LoadFont(dir: String; SpaceWidth: Integer): TPixelFont;', @_LapePixelOCR_LoadFont); | ||
|
||
addGlobalFunc('function TPixelOCR.Recognize(img: TImage; font: TPixelFont; p: TPoint): String; overload;', @_LapePixelOCR_Recognize1); | ||
addGlobalFunc('function TPixelOCR.Recognize(img: TImage; font: TPixelFont; bounds: TBox): String; overload;', @_LapePixelOCR_Recognize2); | ||
addGlobalFunc('function TPixelOCR.RecognizeLines(img: TImage; font: TPixelFont; bounds: TBox): TStringArray;', @_LapePixelOCR_RecognizeLines); | ||
end; | ||
end; | ||
|
||
end. | ||
|
Oops, something went wrong.