Page 1 of 1

Don't work ImageSearch

Posted: 28 May 2023, 06:49
by aleks
Hello.

I use the following code

Code: Select all

^F5:: {  ; CTRL-F5 = Search for image
CoordMode 'Pixel'
CoordMode 'Mouse'

MsgBox ImageSearch(&x, &y, 0, 0, A_ScreenWidth, A_ScreenHeight, pic2  := "C:\Users\Administrator.AXAPTA2012\Documents\AutoHotkey\sword_magenta.png")
}
I use the picture from one program, everything works.
If I run another copy of the same program, the code doesn't work. I tried this code the next day, the picture is not in both copies of the program. Explain what the problem is and how to solve it

Re: Don't work ImageSearch

Posted: 28 May 2023, 07:15
by boiler
It could be that the image you are trying to find looks the same generally but is rendered differently. Capture a screen shot of the one you are trying to find and zoom in on it and your reference image and look for differences at the pixel level.

Re: Don't work ImageSearch

Posted: 28 May 2023, 07:16
by swagfag
the problem is in ur "program" (game really, lets not kid ourselves)

maybe ure doing something with it that changes the sword's graphic(eg resizing the window, this changing the target image's dimensions)
or maybe uve captured an antialiased image that would change every time its placed somewhere else
or maybe uve captured a semitransparent image which would exhibit the same problem
or maybe the game randomizes the pixels of all graphics subtly every time u start it anew(although thats not an anticheat measure ive ever seen anywhere)

Re: Don't work ImageSearch

Posted: 01 Jun 2023, 06:48
by aleks
Hello
Yes it is a game. But how to find similar pictures if they differ slightly and is it possible to indicate the percentage of discrepancy between pictures, when we can assume that the pictures are similar

Re: Don't work ImageSearch

Posted: 01 Jun 2023, 08:09
by boiler
What you might think are slight differences are so different on a pixel-by-pixel basis that ImageSearch may have no possibility of finding it no matter how much variation you allow. Remember, this isn't a human brain looking at an image and recognizing it as another. It's simply doing a comparison of a set of pixels. The only way to tell is to capture an image and see how different it looks from your reference image when you zoom in on both and compare them at a pixel level.

It could also be that you are capturing a piece of the background in your reference image that changes in other instances, and if that's the main thing that's changing, it can be handled by using the *Trans option of ImageSearch by modifying your reference image to indicate which pixels are to be ignored.