Jump to content

Recommended Posts

Posted

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?

Posted

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

Posted

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?

Posted

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

Posted

#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

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
  • Recently Browsing   0 members

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