SRL Archive - Jr. Member General Help and Discussion

OCR Example/Help


elephant

2015-05-20 21:55:56

Can anyone give me an example of a simple OCR search using a font installed on the system such as Arial?

Brandon

2015-05-21 21:53:44

Untested..


var
F: TFont;
T: String;
begin
F.Init();
F.SetName('Arial');
F.SetSize(12); //may or may not be needed..
LoadSystemFont(F, 'Temporary');

T := GetTextAtEx(0, 0, width, height, 0, 10, 4, colour, 5, 'Temporary'); //T now contains the text found..

F.Free();
end;

where 0, 0, width, height is the area to search.. 0, 10 is min vertical spacing and max vertical spacing respectively.. 4 is min horizontal spacing (play around with this value).. colour can be 0 (black - 0x000000) to 16777215 (white - 0xFFFFFF)..

Maybe you can use TPAFromText and then findTextTPAInTPA..

elephant

2015-05-25 19:03:08

From: Brandon
Untested.
From: Brandon
Untested..


var
F: TFont;
T: String;
begin
F.Init();
F.SetName('Arial');
F.SetSize(12); //may or may not be needed..
LoadSystemFont(F, 'Temporary');

T := GetTextAtEx(0, 0, width, height, 0, 10, 4, colour, 5, 'Temporary'); //T now contains the text found..

F.Free();
end;

where 0, 0, width, height is the area to search.. 0, 10 is min vertical spacing and max vertical spacing respectively.. 4 is min horizontal spacing (play around with this value).. colour can be 0 (black - 0x000000) to 16777215 (white - 0xFFFFFF)..

Maybe you can use TPAFromText and then findTextTPAInTPA..


Hi thanks for the response, I just had some free time and decided to see if I could get this working however I wasn't able to get it to read the text properly. In microsoft word I made a arial, 12 font sized text and got the colors of it. However, I was unable to get it to debug out anything beside something random like ".I,C.. ( ~.". I used this

program ocrtesting;

var
F: TFont;
T: String;
begin
F.Init();
F.SetName('Arial');
F.SetSize(12); //may or may not be needed..
LoadSystemFont(F, 'Temporary');

T := GetTextAtEx(278, 272, 395, 312, 0, 10, 4, 7237230, 44, 'Temporary'); //T now contains the text found..

writeln(T);
F.Free();
end;

[ATTACH=CONFIG]26028[/ATTACH]

It dosn't seem to properly detect the text, I make sure the width/height will surround the text and it seems to find it however, it dosn't seem to read it correctly. Is there anything I might be doing wrong you can see from that?

Olly

2015-05-25 19:10:46

You're not going to have much luck using Simba's OCR, It's very much designed for non-antialiased text (just one solid color). Take your image and zoom in to see what I mean.

elephant

2015-05-25 19:47:30

From: Olly
You're not going to have much luck using Simba's OCR, It's very much designed for non-antialiased text (just one solid color). Take your image and zoom in to see what I mean.


I see what you mean, would there be any way to get around this such as a custom font or some sort of thing? Also, I haven't looked into it yet but could I just disable anti aliasing in a game that uses directx? - Did a quick bit of searching, seems you can disable antialiasing under performance options on windows 7. I'll test it out on a a game later, however seems to work perfectly now with mircosoft word. Thanks for bringing that up wasn't aware that was the reason, probably wouldn't of thought out that :).