Sign in to follow this  
Followers 0
J_Y_C

2 dimensional iteration problem

4 posts in this topic

Ok, so I am making a custom OCR script for work. One part of the script reads a block of pixels and rounds each pixel value to one of 4 values (and counts them), then writes that value to a file. Once it reaches the end of the line of the block that it is scanning, it send a blank line to create a carriage return so that even viewing the symbolic representation of the bitmap will still make sense. But for some reason, it's not scanning the area that I tell it to scan. Here's the function that scans and stores the values. I feed it a line number and a filename. It takes the line number, and gets the other values it needs (top, bottom, right, left) from an array where the index number is the same as the line whose coordinates it holds. Then, it loops through those values, starting at the top left, and ending in the bottom right. I know that the values are getting stored in the array properly, as I have tested that thoroughly by displaying the values in question in a msgbox prior to looking for those coordinates.

Now, for some reason unbeknownst to me, is it getting the left, right, and bottom boundries of each line properly, but it starts it's scan somewhere above the screen, and does the entire screen, but within the bounds of the line left, right, and bottom boundries.

So, each "line" file has way too much data on top of the data that it's supposed to write. The function is called

_SnapShot().

Func _SnapShot($LN, $FN);get top, bottom, left, right from $lineCoors[$LN][1 through 4]
                            ;$FN is what to save the file as, create $TR and $BL from this
    $t = $lineCoors[$LN][1] 
    $b = $lineCoors[$LN][2]
    $l = $lineCoors[$LN][3]
    $r = $lineCoors[$LN][4]
    MsgBox(0,"_SnapShot","top = " & $t & " bottom = " & $b &" left = " & $l &" right = " & $r )
    $OF = FileOpen($tempDir & $FN,2)
    $K=0
    $T=0
    $W=0
    $S=0
    $LD="n"
    for $i = $t to $b
        For $j = $l to $r
            ;$LD = LineData
            Switch PixelGetColor($j, $i)
                case 0 to 15000;letter outline (black)0 $T
                    $LD="t"
                    $T +=1
                case 15001 to 10000000;background (blue)17870 $K
                    $LD="k"             
                    $K +=1
                case 10000001 to 15900000;scrolling (red)15724527 $S
                    $LD="s"
                    $S +=1
                case 15900001 to 16711696;letter inside (white)16711696 $W
                    $LD="w"
                    $W +=1
            EndSwitch       
            FileWrite($OF,$LD)
        Next
        FileWriteLine($OF,"")
    Next
EndFunc

I don't know if this is too involved of a question to ask in a forum, but I don't see anything wrong

with my code, and I am wondering if it's something with autoit?

At first, I thought it was a problem with my pixel corrdinate values that are stored in the array, but I exhaustively tested that, and I can't find a single problem.

Share this post


Link to post
Share on other sites



maybe

Opt("PixelCoordMode", 0)        ;1=absolute, 0=relative, 2=client

see help

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

Yes, I had considered that. I am 100% certain that is not the problem.

But since you brought it up, I don't even understand that the 3rd option means, and the helpfile just glazes over that part.

To try and simplify, when it creates the window that it reads from, it makes it in the upper left hand corner of the screen, so that the relative values are the same as the absolute values anyways, and I tested this with the window tool.

Share this post


Link to post
Share on other sites

Yes, I had considered that. I am 100% certain that is not the problem.

But since you brought it up, I don't even understand that the 3rd option means, and the helpfile just glazes over that part.

To try and simplify, when it creates the window that it reads from, it makes it in the upper left hand corner of the screen, so that the relative values are the same as the absolute values anyways, and I tested this with the window tool.

1 = Default / Screen Coords, self explanitory I think

0 = Window Coords, takes the entire windows height and width (including menus etc...)

2 = Client Coords, take the header/menus etc... out, just the actual client area is used.


[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