SRL Archive - OSR Help

How to use simba's ocr?


Sabzi

2011-02-12 07:00:06

Hi!

I have searched for it but I couldn't find a decent answer and I cbf to look trough every script hoping someone already done this :p.

So I have made the fonts already, named correctly, black/white.
I have written a tester script which is basically a GetTextAtEx using the font folder I made, but it never gives me anything. I tried changing spacings, tolerances, coords, colors, so I have came here to get answer.
If I have the correct bmps in the fonts folder(inside another folder just like other fonts) how do I use them?


tl;dr: A simple example of using self-made fonts in simba is enough. (without srl please)

Thanks!
Sabzi

p.s.: I have made this tiny script to make font making easier, thought I share it, nothing crazy tho:

program FontMaker;

const
PIC_NAME = '';
COLOR = 10926007;
TOL = 28;

procedure BlackWhite;
var
bmp, W, H, i, j: Integer;
Mbmp: TMufasaBitmap;

begin
bmp := LoadBitmap(ScriptPath + PIC_NAME + '.bmp');
Mbmp := GetMufasaBitmap(bmp);
W := Mbmp.Width; H := Mbmp.Height;
for i := 0 to W-1 do
for j := 0 to H-1 do
if not SimilarColors(Mbmp.FastGetPixel(i, j), COLOR, TOL) then
Mbmp.FastSetPixel(i, j, clBlack)
else
Mbmp.FastSetPixel(i, j, clWhite);
Mbmp.SaveToFile(ScriptPath + PIC_NAME + '_BW.bmp');
Mbmp.Free;
//FreeBitmap(bmp); Gives exception,
//if I free MufasaBmp this one is freed too, right?
end;


begin
SetColorToleranceSpeed(2);
BlackWhite;
end.

Wizzup?

2011-02-12 07:50:48

Don't free the TMufasaBitmap you get from 'GetMufasaBitmap'; since you're getting the actual reference to it, this will cause Simba to try to free it again, since it still exists in the managed array. Just use FreeBitmap. I think SRL has several fonts you can use as examples?

Sabzi

2011-02-12 08:27:14

From: Wizzup?
Don't free the TMufasaBitmap you get from 'GetMufasaBitmap'; since you're getting the actual reference to it, this will cause Simba to try to free it again, since it still exists in the managed array. Just use FreeBitmap. I think SRL has several fonts you can use as examples?


Thanks for the first one.
I have looked through some of srl's text finding functions.
All of them use only one of the GetTextAt function(afa I can see)
Would it help if I upload the fonts(only the numbers) and a bitmap that I am using for testing?
After lunch I will try again :p, hunger doesn't helps.

p.s.: I really like simba docs :).

EDIT: Now I am getting somewhere. I think the fonts and the color of the fonts differs too much. For example there is 3 completely different '6'.

Different "spaces" in the GetTextAt parameters still confuses me, but when I get the good ones the very last number doesn't shows up. So I should get 516, and I get 51.(coords are okay)

Wizzup?

2011-02-17 07:02:14

How's it going?

Sabzi

2011-02-17 12:53:38

From: Wizzup?
How's it going?


Actually I got kinda busy with university and forgot about this, but I still can't get the last number. i.e.: 613 -> I get 61 while the debugging of the TPA shows that I use the correct coordinates.

I have read the manual about the ocr, but I still don't really get what the different spaces means(hl, min, max(well, I get min, max)).

And the colors of the numbers differs too much. :(

I'm thinking about getting the colors/tolerance runtime, because coordinates are given(more or less but let that be my problem).

Any tip how to get correct tolerance for the ocr functions?
How does those use tol, the same way as colorfinders? <- that's what I'm interested.

And thanks still being interested about this.

Wizzup?

2011-02-27 07:27:07

Yeah, the tolerance is the same as the colour finders.