Sign in to follow this  
Followers 0
pingpong24

NumCR Super Fast EASY NUMBER OCR

43 posts in this topic

#1 ·  Posted (edited)

This is a very fast NUMBER OCR UDF, in order to use it include NumCR and use this function: _OCR

Provide the top left x, top left y, and bottom right x and bottom right y.

#include <NumCR.au3>

$test = _OCR("73", "511", "112", "520")
$test2 = _OCR("72", "462", "110", "471")
MsgBox(0,"something",$test,1)
MsgBox(0,"somethingelse",$test2,1)

In order to create your own definition for your own font, take a screen shoot using print screen, then go to ms paint, zoom to 800x and work out all the if statements...

If you look at the code it will become very apparent on how to use it.

if you have any questions please dont be afraid just ask, unlike other OCR script developer on this forum if you want you can send me your number fonts.. and ill do the definitions for you :lmao:

This is my first ever OCR script and it has done the job that i wanted it to do, i read other developers OCR such as pathbees and insolences.. Those are very complicated and hard to understand also are very slow.

Pathbees OCR moves the mouse around and takes more then 3seconds to work out 4 characters... and he only has 4 characters in his definition. ;)

Anyways enjoy.

NumCR.au3

untitled.bmp

creating_dif.bmp

Edited by pingpong24

Share this post


Link to post
Share on other sites



good job =)

it's alot better then the old, i had ^.^'


[font="Verdana"]In work:[list=1][*]InstallIt[*]New version of SpaceWar[/list] [/font]

Share this post


Link to post
Share on other sites

http://www.autoitscript.com/forum/index.ph...wtopic=1538&hl=

larry does the same thing as me, couldnt find the dll call by larry.. if you can find it for me i may be able to speed up my script further.. though it isnt nassary for me my self, as the offical prgram that i am geting the data of sends data to its API users every 5 seconds.. and my script scans area in less then 1~ sec to 1.5

Share this post


Link to post
Share on other sites

That can be in my TODO list as I dont actually understand what his code does, I am assuming it instantly puts the entire screen into an array with all the colors etc. still since I didnt understand the code I cant embed it into my codes.

I am working as we speak on a character definition creator; this will be a GUI based application where you click on the top left of the individual character and then click on the bottom right of that character and click on define character and it will convert that character to if x = 0 and x+1 = 0 etc so that it can be copied and pasted into the OCR UDF file.

I guess once I release that my OCR will be the best OCR script released on the forum :lmao:o:);)

Share this post


Link to post
Share on other sites

; Created by Royal Miah
; ntl_cable_guy@hotmail.com
;enjoy and your welcome

#include <GUIConstants.au3>
#include <Misc.au3>
;Generated with Form Designer preview
$Form1 = GUICreate("NumCR - Definition Creator  V0.01 Royal Miah", 598, 311, 199, 136)
$codebox = GUICtrlCreateInput("", 40, 64, 529, 125, -1, $WS_EX_CLIENTEDGE)
$color = GUICtrlCreateInput("", 440, 32, 129, 21, -1, $WS_EX_CLIENTEDGE)
$Start = GUICtrlCreateButton("START", 116, 248, 81, 33)
$makecode = GUICtrlCreateButton("GENERATE", 252, 248, 81, 33)
$Copyclip = GUICtrlCreateButton("COPY ME", 388, 248, 81, 33)
$locationbox = GUICtrlCreateInput("", 40, 200, 177, 29, -1, $WS_EX_CLIENTEDGE)
GUICtrlCreateLabel("Converts Selected Area in to source code", 32, 32, 201, 17)
GUICtrlCreateLabel("Enter Color to search for", 319, 35, 118, 17)
GUICtrlCreateLabel("Displays X left, Y left, X bottom, Y bottom", 224, 209, 196, 17)
GUISetState(@SW_SHOW)
While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    
    case $msg = $Start
    while 1
    if _IsPressed("41") and _IsPressed("1") Then
        $pos = MouseGetPos()
        $lAx = $pos[0] 
        $lAy = $pos[1]
    EndIf
    If _IsPressed("5A") and _IsPressed("1") Then
        $pos = MouseGetPos()
        $lDx = $pos[0] 
        $lDy = $pos[1]
        $locationinput = $lAx&","&$lAy&","&$lDx&","&$lDy
        GUICtrlSetData($locationbox,$locationinput)
        ExitLoop
    EndIf
    WEnd

    Case $msg = $Copyclip
        ClipPut(GUICtrlRead($codebox))
        
    Case $msg = $makecode

    $test = _OCR($lAx,$lAy,$lDx,$lDy)
    GUICtrlSetData($codebox,$test)
    Case Else
    ;;;;;;;
    EndSelect
WEnd
Exit

Func _OCR($Ax, $Ay, $Dx, $Dy)
    
    $width = $Dx - $Ax
    $length = $Dy - $Ay
    
    Local $char[$width][$length]
    
    For $xwidth = 0 To $width - 1
        For $xlength = 0 To $length - 1
            $char[$xwidth][$xlength] = Hex(PixelGetColor($Ax, $Ay), 6)
            $Ay = $Ay + 1
        Next
        $Ax = $Ax + 1
        $Ay = $Ay - $length
    Next
;scans entire area 
    

    $p = 1
    Local $row[$width]
    For $xwidth = 0 To $width - 1
        
        For $xlength = 0 To $length - 1
            If $char[$xwidth][$xlength] = "000000" Then
                If $p = 1 Then
                    $div = $xwidth
                    $p += 2
                EndIf
                $x = $xwidth - $div
                $row[$x] +=1
                
            EndIf
            
        Next
    Next
;seriales the array
    
    $ja = "0"
    $pm = ""
    For $xwidth = 0 To $width -1
        If $row[$ja] = "" Then
            ExitLoop
        EndIf
    $pm &= "$row[$xwidth+"&$xwidth&"] ="& $row[$ja]&" And "
    $ja = $ja+1 
    Next
    $result = "If "&StringTrimRight($pm, 4)
    Return $result

    EndFunc

First version of chareacter difination maker, enjoy :lmao:

Share this post


Link to post
Share on other sites

Hello pingpong24, I'm trying to get your OCR working, but to no avail. I keep getting an error...

C:\Documents and Settings\CIS\My Documents\NumCR.au3 (30) : ==> Expected a "=" operator in assignment statement.: 
$p += 2 
$p ^ ERROR

Why is this? Also, I have a font that needs a definition... You mention in your first post that you'll do one?

If you think you can make a definition for me, reply back and I'll post an image with some numbers and letters. Help Appreciated!

Share this post


Link to post
Share on other sites

Posted Image

I think that's all that is needed..

Share this post


Link to post
Share on other sites

Posted Image

I think that's all that is needed..

Your 'example pic' will need to be in .bmp (Just FYI).

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

Hello pingpong24, I'm trying to get your OCR working, but to no avail. I keep getting an error...

C:\Documents and Settings\CIS\My Documents\NumCR.au3 (30) : ==> Expected a "=" operator in assignment statement.: 
$p += 2 
$p ^ ERROR

Why is this? Also, I have a font that needs a definition... You mention in your first post that you'll do one?

If you think you can make a definition for me, reply back and I'll post an image with some numbers and letters. Help Appreciated!

You'll need beta for +=


SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

You'll need beta for +=

Ah! thanks, works on the sample image now. :)

EDIT: Also, how does the definition creator work? I gave it a quick glance and it didn't help any...

Edited by Aztec

Share this post


Link to post
Share on other sites

Can you help? I can't put your OCR to work :D

Can you make the definition for me?

Posted Image

Thank you

Share this post


Link to post
Share on other sites

Not needed anymore, i got it. But, 6 and 9 have the same numbers of pixel in each row. What can i do?

Share this post


Link to post
Share on other sites

I see your counting pixels but are we cheking for black pixels? If so do I change this:

If $char[$xwidth][$xlength] = "000000" Then

to this for characters on a black background

If $char[$xwidth][$xlength] <> "000000" Then

Buck

Share this post


Link to post
Share on other sites

I am back going to be working on this project part time, cant wait for uni to start then i can work on programming like before.

and yeah its only searching for black pixels you need to change that.

Please dont email me asking for help or PMing me, ask someone else on the forum, I am only going to be improving the script and cant help anyone else with their OCR needs.

Going to add an YOUTUBE video to show how to run the exxample and how the code actually works, this should be done in few weeks time LOL to lazy to do it right now and going to make a better implementation of OCR diffination creator.

Share this post


Link to post
Share on other sites

I am back going to be working on this project part time, cant wait for uni to start then i can work on programming like before.

and yeah its only searching for black pixels you need to change that.

Please dont email me asking for help or PMing me, ask someone else on the forum, I am only going to be improving the script and cant help anyone else with their OCR needs.

Going to add an YOUTUBE video to show how to run the exxample and how the code actually works, this should be done in few weeks time LOL to lazy to do it right now and going to make a better implementation of OCR diffination creator.

I'll make you the video if you tell me how it works. Doesn't seem to do anything (for me) so far.


Agreement is not necessary - thinking for one's self is!

My-Colors.jpg

cuniform2.gif

Share this post


Link to post
Share on other sites

I know how to use he's code.

Here is how it works, the place where it have all the If $row[$xwidth] = 4 etc

It actually counts pixels vertically Example the letter "L" might have 9 pixels for the first column, where it has $row[$xwidth+1] = 1 is the next column.

So lettle "L" will have $row[$xwidth]= 9 And $row[$xwidth+1] = 1 And $row[$xwidth+2] = 1 And $row[$xwidth+3] = 1

the problem with this is with letters that have the same amount of pixels counts such as letter "b", "p", "d", "q", "i", "1", "l", "j", "n", "r", "m", "v", "w"

all the above letters have problems recognising a unique pixel count.

I would recomment if you could change the code to read pixel counts in the horizontal position not vetically.

Share this post


Link to post
Share on other sites

I know how to use he's code.

Here is how it works, the place where it have all the If $row[$xwidth] = 4 etc

It actually counts pixels vertically Example the letter "L" might have 9 pixels for the first column, where it has $row[$xwidth+1] = 1 is the next column.

So lettle "L" will have $row[$xwidth]= 9 And $row[$xwidth+1] = 1 And $row[$xwidth+2] = 1 And $row[$xwidth+3] = 1

the problem with this is with letters that have the same amount of pixels counts such as letter "b", "p", "d", "q", "i", "1", "l", "j", "n", "r", "m", "v", "w"

all the above letters have problems recognising a unique pixel count.

I would recomment if you could change the code to read pixel counts in the horizontal position not vetically.

No matter how you do it, you will have some letters / numbers that have the same value... You have to look a bit deeper at BitShift(ing) those values to obtain uniqueness. I've written many OCR's, and just finished a Dll for one for personal use... I ran into this issue often regardless of how I searched.

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0