Zibit Posted July 23, 2010 Share Posted July 23, 2010 (edited) Well i am working on my face recognizion program and i came up with this UDF. Im not going to release my FR program becouse it still has some issues to take care of. But this UDF might help some people. There are only 2 function's._pixel_getpattern($pos1, $pos2, $len, [opt]$gui, [opt]ScreenMode)_pixel_ratio($pattern, $pattern2, [opt]$ratio_level)With _pixel_ratio you have to have 2 patterns to compare. and ratio level is 0-4if it is 0 by default then it will return the result in pixel's that are the same in $pattern and $pattern2.if you have ratio level higher than 0 then it will return a array. Look at example, You'll understand UDF:expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GDIPlus.au3> Func _pixel_getpattern($pos1, $pos2, $len, $gui = "", $screen = 0) if $len > 50 Then ConsoleWriteError("ERROR: Parameter lenght over limit ( 50 )" & @CRLF) SetError(500) Exit(500) EndIf if $len < 0 Then ConsoleWriteError("ERROR: Parameter lenght under limit ( 0 )" & @CRLF) SetError(505) Exit(505) EndIf if $pos1 < 0 or $pos2 < 0 then ConsoleWriteError("ERROR: Location cannot be under 0" & @CRLF) SetError(501) Exit(501) EndIf if $screen > 2 or $screen < 0 Then ConsoleWriteError("ERROR: Screen mode cannot be over 2 or smaller than 0!" & @CRLF) SetError(504) Exit(504) EndIf Opt("PixelCoordMode", $screen) Local $color[9999999] $i = 0 $x = $pos1 - $len $y = $pos2 - $len $n = 0 Do $n = $n + 1 $color[$n] = PixelGetColor($x, $y, $gui) $y = $y + 1 if $y = $pos2 + $len Then $y = $pos2 - $len $i = $i + 1 $x = $x + 1 EndIf Until $i = $len*2 or $i > $len*2 $color[0] = $n Return $color EndFunc ;==>Example1 Func _pixel_ratio($pattern, $pattern2, $confirm = 0) if $confirm <> 0 then $confirm = $confirm if $confirm > 10 Then ConsoleWriteError("ERROR: Too high confirm level! ( 10 max )" & @CRLF) SetError(502) Exit(502) EndIf Local $result[10] $i = 0 $n = 0 Do $n = $n + 1 if $pattern[$n] = $pattern2[$n] then $i = $i + 1 Until $n = $pattern[0] or $n > $patter[0] $confirm_level = 0 if Number(($i/$pattern[0])*100) > 70 then $confirm_level = 3 if Number(($i/$pattern[0])*100) > 90 then $confirm_level = 4 if Number(($i/$pattern[0])*100) < 50 then $confirm_level = 2 if Number(($i/$pattern[0])*100) < 30 then $confirm_level = 1 $result[1] = $i if $confirm > 1 Then $result[2] = $confirm_level if $confirm > 2 Then $result[3] = Number(($i/$pattern[0])*100) if $confirm > 3 Then $result[4] = $i & "/" & $pattern[0] & " Pixel's" if $confirm = 0 Then $result = $i Return $result EndFuncExample:#include <pattern.au3> $gui = GUICreate("Advanced Example", 124, 168, 900, 600) GUISetState() $pattern = _pixel_getpattern(50, 50, 20) $bar = GUICtrlCreatePic("bar.jpg", 100, 100, 10, 0) $status = GUICtrlCreateLabel("", 0, 10, 90, 100) while 1 $pos = MouseGetPos() $pattern2 = _pixel_getpattern($pos[0], $pos[1], 20) $ratio = _pixel_ratio($pattern, $pattern2, 10) GUICtrlSetPos($bar, 100, 100-$ratio[3], 10, $ratio[3]) GUICtrlSetData($status, "Correct: " & $ratio[1] & @CRLF & "Confirm Level: " & $ratio[2] & @CRLF & $ratio[3] & " %" & @CRLF & $ratio[4]) Sleep(1) WEndUpdate 16. Sept* Added Safety Protocols incase of Heavy CPU or RAM Consuption.TESTED ON XP! MAY NOT WORK ON WIN 7 OR VISTA! Edited September 16, 2010 by Zibit Creator Of Xtreme DevelopersPixel Pattern UDFTray GUI UDFMathssend & recive register scriptMouse Control via Webcam Link to comment Share on other sites More sharing options...
VAG Posted July 23, 2010 Share Posted July 23, 2010 (edited) Sorry I don't get it after running your example. Can you elaborate more?I ran it in W7, I see a small empty window, waited for a while and it posted some message.Correct: 0Confirm level: 10%0/1600 Pixe's Edited July 23, 2010 by VAG Link to comment Share on other sites More sharing options...
Zibit Posted July 23, 2010 Author Share Posted July 23, 2010 why didnt you check the script O.o ??? move the mouse up to left corner of ur screen then youll get it. Creator Of Xtreme DevelopersPixel Pattern UDFTray GUI UDFMathssend & recive register scriptMouse Control via Webcam Link to comment Share on other sites More sharing options...
VAG Posted July 23, 2010 Share Posted July 23, 2010 I did look throught the script. FYI, It works in XP, but not working in my Win7 Ultimate system. Link to comment Share on other sites More sharing options...
Zibit Posted July 23, 2010 Author Share Posted July 23, 2010 well ok ill post that it wouldnt work on win 7. btw thx for telling me Creator Of Xtreme DevelopersPixel Pattern UDFTray GUI UDFMathssend & recive register scriptMouse Control via Webcam Link to comment Share on other sites More sharing options...
JohnOne Posted July 23, 2010 Share Posted July 23, 2010 It works fine on my win 7, but it is really heavy on CPU. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
taurus905 Posted February 11, 2012 Share Posted February 11, 2012 I know this is an old thread but I'd appreciate any help in getting the example working in the first post. Or maybe someone can point me in the right direction. I want to create a script which selects and captures a small portion of my screen, about 15 x 25 pixels, and compares it to one of about 60 stored (library) images of the same size, 15 x 25 pixels. When it finds a match, it returns a message. I've read through a lot of threads in the last few days, but they all seem old and far more complex than what I need. Thanks in advance for any suggestions. taurus905 "Never mistake kindness for weakness."-- Author Unknown --"The highest point to which a weak but experienced mind can rise is detecting the weakness of better men."-- Georg Lichtenberg --Simple Obfuscator (Beta not needed.), Random names for Vars and Funcs Link to comment Share on other sites More sharing options...
Lakes Posted February 11, 2012 Share Posted February 11, 2012 Could this track the mouse pointer in a youtube video? I have an idea to remake a youtube video tutorial but in 720p quality. 2015 - Still no flying cars, instead blankets with sleeves. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 11, 2012 Moderators Share Posted February 11, 2012 taurus905,Look at PixelChecksum in the Help file - that should get you started with your project. If you run into problems, please open a new topic in the "General Help" section to prevent this thread getting taken off-topic. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
taurus905 Posted February 11, 2012 Share Posted February 11, 2012 Hello Melba23, Thank you for your advice and I appologize for the second part of my previous post which could have taken this thread off-topic. To stay on-topic, I am still interested in any help to get the example working in the first post. In particular, line 57 of the UDF reads: Until $n = $pattern[0] or $n > $patter[0] and should be either: Until $n = $pattern[0] or $n > $pattern[0] or Until $n = $pattern[0] or $n > $pattern2[0] My hope is that the original author, Zibit, sees this post and chimes in. Thanks in advance for any help. taurus905 "Never mistake kindness for weakness."-- Author Unknown --"The highest point to which a weak but experienced mind can rise is detecting the weakness of better men."-- Georg Lichtenberg --Simple Obfuscator (Beta not needed.), Random names for Vars and Funcs 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