@@ -25,7 +25,7 @@ procedure TSimpleOCR_Recognize(const Params: PParamArray; const Result: Pointer)
25
25
26
26
initialization
27
27
addGlobalType(' packed record' + LineEnding +
28
- ' Character: AnsiChar; ' + LineEnding +
28
+ ' Character: Char; ' + LineEnding +
29
29
' Width, Height: Int32;' + LineEnding +
30
30
' Loaded, HasShadow: Boolean;' + LineEnding +
31
31
' CharacterPoints: TPointArray;' + LineEnding +
@@ -46,7 +46,7 @@ initialization
46
46
addGlobalType(' packed record' + LineEnding +
47
47
' Color, Tolerance: Int32;' + LineEnding +
48
48
' UseShadow: Boolean;' + LineEnding +
49
- ' ShadowMaxValue: Int32;' + LineEnding +
49
+ ' ShadowMaxValue: Int32;' + LineEnding +
50
50
' Threshold: Boolean;' + LineEnding +
51
51
' ThresholdAmount: Int32;' + LineEnding +
52
52
' ThresholdInvert: Boolean;' + LineEnding +
@@ -63,35 +63,45 @@ initialization
63
63
' TSimpleOCR' );
64
64
65
65
addGlobalFunc(' procedure TFontSet.Load(Font: String; Space: Int32 = 4); native;' , @TFontSet_Load);
66
- addGlobalFunc(' function TSimpleOCR.Recognize(constref Client : T2DIntegerArray; constref Filter: TCompareRules; constref Font: TFontSet; IsStatic: Boolean = False; MaxWalk: Int32 = 40): String; overload; native;' , @TSimpleOCR_Recognize);
66
+ addGlobalFunc(' function TSimpleOCR.Recognize(Image : T2DIntegerArray; Filter: TCompareRules; constref Font: TFontSet; IsStatic: Boolean = False; MaxWalk: Int32 = 40): String; overload; native;' , @TSimpleOCR_Recognize);
67
67
68
- addCode(' function TSimpleOCR.Recognize(B: TBox; Filter: TCompareRules; constref Font: TFontSet; IsStatic: Boolean = False; MaxWalk: Int32 = 40): AnsiString; overload;' + LineEnding +
69
- ' begin' + LineEnding +
70
- ' Result := Self.Recognize(GetColorsMatrix(B.X1, B.Y1, B.X2, B.Y2), Filter, Font, IsStatic, MaxWalk);' + LineEnding +
71
- ' end;' + LineEnding +
72
- ' ' + LineEnding +
73
- ' function TSimpleOCR.Recognize(constref TPA: TPointArray; constref Font: TFontSet; MaxWalk: Int32 = 40): String; overload;' + LineEnding +
74
- ' var' + LineEnding +
75
- ' Matrix: T2DIntegerArray;' + LineEnding +
76
- ' B: TBox;' + LineEnding +
77
- ' I: Int32;' + LineEnding +
78
- ' begin' + LineEnding +
79
- ' B := GetTPABounds(TPA);' + LineEnding +
80
- ' ' + LineEnding +
81
- ' SetLength(Matrix, B.Y2 - B.Y1 + 1, B.X2 - B.X1 + 1);' + LineEnding +
82
- ' for I := 0 to High(TPA) do' + LineEnding +
83
- ' Matrix[TPA[I].Y - B.Y1][TPA[I].X - B.X1] := 255;' + LineEnding +
84
- ' ' + LineEnding +
85
- ' Result := Self.Recognize(Matrix, [255], Font, False, MaxWalk);' + LineEnding +
86
- ' end;' + LineEnding +
87
- ' ' + LineEnding +
88
- ' procedure TFontSet.Load(Font: String; Space: Int32 = 4); override;' + LineEnding +
89
- ' begin' + LineEnding +
90
- ' if not DirectoryExists(Font) then' + LineEnding +
91
- ' raise "Font directory does not exist: " + Font;' + LineEnding +
92
- ' inherited();' + LineEnding +
93
- ' if Length(Self.Data) = 0 then' + LineEnding +
94
- ' raise "Failed to load font: " + Font;' + LineEnding +
68
+ addCode(' function TSimpleOCR.Recognize(B: TBox; Filter: TCompareRules; constref Font: TFontSet; IsStatic: Boolean = False; MaxWalk: Int32 = 40): String; overload;' + LineEnding +
69
+ ' begin' + LineEnding +
70
+ ' Result := Self.Recognize(GetColorsMatrix(B.X1, B.Y1, B.X2, B.Y2), Filter, Font, IsStatic, MaxWalk);' + LineEnding +
71
+ ' end;' + LineEnding +
72
+ ' ' + LineEnding +
73
+ ' function TSimpleOCR.RecognizeNumber(B: TBox; Filter: TCompareRules; constref Font: TFontSet; IsStatic: Boolean = False; MaxWalk: Int32 = 40): Int64;' + LineEnding +
74
+ ' var' + LineEnding +
75
+ ' Text: String;' + LineEnding +
76
+ ' begin' + LineEnding +
77
+ ' Text := Self.Recognize(B, Filter, Font, IsStatic, MaxWalk);' + LineEnding +
78
+ ' Text := StringReplace(Text, "O", "0", [rfReplaceAll]);' + LineEnding +
79
+ ' ' + LineEnding +
80
+ ' Result := StrToIntDef(ExtractFromStr(Text, Numbers), -1);' + LineEnding +
81
+ ' end;' + LineEnding +
82
+ ' ' + LineEnding +
83
+ ' function TSimpleOCR.RecognizeTPA(constref TPA: TPointArray; constref Font: TFontSet; MaxWalk: Int32 = 40): String;' + LineEnding +
84
+ ' var' + LineEnding +
85
+ ' Matrix: T2DIntegerArray;' + LineEnding +
86
+ ' B: TBox;' + LineEnding +
87
+ ' I: Int32;' + LineEnding +
88
+ ' begin' + LineEnding +
89
+ ' B := GetTPABounds(TPA);' + LineEnding +
90
+ ' ' + LineEnding +
91
+ ' SetLength(Matrix, B.Y2 - B.Y1 + 1, B.X2 - B.X1 + 1);' + LineEnding +
92
+ ' for I := 0 to High(TPA) do' + LineEnding +
93
+ ' Matrix[TPA[I].Y - B.Y1][TPA[I].X - B.X1] := 255;' + LineEnding +
94
+ ' ' + LineEnding +
95
+ ' Result := Self.Recognize(Matrix, [255], Font, False, MaxWalk);' + LineEnding +
96
+ ' end;' + LineEnding +
97
+ ' ' + LineEnding +
98
+ ' procedure TFontSet.Load(Font: String; Space: Int32 = 4); override;' + LineEnding +
99
+ ' begin' + LineEnding +
100
+ ' if not DirectoryExists(Font) then' + LineEnding +
101
+ ' raise "Font directory does not exist: " + Font;' + LineEnding +
102
+ ' inherited();' + LineEnding +
103
+ ' if Length(Self.Data) = 0 then' + LineEnding +
104
+ ' raise "Failed to load font: " + Font;' + LineEnding +
95
105
' end;'
96
106
);
97
107
0 commit comments