Jump to content
Sign in to follow this  
qwertylol

OCR

Recommended Posts

qwertylol

how do I load a picture into a variable and then use pixelgetcolor to search for it?

doesn't pixelgetcolor only work for pixel on the screen?

Share this post


Link to post
Share on other sites
qwertylol

work this one then.

I am reading your thread.

Share this post


Link to post
Share on other sites
qwertylol

can you tell me very simply how to do getpixelcolor with a screenshot shot by auto3lib that's stored in a variable?

Share this post


Link to post
Share on other sites
qwertylol

how do I search for a image stored in the variable ?

Share this post


Link to post
Share on other sites
qwertylol

Ok, I figure this is the best general tool ever for potential OCR scientists.

I want to code a tool that will produce pictures like below based on your definition.

So, please lend me a hand in creating this.

How can this be acomplished?

First, a window has to be created, and then the enlargement of the area slected will be displayed.

how do I do this ?

post-20975-1178076600_thumb.jpg

Share this post


Link to post
Share on other sites
qwertylol

how do i use au3 to creat image?

Share this post


Link to post
Share on other sites
qwertylol

is anyone interested in a jointed project for a gui for OCR ?

Share this post


Link to post
Share on other sites
qwertylol

Pixelgetcolor will get a point on the screen, yet, for OCR, to fit into any application, it must be able to load a picture into a variable, and then do the search there.

How can it be done, pixelcolor on a image saved in a variable?

Share this post


Link to post
Share on other sites
themax90

I do not know how to do this... thus I didn't post.

Search the forum for OCR. There have been a few made in the past for Diablo/Diablo II.

-AutoIt Smith

Share this post


Link to post
Share on other sites
qwertylol

#include<array.au3>


Global $color = 14018275
Dim $string
Dim $x = 0
Dim $y = 767
Dim $x_size = @DesktopWidth
Dim $y_size = @DesktopHeight
Dim $display_string = ""
Dim $array_order = 0
Dim $avRET

$avRET = search_for_this_color($x_size, $y_size, $color)

MsgBox (0, "the color is at", $avRET[0]  )
MsgBox (0, "the color is at", $avRET[1]  )

$string = ocr_string ( $avRET)



$matches = StringRegExp($string, '[^0]{1,}', 3)

_ArrayDisplay($matches, 'found')

Do
    
    ;check definition
    If  check_definition( $matches[$array_order] ) == 2 Then
        MsgBox ( 0, "Unknown string", $matches[$array_order] )
    EndIf
    
    $display_string = $display_string & check_definition( $matches[$array_order] )

    $array_order = $array_order + 1
    
Until $array_order = 2;size of the array.



MsgBox ( 0, "The string says", $display_string )



Func search_for_this_color($x_size , $y_size, $color)
    ; $avRET[0] = X, $avRET[1] = Y
    Local $avRET[2] = [0, $y_size]
    Do
        Do
            If PixelGetColor($avRET[0], $avRET[1]) = $color Then 
                Return $avRET
                EndIf
            $avRET[1] = $avRET[1] - 1
        Until $avRET[1] = 0
        $avRET[1] = $y_size
        $avRET[0] = $avRET[0] + 1
    Until $avRET[0] = $x_size 
    
    MsgBox (0, "title", "found nothing." )

    Return SetError(1, 0, -1)
EndFunc   ;==>search_for_this_color
    
    
    
    
    

Func    ocr_string ( $avRET)
    
    Local $x_offset = 0
    Local $y_offset = -4
    Local $box = 0
    
    Do
        Do
            If PixelGetColor ( ($avRET[0] + $x_offset) , ($avRET[1] + $y_offset  ) ) = $color   Then
                $box = $box + 1
                EndIf
                
                $y_offset = $y_offset + 1
        Until $y_offset = 7
            
        $y_offset = -4
        $string = $string &$box
        $x_offset = $x_offset + 1
        $box = 0
            
    Until $x_offset = 147                   ;this is how long this string can be, at most.

    MsgBox (0, "147", $string )
    Return $string
EndFunc
    
    
Func check_definition(  $string )
    If $string == ""    Then
        Return "-"
        EndIf
    If $string == ""    Then
        Return "0"
    EndIf
    If $string == ""    Then
        Return "1"
        EndIf
    If $string == ""    Then
        Return "2"
    EndIf
    If $string == ""    Then
        Return "3"
        EndIf
    If $string == ""    Then
        Return "4"
    EndIf
    If $string == ""    Then
        Return "5"
        EndIf
    If $string == ""    Then
        Return "6"
    EndIf
    If $string == ""    Then
        Return "7"
        EndIf
    If $string == ""    Then
        Return "8"
    EndIf
    If $string == ""    Then
        Return "9"
        EndIf
    If $string == ""    Then
        Return "0"
    EndIf
    
    Return 2  ;if nothing matched, return 2
EndFunc

I haven't defined the numbers yet, what I am confused about is, the 3rd item

in the found msgbox should be "243385" but instead of that, the number is strange, and

to_search.bmp

Share this post


Link to post
Share on other sites
qwertylol

just open the picture in mspaint, and then run the script with the picture visible.

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  

×