pingpong24 Posted January 7, 2006 Share Posted January 7, 2006 (edited) Func _ocr($Ax, $Ay, $Dx, $Dy) $Bx = $Dx $By = $Ay $Cx = $Ax $Cy = $Dy $width = $Dx - $Ax $length = $Dy - $Ay $size = $width * $length MsgBox(0,"",$width) MsgBox(0,"",$length) Dim $char[$width][$length] For $xwidth = 0 To $width -1 $row = "0" $column = "0" $Ax = $Ax +1 For $xlength = 0 To $length -1 $char[$row][$column] = Hex(PixelGetColor($Ax, $Ay), 6) $Ay= $Ay+1 $column = $column +1 $row = $row +1 Next Next Return $char EndFunc i get a array subscript error. Edited January 7, 2006 by pingpong24 NumCR Super Fast EASY NUMBER OCR, easiest and the fastest AUTOIT OCR released on this forum Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted January 7, 2006 Moderators Share Posted January 7, 2006 I was starring at this for a while before I even noticed what the function name was... trying to figure out why you would be calling PixelGetColor that much. Let me ask you a silly question... Why not just use PixelCheckSum()? 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. Link to comment Share on other sites More sharing options...
pingpong24 Posted January 7, 2006 Author Share Posted January 7, 2006 cause i am storing the values of color into an array. its an OCR script NumCR Super Fast EASY NUMBER OCR, easiest and the fastest AUTOIT OCR released on this forum Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted January 7, 2006 Moderators Share Posted January 7, 2006 (edited) cause i am storing the values of color into an array. its an OCR script Actually your not storing the values into an array, and I did see the function name, but PixelGetColor() is going to be much more inefficient than PixelCheckSum(). I've made quite a few OCR's with AutoIt, the only unfortunate side is they are application specific. I really don't understand your script, but the $Dy has got to be larger $Dx when passing the variable for whatever reason... at least this might give you some ideas (it's still broke... but I think you might be taking the wrong approach so I'll stop here) Try running this just like this, then mess with the values within the function call.#include <array.au3> _ocr(3, 18, 20, 23) Func _ocr($Ax, $Ay, $Dx, $Dy) $Bx = $Dx $By = $Ay $Cx = $Ax $Cy = $Dy $width = $Dx - $Ax $length = $Dy - $Ay Dim $char[$width][$length] Local $AllValues For $xwidth = 0 To $width - 1 For $xlength = 0 To $length - 1 $char[$xwidth][$xlength] = Hex(PixelGetColor($xwidth, $xlength), 6) $AllValues = $AllValues & $char[$xwidth][$xlength] & @LF Next Next MsgBox(0, "", $AllValues) EndFunc Edit: Oh, and this is how I would have done it:PixelChecksum_ocr(3, 18, 20, 23, 1) Func PixelChecksum_ocr($xtop, $ytop, $xbottom, $ybottom, $step = 1) $SUM_OF_AREA = PixelChecksum($xtop, $ytop, $xbottom, $ybottom, $step) MsgBox(0, "", $SUM_OF_AREA) EndFunc Edited January 7, 2006 by SmOke_N 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. Link to comment Share on other sites More sharing options...
pingpong24 Posted January 7, 2006 Author Share Posted January 7, 2006 thanks for that, i have seen many OCR built on this forum but most of them are complicated and i dont see why they have to be that way. also are designed for static images, where as mine is going to be designed for rapidly changing numbers. on that script above i am just testing to see if its possiable to store pixelgetcolor() into arrays. the user tells my script _ocr( the top left hand side of the rectangles, X and Y, then the bottom right handsides x and y) then my script using these 2 values it works out the entire rectangle. Then i create a 2 diminsional array: $someverable[row][colum] then i scan my rectangle from the TOP left hand side (Ax, Ay) it starts to get the pixel color. someverable[0][0] = FFFFFF someverable[0][1] = 000000 now above would be the value of one colum with 2 rows, now if there was a 2 colum someverable[1][0] = ....... someverable[1][1] = ....... ----- thats all i wanted to do. then i am going to check if an array contains the required colour in my case the color is black, if the array doesnt contain black then it will be removed. (blank) if the array contained one black pixel, then this colum of array will be kept. that will be flaged as stating point of a char.. now i will keep adding to the char as normal.. until i come to a point where an entire array doesnt contain the color i require.. in this case black.. once that occurs, ill use array i got so far to compare the arrays with my char difinations. if it doesnt match rescan the same place if does.. continue from where i last left off.. btw. i tested the pixelchecksum and i read the documentation, it says: A checksum only allows you to see if "something" has changed in a region - it does not tell you exactly what has changed. which is no good, you want to know all the colors in a specificed rectangles. also your script only returns 1 color.. you need a array of colors NumCR Super Fast EASY NUMBER OCR, easiest and the fastest AUTOIT OCR released on this forum Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted January 7, 2006 Moderators Share Posted January 7, 2006 Actually... you need to read that a bit different and look at the function name too. Ask your self a question... How does it 'know' the value of that 'area' has changed? It scans an area, and takes it's sum of colors and adds them together (sound familiar to what your trying to accomplish?)... then that sum of colors is stored in a variable, now that variable contains the 'required data be it a picture / letter / several colors / single colors... if that area's color sum should change, then pixelchecksum can tell you that... but you can also use it for defining a specific 'letter / number / picture etc... '. 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. Link to comment Share on other sites More sharing options...
pingpong24 Posted January 7, 2006 Author Share Posted January 7, 2006 (edited) Func _ocr($Ax, $Ay, $Dx, $Dy) $Bx = $Dx $By = $Ay $Cx = $Ax $Cy = $Dy $width = $Dx - $Ax $length = $Dy - $Ay MsgBox(0,"row",$width) MsgBox(0,"column",$length) $size = $width * $length Dim $char[$width][$length] For $xwidth = 0 To $width -1 $row = "0" $column = "0" $Ax = $Ax +1 MsgBox(0,"column",$xwidth,1) For $xlength = 0 To $length -1 $char[$row][$column] = Hex(PixelGetColor($Ax, $Ay), 6) MsgBox(0,"row",$xlength,1) $Ay= $Ay+1 $column = $column +1 $row = $row +1 Next Next Return $char EndFunc i just done tests with msgboxes and everything seems to be fine. so why do i get subscript error? edit: smokeN the modified code you gave me works but i just want to know why mine orginal code doesnt thanks Edited January 7, 2006 by pingpong24 NumCR Super Fast EASY NUMBER OCR, easiest and the fastest AUTOIT OCR released on this forum Link to comment Share on other sites More sharing options...
pingpong24 Posted January 7, 2006 Author Share Posted January 7, 2006 it seems _arrayDisplay has a bug, i tried SmokeN script using array display and i recive the same error. yes i just tested it, and its _arrayDisplay problem. NumCR Super Fast EASY NUMBER OCR, easiest and the fastest AUTOIT OCR released on this forum Link to comment Share on other sites More sharing options...
Valuater Posted January 7, 2006 Share Posted January 7, 2006 i was just bored expandcollapse popup#include <GuiConstants.au3> Opt("MouseCoordMode", 2) ;1=absolute, 0=relative, 2=client Opt("PixelCoordMode", 2) ;1=absolute, 0=relative, 2=client Dim $Paused HotKeySet("{PAUSE}", "TogglePause") HotKeySet("{ESC}", "Terminate") GUICreate("test window", 400, 300) GUICtrlCreateLabel("Array position", 5, 25) GUICtrlCreateLabel("$Ax and $Ay position", 110, 25) GUICtrlCreateLabel("", 145, 0, 28, 8) GUICtrlSetBkColor(-1,0x00ff00) ; Green GUICtrlCreateLabel("", 145, 8, 28, 8) GUICtrlSetBkColor(-1,0xff0000) ; Red GUICtrlCreateLabel("", 145, 16, 28, 8) GUICtrlSetBkColor(-1,"") ; Black GUICtrlCreateLabel("RGB Mouse Color Found ", 250, 25) $color1 = GUICtrlCreateLabel("", 300, 3, 20, 20) $Edit1 = GUICtrlCreateEdit("", 50, 50, 300, 200) GUICtrlCreateLabel("Press *Pause* to Stop/Resume or Press *ESC* to Exit ", 60, 270) GUISetState() _ocr(150, 0, 170, 20) $msg = GUIGetMsg() While $msg <> $GUI_EVENT_CLOSE $msg = GUIGetMsg() WEnd Func _ocr($Ax, $Ay, $Dx, $Dy) $By = $Ay $width = $Dx - $Ax $length = $Dy - $Ay Dim $char[$width][$length] For $xwidth = 0 To $width -1 $Ax = $Ax +1 $Ay = $By For $xlength = 0 To $length -1 $char[$xwidth][$xlength] = Hex(PixelGetColor($Ax, $Ay), 6) GUICtrlCreateLabel("*", $xwidth, $xlength) GUICtrlCreateLabel("*", $Ax -4, $Ay) GUICtrlSetData($Edit1, "Hex Color at " & $Ax & " and " & $Ay & " is " & $char[$xwidth][$xlength] & @CRLF, 1) MouseMove($Ax + 2, $Ay) GUICtrlSetBkColor( $color1, (PixelGetColor($Ax, $Ay))) Sleep(20) $Ay= $Ay+1 Next Next Return $char EndFunc Func TogglePause() $Paused = NOT $Paused While $Paused sleep(100) ToolTip('Script is "Paused"',0,0) WEnd ToolTip("") EndFunc Func Terminate() Exit 0 EndFunc 8) Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now