Jump to content

NumCR Super Fast EASY NUMBER OCR


pingpong24
 Share

Recommended Posts

need help , when I run the script with the example bmp it only return " . " or " .. " instead of numbers.

------------------------------------------

#include "NumCR.au3"

$test = _OCR(0, 0, 300, 300)

MsgBox(0, "Example", $test)

------------------------------------------

Is it working??

Link to comment
Share on other sites

  • 3 months later...
  • Replies 44
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Posted Images

  • 2 months later...

I little modified the script for NumCR.

In my version, I count the number of pixels in area to determine number (or another character). And to distinct the numbers with the same numbers of pixels (2 and 4, 6 and 9 in my case) I added some multiplicity factor to next row. It means that next row have bigger value than previous and using this method I was able to generate different patters to different number. Before usage you must modify the script to set the number of pixels for every digit you will use. Also different multiply strategies and values can be used to generate unique pattern.

Func _OCR($Ax, $Ay, $Dx, $Dy)
    
    $width = $Dx - $Ax
    $length = $Dy - $Ay
    
    Dim $char = 0;
    Dim $sign = 1 
        
    For $xwidth = 0 To $width - 1
        For $xlength = 0 To $length - 1
            If PixelGetColor($Ax+$xwidth, $Ay+$xlength) = 0 Then
            $char += $sign ; or 1*$sign, 2*$sign. For unique pattern
            EndIf
        Next
        If $char <> 0 Then
            $sign += 1 ; increase the row multiply factor to avoid the same # of black pixels in different numbers
        EndIF
    Next
    
    Select
        Case $char = 152
                $result = 0
        Case $char = 80
                $result = 1
        Case $char = 120
                $result = 2 
        Case $char = 138
                $result = 3
        Case $char = 126
                $result = 4 
        Case $char = 130
                $result = 5
        Case $char = 131
                $result = 6 
        Case $char = 102
                $result = 7
        Case $char = 156
                $result = 8
        Case $char = 149
                $result = 9
    EndSelect
    Return $result 
EndFunc
Link to comment
Share on other sites

  • 8 years later...

I know this is an extreme gravedig. But I am working on a project and trying to get some OCR for numbers only -- something like this that I can customize to my own liking/text. I tried using tesseract and it kept messing up changing digits to random characters.

 

From what it looks like in this script i am to specify the text color on line 24, which happens to be green (4dc92b) then count the green pixels of each column from top to bottom -- here is an image of what I envision I am supposed to do, please correct me if im wrong. The numbers in the picture represent each vertical pixel. meaning that my if statement to catch that number should look like the code below, right? 

 

If $row[$xwidth] = 5 And $row[$xwidth+1] = 3 And $row[$xwidth+2] = 3 And $row[$xwidth+3] = 3 And $row[$xwidth+4] = 5 Then
            $result &= "8"
        EndIf

 

I am willing to pay a few bucks to anyone that can get this text to recognize for me using this lightweight OCR.

example88.png

Link to comment
Share on other sites

  • Moderators

What is the app that you're pulling the numbers from (desktop app, web app, etc.)? Are you not able to get any info with the AutoIt Window Info Tool, that you have to resort to OCR?

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...