Nubie Posted March 4, 2020 Posted March 4, 2020 (edited) Hi! I see have alot methods make Image Search around here. But with my tests, they can't find if target isn't same thing I want find (mean not exaclty). Example if target is bigger or smaller (mean not same resolution) or not same color (mean not same pixel color). Of couse their difference isn't too much I think this's hard to do Edited March 7, 2020 by Nubie
Moderators JLogan3o13 Posted March 4, 2020 Moderators Posted March 4, 2020 Please share your code, or an example of the target, and what you are trying, so we can see what you're attempting to accomplish. There may be a better way to do it, but without seeing what code you have it is almost impossible to offer suggestions. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
Nubie Posted March 4, 2020 Author Posted March 4, 2020 xample with 2 images here. just change resolution then Image search can't find for stable I have try by this: here's example code I tried expandcollapse popup#include "_ImageSearch_UDF.au3" #include "_ImageSearch_Tool.au3" #RequireAdmin HotKeySet("{Esc}", "_Exit") ; Press ESC for exit Func _Exit() Exit 0 EndFunc ;==>_Exit Global Const $Ask_On_Found = 0 Global Const $Mouse_Move_On_Found = 1 Global Const $Mouse_Click_On_Found = 0 Global Const $iSleep_Time=500 Global $sCount = 0, $_Image_1 = @ScriptDir & "\example.bmp" ; First, use this function to create a file bmp, maybe a desktop icon for example') MsgBox(64 + 262144, 'ImageSearch', 'At first, create a file bmp,' & @CRLF & 'photos that will search on the screen!') _ImageSearch_Create_BMP($_Image_1) ConsoleWrite("! Search for images: " & $_Image_1 & @CRLF & '! Searching on the screen ...' & @CRLF) While 1 ToolTip('(Press ESC for EXIT) Searching ...', 1, 1) Sleep($iSleep_Time) $sCount += 1 Local $return = _ImageSearch($_Image_1) If $return[0] = 1 Then ConsoleWrite('- [' & $sCount & '] Image found:' & " X=" & $return[1] & " Y=" & $return[2] & @CRLF) If $Mouse_Move_On_Found Then MouseMove($return[1], $return[2]) Sleep($iSleep_Time) EndIf If $Mouse_Click_On_Found Then MouseClick("left", $return[1], $return[2]) ToolTip('(Press ESC for EXIT) - [' & $sCount & "] Image found:" & " X=" & $return[1] & " Y=" & $return[2], 1, 1) If $Ask_On_Found Then Local $ask = MsgBox(6 + 262144, 'Success [' & $sCount & ']', 'Image found:' & " X=" & $return[1] & " Y=" & $return[2]) If $ask = 2 Or $ask = 3 Or $ask = 5 Or $ask = 7 Then Exit ;No, Abort, Cancel, and Ignore If $ask = 10 Then _ImageSearch_Create_BMP($_Image_1) ; Continue ;Try Again EndIf EndIf Sleep(200) WEnd disable _ImageSearch_Create_BMP if don't want capture anymore normal.bmp smaller.bmp
Nine Posted March 4, 2020 Posted March 4, 2020 59 minutes ago, Nubie said: Hi! I see have alot methods make Image Search around here. But with my tests, they can't find if target isn't same thing I want find (mean not exaclty). Example if target is bigger or smaller (mean not same resolution) or not same color (mean not same pixel color). Of couse their difference isn't too much I think this's hard to do For the difference of pixel color, you could try using Tolerance parameters of the Image search function. Be aware that if you have a large Tolerance, you may get false positive. For the difference in size, you may use GDI+ and reduce the size of the searched image pixel by pixel until you find it. However there might a better solution than Image Searching if you could tell us what application your are trying to automate. “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
Nubie Posted March 4, 2020 Author Posted March 4, 2020 17 minutes ago, Nine said: For the difference of pixel color, you could try using Tolerance parameters of the Image search function. Be aware that if you have a large Tolerance, you may get false positive. For the difference in size, you may use GDI+ and reduce the size of the searched image pixel by pixel until you find it. However there might a better solution than Image Searching if you could tell us what application your are trying to automate. Thanks your suggestion, I'll try it I have try make a simple tool detect images in web browser. Something like as "tadah, found you". But I'm surprise it's not work if I change other web browser or change web zoom
Nine Posted March 4, 2020 Posted March 4, 2020 You do know that there is some UDF that could do what you are after (IE for Internet Explorer or WebDriver for Chrome and FireFox). Instead of searching for image, you could way more easily search for tags (ex : img tags). I would highly recommend that you take a closer look at either one of them. Highly... “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
Nubie Posted March 6, 2020 Author Posted March 6, 2020 (edited) On 3/4/2020 at 11:31 PM, Nine said: You do know that there is some UDF that could do what you are after (IE for Internet Explorer or WebDriver for Chrome and FireFox). Instead of searching for image, you could way more easily search for tags (ex : img tags). I would highly recommend that you take a closer look at either one of them. Highly... Thanks for suggestion the method, but I'm only want about Image Search Ok here's my test #include <GDIPlus.au3> #Include <ScreenCapture.au3> #Include <Array.au3> #Include <findBMP.au3> Func _CsvToArray($sSource) Local $aLines = StringSplit(StringStripWS($sSource, 2), @CRLF, 1) Local $arr[$aLines[0]][100], $iMaxCol = 0, $a, $i, $x For $i = 1 To $aLines[0] $a = StringSplit($aLines[$i], ",") If $a[0] > $iMaxCol Then $iMaxCol = $a[0] For $x = 1 To $a[0] $arr[$i - 1][$x - 1] = $a[$x] Next Next ReDim $arr[$aLines[0]][$iMaxCol] Return $arr EndFunc ;==>_CsvToArray $img1 = FileOpenDialog("Main image", @ScriptDir & "\", "Images (*.jpg;*.bmp;*.png;*.gif)", 1) $img2 = FileOpenDialog("Sub image", @ScriptDir & "\", "Images (*.jpg;*.bmp;*.png;*.gif)", 1) _GDIPlus_Startup() $tResult = findBMP($img1, $img2, 1) $test = _CsvToArray($tResult) _GDIPlus_ImageDispose($img1) _GDIPlus_ImageDispose($img2) _ArrayDisplay($test) _GDIPlus_Shutdown() get findBMP from this for make compare images, just little edit for use _CsvToArray All image have same size and resolution, tried with GrayScale for bypass pixelcolor Use button A find button A -> True Use Button B find all Button A -> False What I want: use button B find all button A -> True findBMP.au3 images.zip Edited March 6, 2020 by Nubie
Nubie Posted March 7, 2020 Author Posted March 7, 2020 Ok I found a method can sovle my problem, just need add _GDIPlus_BitmapCloneArea to images before compare Somethings like as this _GDIPlus_BitmapCloneArea(Bitmap, 0 ,0 , $W, $H, $GDIP_PXF01INDEXED) Thanks all, can close this topic
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