Jump to content
Sign in to follow this  
Insolence

Diablo II OCR with spacing now...

Recommended Posts

I'd like to make the point that this is not an OCR program by any means. OCR stands for Optical Character Recognition. The program isn't "seeing" the letters, it's simply comparing the pixels read in, to those in a defined file. Should a single pixel in a letter change, the program is unable to recognize it

- Added

As to your i & j issue, a method is to check the characters on either side. I'm pretty sure you don't find consonants next to j's. If there's a consonant you should be safe assuming it's an i. In cases where there are vowels on either side, you'll be left in the dark, but at least it solves it some of the time.

Look into editing your MPQ files, maybe it's possible to change the j

Edited by asik

Share this post


Link to post
Share on other sites

Asik, don't be so critical. Of course it's a very good OCR, but it does recognize characters optically, doesn't it? I think it qualifies as an OCR, just not a good one... :lmao:

Excellent idea for the J, I'll edit the font file and fixup a couple annoying problems that I found.


"I thoroughly disapprove of duels. If a man should challenge me, I would take him kindly and forgivingly by the hand and lead him to a quiet place and kill him." - Mark TwainPatient: "It hurts when I do $var_"Doctor: "Don't do $var_" - Lar.

Share this post


Link to post
Share on other sites

Yep.

I'm the founder of D2BS.


"I thoroughly disapprove of duels. If a man should challenge me, I would take him kindly and forgivingly by the hand and lead him to a quiet place and kill him." - Mark TwainPatient: "It hurts when I do $var_"Doctor: "Don't do $var_" - Lar.

Share this post


Link to post
Share on other sites

...

It reads text.  If it's the same font, it can read it... no need to elaborate more then I have.

Yes, with what I have completed now I can read text in game, like in the pictures in this thread.

<{POST_SNAPBACK}>

few questions.... for the character definitions, did you have to do all of that manually? or did you make another script/program to import a font file? was asking because i was thinking of trying to implement this to grab a client number from a telnet display, but the fonts are definitely not the same... if you have a script that turns a font file into the character defs, could i get a copy of it? doing this for/at work, so can't go in and map all of my fonts...

Share this post


Link to post
Share on other sites

...

It reads text.  If it's the same font, it can read it... no need to elaborate more then I have.

Yes, with what I have completed now I can read text in game, like in the pictures in this thread.

<{POST_SNAPBACK}>

Hi Insolence,

I've tried your script and it worked. Now, the third party app that I'm using uses Aria front which I think is size 14 or 15. How do I make my own character definition? Do I really need to?

Thanks again! It's wonderful! Great job!

Neil

Share this post


Link to post
Share on other sites

few questions.... for the character definitions, did you have to do all of that manually? or did you make another script/program to import a font file?  was asking because i was thinking of trying to implement this to grab a client number from a telnet display, but the fonts are definitely not the same...  if you have a script that turns a font file into the character defs, could i get a copy of it?  doing this for/at work, so can't go in and map all of my fonts...

<{POST_SNAPBACK}>

I doubt it will work for that, there are many specifications it has for the Diablo II font, so my answer is no. I also do not have a script to make definitions :)

Hi Insolence,

I've tried your script and it worked. Now, the third party app that I'm using uses Aria front which I think is size 14 or 15. How do I make my own character definition? Do I really need to?

Thanks again! It's wonderful! Great job!

Neil

Glad you enjoy it :evil:

You can use the same algorithm (if you can call it that) that I'm using, but you'll have to apply it specifically to your font. There has to be a clear line between EACH character so the parser can seperate them, that is a huge weakness. Of course you could check and make sure the pixels are actually connected, but that'd take too much time.


"I thoroughly disapprove of duels. If a man should challenge me, I would take him kindly and forgivingly by the hand and lead him to a quiet place and kill him." - Mark TwainPatient: "It hurts when I do $var_"Doctor: "Don't do $var_" - Lar.

Share this post


Link to post
Share on other sites

I doubt it will work for that, there are many specifications it has for the Diablo II font, so my answer is no.  I also do not have a script to make definitions :)

Glad you enjoy it :evil:

You can use the same algorithm (if you can call it that) that I'm using, but you'll have to apply it specifically to your font.  There has to be a clear line between EACH character so the parser can seperate them, that is a huge weakness.  Of course you could check and make sure the pixels are actually connected, but that'd take too much time.

<{POST_SNAPBACK}>

Yep, the text that I want to OCR on the dialogue box is really neat and clean. However, like what I have mentioned earlier, how will I make my own character definition file if the font is Arial with size of 14? Can you teach me how I will create this file?

In your character definition file, you have like this entry:

$arCharactersTemp[1][0]="A"

$arCharactersTemp[1][1]="0,-1;-1,0;-1,-1;-7,0;-7,-1;"

$arCharactersTemp[2][0]="B"

$arCharactersTemp[2][1]="0,-1;0,-2;0,-3;0,-4;0,-5;0,-6;0,-7;0,-8;-1,0;-1,-1;-1,-2;-1,-3;-1,-4;-1,-5;-1,-6;-1,-7;-1,-8;-2,0;-2,-3;-2,-7;-3,0;-3,-2;-3,-3;-3,-7;-4,0;-4,-1;-4,-2;-4,-3;-4,-4;-4,-5;-4,-6;-4,-7;"

If it's Arial, how do I modify the values?

Thanks,

Neil

Share this post


Link to post
Share on other sites

Yep, the text that I want to OCR on the dialogue box  is really neat and clean. However, like what I have mentioned earlier, how will I make my own character definition file if the font is Arial with size of 14? Can you teach me how I will create this file?

In your character definition file, you have like this entry:

$arCharactersTemp[1][0]="A"

$arCharactersTemp[1][1]="0,-1;-1,0;-1,-1;-7,0;-7,-1;"

$arCharactersTemp[2][0]="B"

$arCharactersTemp[2][1]="0,-1;0,-2;0,-3;0,-4;0,-5;0,-6;0,-7;0,-8;-1,0;-1,-1;-1,-2;-1,-3;-1,-4;-1,-5;-1,-6;-1,-7;-1,-8;-2,0;-2,-3;-2,-7;-3,0;-3,-2;-3,-3;-3,-7;-4,0;-4,-1;-4,-2;-4,-3;-4,-4;-4,-5;-4,-6;-4,-7;"

If it's Arial, how do I modify the values?

Thanks,

Neil

<{POST_SNAPBACK}>

Well you have to understand what they are, the 'graphing' points of the character.

Try and modify my script to show you exactly what it's looking at. Hint: use the AutoIt Window Info tool and the Magnify option. Open up paint and you can have it show you exactly what it's doing :)


"I thoroughly disapprove of duels. If a man should challenge me, I would take him kindly and forgivingly by the hand and lead him to a quiet place and kill him." - Mark TwainPatient: "It hurts when I do $var_"Doctor: "Don't do $var_" - Lar.

Share this post


Link to post
Share on other sites

Well you have to understand what they are, the 'graphing' points of the character.

Try and modify my script to show you exactly what it's looking at.  Hint: use the AutoIt Window Info tool and the Magnify option.  Open up paint and you can have it show you exactly what it's doing :)

<{POST_SNAPBACK}>

I did try to use the magnify option on AutoIT Window info and saw each pixels. However, I tried to hover the magnifying glass on the letter A of your example and I'm really still having a hard time figuring out how you came up with those values for letter A in your character definition.au3 file. I apologize. Please help me again. :evil:

Thanks,

Neil

Share this post


Link to post
Share on other sites

Make the bot slow down (sleep) and then move the mouse to each pixel:

MouseMove($x,$y)

Sleep(500)

That way you'll see exactly what it's doing, also, if this still doesn't help you go over the code. Tell me what you don't understand, it's very straight forward.


"I thoroughly disapprove of duels. If a man should challenge me, I would take him kindly and forgivingly by the hand and lead him to a quiet place and kill him." - Mark TwainPatient: "It hurts when I do $var_"Doctor: "Don't do $var_" - Lar.

Share this post


Link to post
Share on other sites

Make the bot slow down (sleep) and then move the mouse to each pixel:

MouseMove($x,$y)

Sleep(500)

That way you'll see exactly what it's doing, also, if this still doesn't help you go over the code.  Tell me what you don't understand, it's very straight forward.

<{POST_SNAPBACK}>

Hi, I'm just wondering why msgbox for the GetLines function doesn't get called. Any ideas?

Func GetLines($StartX, $StartY, $EndX, $EndY, $Color)

Local $arLineCheck = 0, $intElement = 1, $FirstFound = 0

Dim $arNewLine[255][4]

#CS

DEBUG

$arStartCoord[0] =

$arStartCoord = PixelSearch ($StartX, $StartY, $EndX, $EndY, $Color)

MsgBox("","", $arStartCoord[0] & ", " & $arStartCoord[1])

.............

I already changed it to MsgBox(0,"", $arStartCoord[0] & ", " & $arStartCoord[1]) but it didn't help.

And also, what does it mean by this line since there is no value on the right?

$arStartCoord[0] =

Thanks.

Share this post


Link to post
Share on other sites

Hi, I'm just wondering why msgbox for the GetLines function doesn't get called. Any ideas?

Func GetLines($StartX, $StartY, $EndX, $EndY, $Color)

  Local $arLineCheck = 0, $intElement = 1, $FirstFound = 0

  Dim $arNewLine[255][4]

 

  #CS

  DEBUG

  $arStartCoord[0] =

 

  $arStartCoord = PixelSearch ($StartX, $StartY, $EndX, $EndY, $Color)

  MsgBox("","", $arStartCoord[0] & ", " & $arStartCoord[1])

  .............

I already changed it to MsgBox(0,"", $arStartCoord[0] & ", " & $arStartCoord[1]) but it didn't help.

And also, what does it mean by this line since there is no value on the right?

  $arStartCoord[0] =

Thanks.

<{POST_SNAPBACK}>

I just found out that #cs and #ce are for comments, LOL :)

Share this post


Link to post
Share on other sites

I just found out that #cs and #ce are for comments, LOL :)

<{POST_SNAPBACK}>

Yup :evil:

"I thoroughly disapprove of duels. If a man should challenge me, I would take him kindly and forgivingly by the hand and lead him to a quiet place and kill him." - Mark TwainPatient: "It hurts when I do $var_"Doctor: "Don't do $var_" - Lar.

Share this post


Link to post
Share on other sites

Yup :)

<{POST_SNAPBACK}>

Ok, I enabled the mousemove in your script and saw that mouse goes from top to bottom and back to top again. However, the mouse didn're really hovered all on the autoit.bmp file. I think, it only hovered the first two vertical pixels. Then it quits. However, the output.txt contains the correct text.

Any ideas?

Neil

Share this post


Link to post
Share on other sites

That sounds kinda weird, but now that you've really digged into the script I don't mind explaining it:

Basically it first seperates the text into lines

Then into characters (at least 2 pixels between each character)

After that it finds the top-left most pixel, and graphs out the other pixels relative to its position

That's how I get the

0,1;0,2;0,3;

Which would just be

[]

[]

[]


"I thoroughly disapprove of duels. If a man should challenge me, I would take him kindly and forgivingly by the hand and lead him to a quiet place and kill him." - Mark TwainPatient: "It hurts when I do $var_"Doctor: "Don't do $var_" - Lar.

Share this post


Link to post
Share on other sites

That sounds kinda weird, but now that you've really digged into the script I don't mind explaining it:

Basically it first seperates the text into lines

Then into characters (at least 2 pixels between each character)

After that it finds the top-left most pixel, and graphs out the other pixels relative to its position

Which line of code does the separtion of text into lines?

Which part is for the characters?

Thanks for bearing with me :)

Neil

Share this post


Link to post
Share on other sites

No problem,

GetLines

GetCharacters


"I thoroughly disapprove of duels. If a man should challenge me, I would take him kindly and forgivingly by the hand and lead him to a quiet place and kill him." - Mark TwainPatient: "It hurts when I do $var_"Doctor: "Don't do $var_" - Lar.

Share this post


Link to post
Share on other sites

No problem,

GetLines

GetCharacters

<{POST_SNAPBACK}>

I think, the reason I'm so confused is that the mousemove doesn't go to where it should be. I'm talking about the mousemove in the Getlines function that you made. Anyways, I would like to know what the values such as -1, -7,etc really mean. Is it for color or for coordinate? I also see a pattern, I think they come in partners.

$arCharactersTemp[1][0]="A"

$arCharactersTemp[1][1]="0,-1;-1,0;-1,-1;-7,0;-7,-1;"

Please help again. :)

Share this post


Link to post
Share on other sites

I think, the reason I'm so confused is that the mousemove doesn't go to where it should be. I'm talking about the mousemove in the Getlines function that you made. Anyways, I would like to know what the values such as -1, -7,etc really mean. Is it for color or for coordinate? I also see a pattern, I think they come in partners.

$arCharactersTemp[1][0]="A"

$arCharactersTemp[1][1]="0,-1;-1,0;-1,-1;-7,0;-7,-1;"

Please help again. :)

<{POST_SNAPBACK}>

It's for coordinate of each pixel away from the top-leftmost pixel.

"I thoroughly disapprove of duels. If a man should challenge me, I would take him kindly and forgivingly by the hand and lead him to a quiet place and kill him." - Mark TwainPatient: "It hurts when I do $var_"Doctor: "Don't do $var_" - Lar.

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...