Wizzup?
2011-11-29 15:05:40
Anyway.
- FindText no longer works and neither will FindTextTPA. Therefore I'm using Simba's awesome GetTextATPA.
- Characters now have (or had, I don't recall) shadow.
- Font is still SmallChars.
- Background may be transparent.
(Confirm?)Confirmed. - Characters have some random spacing. (Confirm?)
Now, Java is really giving me a bad time, so I'd appreciate some (32 bit) screenshots of various choose option menus. To (specifically) get: The colours used for text, (gray, brown, etc) and test my shadow functions if required. Colours are required to make a non shadow version.
Here's what I made in 30 mins:
program new;
var
bmp, bmp2: integer;
w, h: integer;
cts: integer;
i: integer;
s: String;
P: TPointArray;
ATPA: Array of TPointArray;
ATPATemp: Array of TPointArray;
begin
LoadFont('SmallCharsNS', True);
LoadFont('SmallCharsNS', False); // we don't really need this.
bmp := LoadBitmap('chooseopt.bmp');
SetTargetBitmap(bmp);
GetClientDimensions(w, h);
Writeln('Size: ' + inttostr(w) + ', ' + inttostr(h));
cts := GetToleranceSpeed;
SetColorToleranceSpeed(1);
FindColorsTolerance(P, 591618, 0, 0, w-1, h-1, 5); // Find shadows
// Replace this with multiple FindColorsTolerance + CombineTPA for non-shadow OCR.
SetColorToleranceSpeed(cts);
ATPA := SplitTPAEx(P, 15, 2); // Split per line.
SortATPAFromFirstPoint(ATPA, Point(0,0)); // Sort, SplitTPAEx messes stuff up
bmp2 := CopyBitmap(bmp);
writeln(length(atpa));
DrawATPABitmap(bmp2, ATPA);
DisplayDebugImgWindow(w, h);
DrawBitmapDebugImg(bmp2);
DisplayDebugImgWindow(w, h);
SaveBitmap(bmp2, 'test.bmp');
for i := 0 to high(ATPA) do
begin
P := ATPA[i];
ATPATemp := SplitTPAEx(P, 2, 10); // Split one into characters
SortTPAFrom(P, Point(0, 0)); // Sort SplitTPA messes stuff up
SortATPAFromFirstPoint(ATPATemp, P[0]); // More Sort
DrawATPABitmap(bmp2, ATPATemp);
s := GetTextATPA(ATPATemp, 5, 'SmallCharsNS_s'); // Replace this with 'SmallChars' for non shadow OCR
writeln(s);
setlength(atpatemp,0);
setlength(p,0);
end;
SaveBitmap(bmp2, 'test_split.bmp');
SetDesktopAsClient;
FreeBitmap(bmp);
end.
You need SmallCharsNS in your Fonts: http://wizzup.org/SmallCharsNS.zip (I just added shadows, in the future the shadows will not be required in the bitmaps themselves. (BTW don't use this SmallCharsNS font in combination with BitmapFromText, it will fail)
So, what do we need to finish this?
Basically:
- Retrieve the ChooseOption area
- Call the above code on it and make it return a string array + position of characters.
- Call pos() on the string array, return the position of the first hit.
That's it. The above code can be adjusted to include all the colours and now compare to the SmallChars_NS_s but to SmallChars (no _s), you'll have to FindColorsTolerance() each colour, and combine it into one TPA. Then just call all the same splitstuff etc on it. (IOW Replace the one FindColorsTolerance with several FindColorsTolerance combined with CombineTPA)
I'd be grateful if someone else could work on this (as well), I'm done for today. I don't know SRL by heart at the moment and I need to focus my time on something else ATM.






