4242
4343
4444
45- function TRSOCR.RecognizeStatic(Bounds : TBox; Font : TPixelFont; Colors : TColorArray; Tolerance : Single): String;
45+ function TRSOCR.RecognizeStatic(bounds : TBox; font : TPixelFont; colors : TColorArray; tolerance : Single): String;
4646var
4747 img: TImage;
4848begin
49- img := TImage.CreateFromTarget(Bounds );
50- img.ReplaceColorBinary(False, Colors, Tolerance );
51- Result := Self.Engine.Recognize(img, Font , [0,0]);
49+ img := TImage.CreateFromTarget(bounds );
50+ img.ReplaceColorBinary(False, colors, tolerance );
51+ Result := Self.Engine.Recognize(img, font , [0,0]);
5252 img.Free();
5353end;
5454
55- function TRSOCR.RecognizeStaticInvert(Bounds : TBox; Font : TPixelFont; Colors : TColorArray): String;
55+ function TRSOCR.RecognizeStaticInvert(bounds : TBox; font : TPixelFont; colors : TColorArray): String;
5656var
5757 img: TImage;
5858begin
59- img := TImage.CreateFromTarget(Bounds );
60- img.ReplaceColorBinary(True, Colors );
61- Result := Self.Engine.Recognize(img, Font , [0,0]);
59+ img := TImage.CreateFromTarget(bounds );
60+ img.ReplaceColorBinary(True, colors );
61+ Result := Self.Engine.Recognize(img, font , [0,0]);
6262 img.Free();
6363end;
6464
65- function TRSOCR.Recognize(Bounds : TBox; Font : TPixelFont; Colors : TColorArray; Tolerance : Single): String;
65+ function TRSOCR.Recognize(bounds : TBox; font : TPixelFont; colors : TColorArray; tolerance : Single): String;
6666var
6767 img: TImage;
6868begin
69- img := TImage.CreateFromTarget(Bounds );
70- img.ReplaceColorBinary(False, Colors, Tolerance );
69+ img := TImage.CreateFromTarget(bounds );
70+ img.ReplaceColorBinary(False, colors, tolerance );
7171 Result := Self.Engine.Recognize(img, Font);
7272 img.Free();
7373end;
7474
75- function TRSOCR.RecognizeLines(Bounds : TBox; Font : TPixelFont; Colors : TColorArray; Tolerance : Single): TStringArray;
75+ function TRSOCR.RecognizeLines(bounds : TBox; font : TPixelFont; colors : TColorArray; tolerance : Single): TStringArray;
7676var
7777 img: TImage;
7878begin
79- img := TImage.CreateFromTarget(Bounds );
80- img.ReplaceColorBinary(False, Colors, Tolerance );
81- Result := Self.Engine.RecognizeLines(img, Font );
79+ img := TImage.CreateFromTarget(bounds );
80+ img.ReplaceColorBinary(False, colors, tolerance );
81+ Result := Self.Engine.RecognizeLines(img, font );
8282 img.Free();
8383end;
8484
85- function TRSOCR.RecognizeShadow(Bounds : TBox; Font : TPixelFont; Tolerance : Single): String;
85+ function TRSOCR.RecognizeShadow(bounds : TBox; font : TPixelFont; tolerance : Single): String;
8686var
87- Image : TImage;
88- Shadows, ShadowsOffset : TPointArray;
89- Color : TColor;
87+ image : TImage;
88+ shadows : TPointArray;
89+ color : TColor;
9090begin
91- Image := TImage.CreateFromTarget(Bounds );
92- Shadows := Image .FindColor(0, 2.5, [1, 1, Image .Width - 1, Image .Height - 1]);
93- Shadows := Shadows.Offset([-1,-1]).ExcludePoints(Shadows );
94- Color := Image .GetColors(Shadows ).Mode;
95- Image .ReplaceColorBinary(False, Color, Tolerance );
96- Result := Self.Engine.Recognize(Image, Font );
97- Image .Free();
91+ image := TImage.CreateFromTarget(bounds );
92+ shadows := image .FindColor(0, 2.5, [1, 1, image .Width - 1, image .Height - 1]);
93+ shadows := Shadows.Offset([-1,-1]).ExcludePoints(shadows );
94+ color := image .GetColors(shadows ).Mode;
95+ image .ReplaceColorBinary(False, color, tolerance );
96+ Result := Self.Engine.Recognize(image, font );
97+ image .Free();
9898end;
9999
100- function TRSOCR.RecognizeNumber(Bounds: TBox; Font: TPixelFont; Colors: TColorArray; Tolerance: Single): Integer;
101- var
102- img: TImage;
103- txt: String;
100+ function TRSOCR.RecognizeNumber(bounds: TBox; font: TPixelFont; colors: TColorArray; tolerance: Single): Integer;
104101begin
105- img := TImage.CreateFromTarget(Bounds);
106- img.ReplaceColorBinary(False, Colors, Tolerance);
107- txt := Self.Engine.Recognize(img, Font);
108- Result := txt.ExtractInteger();
109- img.Free();
102+ Result := Self.Recognize(bounds, font, colors, tolerance).ExtractInteger();
110103end;
111104
112- function TRSOCR.Locate(Bounds : TBox; Text: String; Colors : TColorArray; Tolerance : Single; Font : TPixelFont): Single;
105+ function TRSOCR.Locate(bounds : TBox; Text: String; colors : TColorArray; tolerance : Single; font : TPixelFont): Single;
113106var
114107 img: TImage;
115108begin
116- img := TImage.CreateFromTarget(Bounds );
117- img.ReplaceColorBinary(False, Colors, Tolerance );
109+ img := TImage.CreateFromTarget(bounds );
110+ img.ReplaceColorBinary(False, colors, tolerance );
118111 Result := Self.Engine.Locate(img, Font, Text);
119112 img.Free();
120113end;
121114
122- function TRSOCR.LocateInvert(Bounds : TBox; Text: String; Colors : TColorArray; Tolerance : Single; Font : TPixelFont): Single;
115+ function TRSOCR.LocateInvert(bounds : TBox; Text: String; colors : TColorArray; tolerance : Single; font : TPixelFont): Single;
123116var
124117 img: TImage;
125118begin
126- img := TImage.CreateFromTarget(Bounds );
127- img.ReplaceColorBinary(True, Colors, Tolerance );
119+ img := TImage.CreateFromTarget(bounds );
120+ img.ReplaceColorBinary(True, colors, tolerance );
128121 img.Show();
129122 Result := Self.Engine.Locate(img, Font, Text);
130123 img.Free();
@@ -133,14 +126,14 @@ end;
133126(*
134127function CountItemStack(Area: TBox): Int64;
135128const
136- Colors = [RSColors .ITEM_TEXT_YELLOW, RSColors .ITEM_TEXT_WHITE, RSColors .ITEM_TEXT_GREEN];
129+ colors = [RScolors .ITEM_TEXT_YELLOW, RScolors .ITEM_TEXT_WHITE, RScolors .ITEM_TEXT_GREEN];
137130 Multipliers = [1, 1000, 1000000];
138131var
139132 I: Integer;
140133begin
141- //for I := 0 to High(Colors ) do
134+ //for I := 0 to High(colors ) do
142135 //begin
143- // Result := OCR.RecognizeNumber(Area, TOCRColorFilter.Create([Colors [I]]), FONT_PLAIN_11) * Multipliers[I];
136+ // Result := OCR.RecognizeNumber(Area, TOCRColorFilter.Create([colors [I]]), FONT_PLAIN_11) * Multipliers[I];
144137 // if (Result > 0) then
145138 // Exit;
146139 //end;
0 commit comments