Skip to content

Commit 332fea5

Browse files
committed
Added ocr Documentation
1 parent b343d93 commit 332fea5

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

utils/ocr.simba

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,21 @@ This page is about WaspLib's OCR.
77
{$INCLUDE_ONCE WaspLib/utils.simba}
88

99
type
10+
(*
11+
## TOCR
12+
Record wrapping TPixelOCR with convenience methods for text recognition.
13+
*)
1014
TOCR = record
1115
Engine: TPixelOCR;
1216
end;
1317

18+
(*
19+
## OCR.RecognizeStatic
20+
```pascal
21+
function TOCR.RecognizeStatic(bounds: TBox; font: TPixelFont; colors: TColorArray; tolerance: Single): String;
22+
```
23+
Recognizes static text (non-moving) within bounds using specified font and colors.
24+
*)
1425
function TOCR.RecognizeStatic(bounds: TBox; font: TPixelFont; colors: TColorArray; tolerance: Single): String;
1526
var
1627
img: TImage;
@@ -20,6 +31,13 @@ begin
2031
Result := Self.Engine.Recognize(img, font, [0,0]);
2132
end;
2233

34+
(*
35+
## OCR.RecognizeStaticInvert
36+
```pascal
37+
function TOCR.RecognizeStaticInvert(bounds: TBox; font: TPixelFont; colors: TColorArray): String;
38+
```
39+
Recognizes static text with inverted colors (background becomes text).
40+
*)
2341
function TOCR.RecognizeStaticInvert(bounds: TBox; font: TPixelFont; colors: TColorArray): String;
2442
var
2543
img: TImage;
@@ -29,6 +47,13 @@ begin
2947
Result := Self.Engine.Recognize(img, font, [0,0]);
3048
end;
3149

50+
(*
51+
## OCR.Recognize
52+
```pascal
53+
function TOCR.Recognize(bounds: TBox; font: TPixelFont; colors: TColorArray; tolerance: Single): String;
54+
```
55+
Recognizes text within bounds using specified font and colors.
56+
*)
3257
function TOCR.Recognize(bounds: TBox; font: TPixelFont; colors: TColorArray; tolerance: Single): String;
3358
var
3459
img: TImage;
@@ -38,6 +63,13 @@ begin
3863
Result := Self.Engine.Recognize(img, Font);
3964
end;
4065

66+
(*
67+
## OCR.RecognizeLines
68+
```pascal
69+
function TOCR.RecognizeLines(bounds: TBox; font: TPixelFont; colors: TColorArray; tolerance: Single): TStringArray;
70+
```
71+
Recognizes multiple lines of text, returning each line as a separate string.
72+
*)
4173
function TOCR.RecognizeLines(bounds: TBox; font: TPixelFont; colors: TColorArray; tolerance: Single): TStringArray;
4274
var
4375
img: TImage;
@@ -47,6 +79,13 @@ begin
4779
Result := Self.Engine.RecognizeLines(img, font);
4880
end;
4981

82+
(*
83+
## OCR.RecognizeShadow
84+
```pascal
85+
function TOCR.RecognizeShadow(bounds: TBox; font: TPixelFont; tolerance: Single): String;
86+
```
87+
Recognizes text by detecting shadow pixels and finding adjacent text colors.
88+
*)
5089
function TOCR.RecognizeShadow(bounds: TBox; font: TPixelFont; tolerance: Single): String;
5190
var
5291
img: TImage;
@@ -63,6 +102,13 @@ begin
63102
Result := Self.Engine.Recognize(img, font);
64103
end;
65104

105+
(*
106+
## OCR.RecognizeNumber
107+
```pascal
108+
function TOCR.RecognizeNumber(bounds: TBox; font: TPixelFont; colors: TColorArray; tolerance: Single): Integer;
109+
```
110+
Recognizes and extracts an integer from text within bounds.
111+
*)
66112
function TOCR.RecognizeNumber(bounds: TBox; font: TPixelFont; colors: TColorArray; tolerance: Single): Integer;
67113
begin
68114
Result := Self.Recognize(bounds, font, colors, tolerance).ExtractInteger();
@@ -87,9 +133,17 @@ begin
87133
end;
88134

89135
var
136+
(*
137+
## OCR variable
138+
Global {ref}`TOCR` variable.
139+
*)
90140
OCR: TOCR;
91141

92142
type
143+
(*
144+
## TRSFonts
145+
Record containing pre-loaded RuneScape fonts and common text colors.
146+
*)
93147
TRSFonts = record
94148
PLAIN_11: TPixelFont;
95149
PLAIN_12: TPixelFont;

0 commit comments

Comments
 (0)