Hi.
I was wondering if there was a way to find an image (e.g. in png format) in another, larger image (also in png format).
Is it possible to use ImageSearch for that?
Greets Spitzi
ImageSearch: search on an image file instead of on the screen - is it possible?
Re: ImageSearch: search on an image file instead of on the screen - is it possible?
Yes, as long as the image that you need to find is visible. Try it. See if it works.
When you search for an image, your target is not an image file. It is pixels displayed on the screen.
When you search for an image, your target is not an image file. It is pixels displayed on the screen.
Re: ImageSearch: search on an image file instead of on the screen - is it possible?
Possible, yes
Realistic, no
Greets Spitzi
Re: ImageSearch: search on an image file instead of on the screen - is it possible?
I guess I misunderstood, thought that the image was being displayed-- oops, didn't read the subject carefully enough!
Re: ImageSearch: search on an image file instead of on the screen - is it possible?
My image scan class is capable of this, you can find the github here > https://github.com/Spawnova/ShinsImageScanClass
here is an example on how it is used
here is an example on how it is used
Code: Select all
#include ShinsImageScanClass.ahk
scan := new ShinsImageScanClass() ;only create this once at the top
scan.SetTargetImageFile("LargeImageToSearch.png") ;sets the target to be a local image file instead of the desktop or target window
msgbox % scan.Pixel(0xFF0000,0,x,y) "`n" x "," y ;scans for a red pixel and returns the x,y
msgbox % scan.Image("smallerImage.png",0,x,y) "`n" x "," y ;scans for an image and returns the x,y
exitapp
Some of my AHK programs: 3D Voxel Game - Platformer Game
GitHub projects : Image/Pixel scanning class - Direct2D overlay class
GitHub projects : Image/Pixel scanning class - Direct2D overlay class
Re: ImageSearch: search on an image file instead of on the screen - is it possible?
Hi @Spawnova.
Love it! This looks very promising and should be exactly what I want. I'll give you feedback in a few days.
Greets Simon
Love it! This looks very promising and should be exactly what I want. I'll give you feedback in a few days.
Greets Simon
Re: ImageSearch: search on an image file instead of on the screen - is it possible?
Hi again @Spawnova.
Your code works nicely and is indeed a little bit faster than ImageSearch: on a dual 4k monitor setup I searched the desktop for a small image in the far right lower corner of the screen, it took about 250ms. With ImageSearch about 350ms.
Then I tried it using only a program window - turns out that it was slower than, about 450ms. Why is that?
And is it possible to have an array of all occurrences of the image on the screen?
Thanks again. Spitzi
Your code works nicely and is indeed a little bit faster than ImageSearch: on a dual 4k monitor setup I searched the desktop for a small image in the far right lower corner of the screen, it took about 250ms. With ImageSearch about 350ms.
Then I tried it using only a program window - turns out that it was slower than, about 450ms. Why is that?
And is it possible to have an array of all occurrences of the image on the screen?
Thanks again. Spitzi
Re: ImageSearch: search on an image file instead of on the screen - is it possible?
Window scanning should be significantly faster than desktop, though it may not work on some directx games
you can easily get all matches by using the ImageArray function, here is an example
if there is any other issues you can also message me on discord @ Spawnova#2957, I check it a few times a day =P
you can easily get all matches by using the ImageArray function, here is an example
Code: Select all
#include ShinsImageScanClass.ahk
scan := new ShinsImageScanClass("WindowTitleHere")
return
f1::
;region scans will be faster than normal ones, image array is the slowest scan overall though
;scans for all images in the region of 0,0 to 500,500 with 0 variance
;the results are stored in the results array which contains the x,y
if (scan.ImageArrayRegion("image.png",results,0,0,500,500)) {
for k,v in results
{
msgbox % "Match " a_index ": " v.x "," v.y
}
} else {
msgbox % "Could not find any matches for image.png"
}
return
Some of my AHK programs: 3D Voxel Game - Platformer Game
GitHub projects : Image/Pixel scanning class - Direct2D overlay class
GitHub projects : Image/Pixel scanning class - Direct2D overlay class
Who is online
Users browsing this forum: Bing [Bot], Marium0505, mcl and 348 guests