mirror of
https://github.com/moparisthebest/Simba
synced 2024-11-29 04:22:16 -05:00
Fixed some bugs in the OCR and TPA.
git-svn-id: http://www.villavu.com/repositories/merlijn/mufasa@528 3f818213-9676-44b0-a9b4-5e4c4e03d09d
This commit is contained in:
parent
82e54e5b07
commit
108bf37d6f
@ -130,6 +130,8 @@ begin
|
|||||||
Result.Data.Height := Self.Data.Height;
|
Result.Data.Height := Self.Data.Height;
|
||||||
Result.Data.inputs := Self.Data.inputs;
|
Result.Data.inputs := Self.Data.inputs;
|
||||||
Result.Data.outputs := Self.Data.outputs;
|
Result.Data.outputs := Self.Data.outputs;
|
||||||
|
Result.Data.max_height:= Self.Data.max_height;
|
||||||
|
Result.Data.max_width:= Self.Data.max_width;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TMFonts.GetFontByIndex(Index : integer): TMfont;
|
function TMFonts.GetFontByIndex(Index : integer): TMfont;
|
||||||
|
@ -729,50 +729,54 @@ var
|
|||||||
|
|
||||||
begin
|
begin
|
||||||
fD := Fonts.GetFont(font);
|
fD := Fonts.GetFont(font);
|
||||||
{ writeln(format('W, H: %d, %d', [fD.max_width, fd.max_height])); }
|
{writeln(format('W, H: %d, %d', [fD.max_width, fd.max_height]));}
|
||||||
|
|
||||||
TClient(Client).IOManager.GetDimensions(w, h);
|
TClient(Client).IOManager.GetDimensions(w, h);
|
||||||
{ writeln('Dimensions: (' + inttostr(w) + ', ' + inttostr(h) + ')'); }
|
{ writeln('Dimensions: (' + inttostr(w) + ', ' + inttostr(h) + ')'); }
|
||||||
|
|
||||||
{ Get the text points }
|
{ Get the text points }
|
||||||
SetLength(TPA, 0);
|
SetLength(TPA, 0);
|
||||||
|
if (atY + fD.max_height -1) >= h then
|
||||||
|
raise exception.createFMT('You are trying to get text that is out of is origin y-coordinate: %d',[aty]);
|
||||||
|
|
||||||
TClient(Client).MFinder.FindColorsTolerance(TPA, color, atX, atY,
|
TClient(Client).MFinder.FindColorsTolerance(TPA, color, atX, atY,
|
||||||
min(fD.max_width * len, w - atX - 1),
|
min(atX + fD.max_width * len, w - 1),
|
||||||
fD.max_height - 1, tol);
|
atY + fD.max_height - 1, tol);
|
||||||
{ b := GetTPABounds(TPA);
|
{ b := GetTPABounds(TPA);
|
||||||
bmp := TMufasaBitmap.Create;
|
bmp := TMufasaBitmap.Create;
|
||||||
bmp.SetSize(b.x2+1,b.y2+1);
|
bmp.SetSize(b.x2+1,b.y2+1);
|
||||||
bmp.DrawTPA(TPA, clRed);
|
bmp.DrawTPA(TPA, clRed);
|
||||||
bmp.SaveToFile('/tmp/found.bmp'); }
|
bmp.SaveToFile('c:\found.bmp');}
|
||||||
|
|
||||||
{ Split the text points into something usable. }
|
{ Split the text points into something usable. }
|
||||||
{ +1 because splittpa will not split well if we use 0 space ;) }
|
{ +1 because splittpa will not split well if we use 0 space ;) }
|
||||||
STPA := SplitTPAEx(TPA, minvspacing+1, hspacing+1);
|
STPA := SplitTPAEx(TPA, minvspacing+1, hspacing+1);
|
||||||
|
|
||||||
{ bmp.DrawATPA(STPA);
|
{ bmp.DrawATPA(STPA);
|
||||||
bmp.SaveToFile('/tmp/found2.bmp');
|
bmp.SaveToFile('c:\found2.bmp');
|
||||||
bmp.Free; }
|
bmp.Free;
|
||||||
|
|
||||||
{ for i := 0 to high(STPA) do
|
for i := 0 to high(STPA) do
|
||||||
begin
|
begin
|
||||||
b := GetTPABounds(STPA[i]);
|
b := GetTPABounds(STPA[i]);
|
||||||
bmp := TMufasaBitmap.Create;
|
bmp := TMufasaBitmap.Create;
|
||||||
bmp.SetSize(b.x2+1,b.y2+1);
|
bmp.SetSize(b.x2+1,b.y2+1);
|
||||||
bmp.DrawTPA(STPA[i], clRed);
|
bmp.DrawTPA(STPA[i], clRed);
|
||||||
bmp.SaveToFile('/tmp/t_' + inttostr(i) + '.bmp');
|
bmp.SaveToFile('c:\t_' + inttostr(i) + '.bmp');
|
||||||
bmp.Free;
|
bmp.Free;
|
||||||
end; }
|
end; }
|
||||||
|
|
||||||
SortATPAFrom(STPA, Point(0, 0));
|
SortATPAFrom(STPA, Point(0, atY));
|
||||||
SortATPAFromFirstPoint(STPA, Point(0, 0));
|
SortATPAFromFirstPoint(STPA, Point(0, atY));
|
||||||
|
|
||||||
{ for i := 0 to high(STPA) do
|
{ for i := 0 to high(STPA) do
|
||||||
begin
|
begin
|
||||||
b := GetTPABounds(STPA[i]);
|
b := GetTPABounds(STPA[i]);
|
||||||
bmp := TMufasaBitmap.Create;
|
bmp := TMufasaBitmap.Create;
|
||||||
bmp.SetSize(b.x2+1,b.y2+1);
|
bmp.SetSize(b.x2-b.x1 + 2,b.y2-b.y1 + 2);
|
||||||
bmp.DrawTPA(STPA[i], clRed);
|
for j := 0 to high(STPA[i]) do
|
||||||
bmp.SaveToFile('/tmp/s_' + inttostr(i) + '.bmp');
|
bmp.FastSetPixel(stpa[i][j].x-b.x1,stpa[i][j].y-b.y1,clred);
|
||||||
|
bmp.SaveToFile('c:\s_' + inttostr(i) + '.bmp');
|
||||||
bmp.Free;
|
bmp.Free;
|
||||||
end; }
|
end; }
|
||||||
|
|
||||||
|
@ -1118,6 +1118,7 @@ function FindTextTPAinTPA(Height : integer; SearchTPA, TotalTPA: TPointArray; va
|
|||||||
var
|
var
|
||||||
Len, I,II,LenSearch,LenTPA,xOff,yOff,x,y: integer;
|
Len, I,II,LenSearch,LenTPA,xOff,yOff,x,y: integer;
|
||||||
tx,ty,MatchCount : integer;
|
tx,ty,MatchCount : integer;
|
||||||
|
Found : boolean;
|
||||||
Screen : Array of Array of Boolean;
|
Screen : Array of Array of Boolean;
|
||||||
ScreenBox,SearchBox : TBox;
|
ScreenBox,SearchBox : TBox;
|
||||||
InversedTPA : TPointArray;
|
InversedTPA : TPointArray;
|
||||||
@ -1176,15 +1177,23 @@ begin;
|
|||||||
if ty > 0 then
|
if ty > 0 then
|
||||||
if ((SearchBox.x2 + tx) <= ScreenBox.x2) and ((SearchBox.y2 + ty) <= ScreenBox.y2) then
|
if ((SearchBox.x2 + tx) <= ScreenBox.x2) and ((SearchBox.y2 + ty) <= ScreenBox.y2) then
|
||||||
begin;
|
begin;
|
||||||
|
Found := false;
|
||||||
For II := 0 to LenSearch do
|
For II := 0 to LenSearch do
|
||||||
if Screen[tx + SearchTPA[II].x ][ty + SearchTPA[II].y] = False then
|
if Screen[tx + SearchTPA[II].x ][ty + SearchTPA[II].y] = False then
|
||||||
|
begin
|
||||||
|
Found := true;
|
||||||
Break;
|
Break;
|
||||||
if (II > LenSearch) then
|
end;
|
||||||
|
if (not Found) then
|
||||||
begin;
|
begin;
|
||||||
|
Found := false;
|
||||||
For II := 0 to LenTPA do
|
For II := 0 to LenTPA do
|
||||||
if Screen[tx + InversedTPA[II].x ][ty + InversedTPA[II].y] = True then
|
if Screen[tx + InversedTPA[II].x ][ty + InversedTPA[II].y] = True then
|
||||||
|
begin
|
||||||
|
Found := true;
|
||||||
Break;
|
Break;
|
||||||
if (II > LenTPA) then
|
end;
|
||||||
|
if (not Found) then
|
||||||
begin;
|
begin;
|
||||||
MatchCount := MatchCount + 1;
|
MatchCount := MatchCount + 1;
|
||||||
SetLength(Matches,MatchCount);
|
SetLength(Matches,MatchCount);
|
||||||
|
Loading…
Reference in New Issue
Block a user