@@ -7,10 +7,21 @@ This page is about WaspLib's OCR.
77{$INCLUDE_ONCE WaspLib/utils.simba}
88
99type
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+ *)
1425function TOCR.RecognizeStatic(bounds: TBox; font: TPixelFont; colors: TColorArray; tolerance: Single): String;
1526var
1627 img: TImage;
2031 Result := Self.Engine.Recognize(img, font, [0,0]);
2132end;
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+ *)
2341function TOCR.RecognizeStaticInvert(bounds: TBox; font: TPixelFont; colors: TColorArray): String;
2442var
2543 img: TImage;
2947 Result := Self.Engine.Recognize(img, font, [0,0]);
3048end;
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+ *)
3257function TOCR.Recognize(bounds: TBox; font: TPixelFont; colors: TColorArray; tolerance: Single): String;
3358var
3459 img: TImage;
3863 Result := Self.Engine.Recognize(img, Font);
3964end;
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+ *)
4173function TOCR.RecognizeLines(bounds: TBox; font: TPixelFont; colors: TColorArray; tolerance: Single): TStringArray;
4274var
4375 img: TImage;
4779 Result := Self.Engine.RecognizeLines(img, font);
4880end;
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+ *)
5089function TOCR.RecognizeShadow(bounds: TBox; font: TPixelFont; tolerance: Single): String;
5190var
5291 img: TImage;
@@ -63,6 +102,13 @@ begin
63102 Result := Self.Engine.Recognize(img, font);
64103end;
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+ *)
66112function TOCR.RecognizeNumber(bounds: TBox; font: TPixelFont; colors: TColorArray; tolerance: Single): Integer;
67113begin
68114 Result := Self.Recognize(bounds, font, colors, tolerance).ExtractInteger();
@@ -87,9 +133,17 @@ begin
87133end;
88134
89135var
136+ (*
137+ ## OCR variable
138+ Global {ref}`TOCR` variable.
139+ *)
90140 OCR: TOCR;
91141
92142type
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