-
Notifications
You must be signed in to change notification settings - Fork 3
/
SimpleOCR.lpr
135 lines (116 loc) · 5.36 KB
/
SimpleOCR.lpr
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
library SimpleOCR;
{==============================================================================]
Copyright (c) 2016, Jarl `slacky` Holta
Project: SimpleOCR
Project URL: https://github.com/WarPie/SimpleOCR
License: GNU Lesser GPL (http://www.gnu.org/licenses/lgpl.html)
[==============================================================================}
{$mode objfpc}{$H+}
{$macro on}
{$inline on}
{$DEFINE callconv :=
{$IFDEF WINDOWS}{$IFDEF CPU32}cdecl;{$ELSE}{$ENDIF}{$ENDIF}
{$IFDEF LINUX}{$IFDEF CPU32}cdecl;{$ELSE}{$ENDIF}{$ENDIF}
}
uses
SysUtils,
Math,
Classes,
OCRBitmap,
OCRTypes,
OCREngine,
SimbaPlugin;
// ------------------------------------------------------------------------------------------------
// Export definitions
// ------------------------------------------------------------------------------------------------
procedure TFontSet_Load(const Params: PParamArray); callconv export;
begin
TFontSet(Params^[0]^).Load(AnsiString(Params^[1]^), Int32(Params^[2]^));
end;
procedure TFontSet_Free(const Params: PParamArray); callconv export;
begin
TFontSet(Params^[0]^).Free();
end;
procedure TSimpleOCR_Init(const Params: PParamArray); callconv export;
begin
TSimpleOCR(Params^[0]^).Init(TFontSet(Params^[1]^));
end;
procedure TSimpleOCR_Init2(const Params: PParamArray); callconv export;
begin
TSimpleOCR(Params^[0]^).Init(AnsiString(Params^[1]^), Int32(Params^[2]^));
end;
procedure TSimpleOCR_Free(const Params: PParamArray); callconv export;
begin
TSimpleOCR(Params^[0]^).Free();
end;
procedure TSimpleOCR_SetFont(const Params: PParamArray); callconv export;
begin
TSimpleOCR(Params^[0]^).SetFont(PFontSet(Params^[1])^);
end;
procedure TSimpleOCR_SetFont2(const Params: PParamArray); callconv export;
begin
TSimpleOCR(Params^[0]^).SetFont(AnsiString(Params^[1]^), Int32(Params^[2]^));
end;
procedure TSimpleOCR_Recognize(const Params: PParamArray; const Result:Pointer); callconv export;
begin
AnsiString(Result^) := TSimpleOCR(Params^[0]^).Recognize(TBox(Params^[1]^),
TCompareRules(Params^[2]^),
Int32(Params^[3]^));
end;
procedure TSimpleOCR_RecognizeEx(const Params: PParamArray; const Result:Pointer); callconv export;
begin
AnsiString(Result^) := TSimpleOCR(Params^[0]^).RecognizeEx(TIntMatrix(Params^[1]^),
TCompareRules(Params^[2]^),
Int32(Params^[3]^));
end;
// ------------------------------------------------------------------------------------------------
// Export for Simba
// ------------------------------------------------------------------------------------------------
exports GetPluginABIVersion;
exports SetPluginMemManager;
exports GetFunctionCount;
exports GetFunctionInfo;
exports GetTypeCount;
exports GetTypeInfo;
//exports OnAttach;
exports OnDetach;
initialization
AddGlobalType('TFontChar',
'packed record' +LineEnding+
' FChar:AnsiChar;' +LineEnding+
' FWidth,FHeight:Int32;' +LineEnding+
' Loaded, HasShadow:LongBool;' +LineEnding+
' PTS,Shadow,Bad:TPointArray;' +LineEnding+
'end;');
AddGlobalType('TFontset',
'packed record' +LineEnding+
' FData: Array of TFontChar;' +LineEnding+
' SpaceWidth: Int32;' +LineEnding+
'end;');
AddGlobalType('TCompareRules',
'packed record' +LineEnding+
' Color, ColorMaxDiff: Int32;' +LineEnding+
' UseShadow: LongBool;' +LineEnding+
' ShadowMaxValue:Int32;' +LineEnding+
' Threshold: Int32;' +LineEnding+
' ThreshInv: LongBool;' +LineEnding+
'end;');
AddGlobalType('TSimpleOCR',
'packed record' +LineEnding+
' IsLoaded: LongBool;' +LineEnding+
' FontData: TFontSet;' +LineEnding+
' ClientID: TTarget_Exported;' +LineEnding+
' Client: T2DIntArray;' +LineEnding+
' __maxShadowAvg: Int32;' +LineEnding+
' __debugging: LongBool;' +LineEnding+
'end;');
AddLPCMethod(@TFontSet_Load, 'procedure TFontSet.Load(Font:AnsiString; Space:Int32=4);');
AddLPCMethod(@TFontSet_Free, 'procedure TFontSet.Free();');
AddLPCMethod(@TSimpleOCR_Init, 'procedure TSimpleOCR.Init(FontPath: TFontSet);');
AddLPCMethod(@TSimpleOCR_Init2, 'procedure TSimpleOCR.Init(Font: AnsiString; SpaceWidth: Int32=4); overload;');
AddLPCMethod(@TSimpleOCR_SetFont, 'procedure TSimpleOCR.SetFont(FontPath:TFontSet);');
AddLPCMethod(@TSimpleOCR_SetFont2, 'procedure TSimpleOCR.SetFont(Font:AnsiString; SpaceWidth:Int32=4); overload;');
AddLPCMethod(@TSimpleOCR_Free, 'procedure TSimpleOCR.Free();');
AddLPCMethod(@TSimpleOCR_Recognize, 'function TSimpleOCR.Recognize(B:TBox; Filter:TCompareRules; MaxWalk:Int32=40): AnsiString;');
AddLPCMethod(@TSimpleOCR_RecognizeEx,'function TSimpleOCR.RecognizeEx(AClient:T2DIntArray; Filter:TCompareRules; MaxWalk:Int32=40): AnsiString;');
end.