Hi
I want to know how imagesearch of ahk works (algorithm) , but I can't find the source....
Is there any place that described the way or actual codes of ahk commands?
I am just thinking that imagesearch would work in the way below:
1. get the pixelcolor of each pixels (both needle image and haystack)
2. compare the values of pixelcolor and find the image (maybe using algorithm like kmp...)
Am I right?
How ImageSearch Works (Difference with PixelSearch?) Topic is solved
-
- Posts: 7
- Joined: 02 Aug 2017, 07:30
-
- Posts: 216
- Joined: 30 Jun 2016, 06:01
Re: How ImageSearch Works (Difference with PixelSearch?)
How does the sun set? How is a rainbow made? How does the positrac rear-end on a Plymouth work?
It just does.
It just does.
-
- Posts: 7
- Joined: 02 Aug 2017, 07:30
Re: How ImageSearch Works (Difference with PixelSearch?)
The sun sets because the earch rotates. Rainbow is made because of light reflection.neomulemi6 wrote:How does the sun set? How is a rainbow made? How does the positrac rear-end on a Plymouth work?
It just does.
Positrac rear-end of a Plymouth will work as the engineer designed.
Everything doesn't "just" happen.
All codes are made with original authors' efforts and all codes work in a way that author intended.
By saying what you just said, you're not only showing your ignorance, but also ignoring many people's efforts right now.
Re: How ImageSearch Works (Difference with PixelSearch?)
Autohotkey is Open Source. https://github.com/Lexikos/AutoHotkey_L
Re: How ImageSearch Works (Difference with PixelSearch?) Topic is solved
The source code is usually in cpp files e.g. script2.cpp contains ImageSearch:
Gdip_ImageSearch is useful for searching an image stored in a variable, versus searching on the current screen.
AutoHotkey/Gdip_ImageSearch.ahk at master · MasterFocus/AutoHotkey · GitHub
https://github.com/MasterFocus/AutoHotkey/blob/master/Functions/Gdip_ImageSearch/Gdip_ImageSearch.ahk
I've added more links to the 'SOURCE CODE' section here:
best utilities + best AutoHotkey scripts (+ useful tips) - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=7&t=28149
See also:
AutoHotkey_L/script2.cpp at master · Lexikos/AutoHotkey_L · GitHub
https://github.com/Lexikos/AutoHotkey_L/blob/master/source/script2.cpp#L4722
How does AHK's ImageSearch work? - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=23&t=26857
ImageSearch with transparency tolerance? - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=5&t=33208
Some other 'how does it work?' questions:
jeeswg's homepage - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=17&t=30931&p=144442#p144442
Code: Select all
ResultType Line::ImageSearch(int aLeft, int aTop, int aRight, int aBottom, LPTSTR aImageFile)
// Author: ImageSearch was created by Aurelian Maga.
...
AutoHotkey/Gdip_ImageSearch.ahk at master · MasterFocus/AutoHotkey · GitHub
https://github.com/MasterFocus/AutoHotkey/blob/master/Functions/Gdip_ImageSearch/Gdip_ImageSearch.ahk
I've added more links to the 'SOURCE CODE' section here:
best utilities + best AutoHotkey scripts (+ useful tips) - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=7&t=28149
See also:
AutoHotkey_L/script2.cpp at master · Lexikos/AutoHotkey_L · GitHub
https://github.com/Lexikos/AutoHotkey_L/blob/master/source/script2.cpp#L4722
How does AHK's ImageSearch work? - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=23&t=26857
ImageSearch with transparency tolerance? - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=5&t=33208
Some other 'how does it work?' questions:
jeeswg's homepage - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=17&t=30931&p=144442#p144442
Last edited by jeeswg on 17 Mar 2019, 15:53, edited 2 times in total.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
-
- Posts: 216
- Joined: 30 Jun 2016, 06:01
Re: How ImageSearch Works (Difference with PixelSearch?)
Or I could have been quoting a very funny movie. Who knows.dntkdlsqjawns wrote:The sun sets because the earch rotates. Rainbow is made because of light reflection.neomulemi6 wrote:How does the sun set? How is a rainbow made? How does the positrac rear-end on a Plymouth work?
It just does.
Positrac rear-end of a Plymouth will work as the engineer designed.
Everything doesn't "just" happen.
All codes are made with original authors' efforts and all codes work in a way that author intended.
By saying what you just said, you're not only showing your ignorance, but also ignoring many people's efforts right now.
Re: How ImageSearch Works (Difference with PixelSearch?)
Interesting! So do you think this Gdip Image Search could be faster than the regular ImageSearch? And can it output the coördinates of where it found the image? I didn't see that option at a glance.jeeswg wrote:The source code is usually in cpp files e.g. script2.cpp contains ImageSearch:Gdip_ImageSearch is useful for searching an image stored in a variable, versus searching on the current screen.Code: Select all
ResultType Line::ImageSearch(int aLeft, int aTop, int aRight, int aBottom, LPTSTR aImageFile) // Author: ImageSearch was created by Aurelian Maga. ...
AutoHotkey/Gdip_ImageSearch.ahk at master · MasterFocus/AutoHotkey · GitHub
https://github.com/MasterFocus/AutoHotk ... Search.ahk
I've added more links to the 'SOURCE CODE' section here:
best utilities + best AutoHotkey scripts (+ useful tips) - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=7&t=28149
...
Re: How ImageSearch Works (Difference with PixelSearch?)
(Gdip_ImageSearch stores the results in a ByRef variable, 'OutputList'.)
From some tests it seems that ImageSearch is slightly faster, when the same thing is done as Gdip_ImageSearch, i.e. printscreen and perform one search (although maybe there is some code change that would result in Gdip_ImageSearch being faster).
However, Gdip_ImageSearch, has various options that can be set, allowing it to do things that ImageSearch can't, e.g. specify a search direction, and retrieve multiple results. Or to apply further image searches to an image already in memory, rather than performing a printscreen each time. Or to allow to you search an image that isn't the screen (e.g. from a file, from the clipboard, generated via AHK).
One thing I used Gdip_ImageSearch for was to OCR a timer, I would take multiple screenshots of a timer, until I had two images with exactly the same contents twice, i.e. to confirm that the snapshot was of an actual timestamp, and not a timestamp in transition, when the second was changing.
From some tests it seems that ImageSearch is slightly faster, when the same thing is done as Gdip_ImageSearch, i.e. printscreen and perform one search (although maybe there is some code change that would result in Gdip_ImageSearch being faster).
However, Gdip_ImageSearch, has various options that can be set, allowing it to do things that ImageSearch can't, e.g. specify a search direction, and retrieve multiple results. Or to apply further image searches to an image already in memory, rather than performing a printscreen each time. Or to allow to you search an image that isn't the screen (e.g. from a file, from the clipboard, generated via AHK).
One thing I used Gdip_ImageSearch for was to OCR a timer, I would take multiple screenshots of a timer, until I had two images with exactly the same contents twice, i.e. to confirm that the snapshot was of an actual timestamp, and not a timestamp in transition, when the second was changing.
Code: Select all
q:: ;benchmark tests - ImageSearch v. Gdip_ImageSearch
pToken := Gdip_Startup()
vImgW := 10, vImgH := 10
pBitmapNeedle := Gdip_CreateBitmap(vImgW, vImgH)
G := Gdip_GraphicsFromImage(pBitmapNeedle)
pBrush := Gdip_BrushCreateSolid(0xffff0000)
Gdip_FillRectangle(G, pBrush, 0, 0, vImgW, vImgH)
hBitmapNeedle := Gdip_CreateHBITMAPFromBitmap(pBitmapNeedle)
vNum := 100
;SplashImage, % "HBITMAP:" hBitmapNeedle, B ;B: borderless
vOutput := ""
CoordMode, Pixel, Screen
vTickCount1 := A_TickCount
Loop, % vNum
ImageSearch, vPosX, vPosY, 0, 0, % A_ScreenWidth, % A_ScreenHeight, % "HBITMAP:*" hBitmapNeedle
vTickCount2 := A_TickCount
vOutput .= (vTickCount2-vTickCount1) "`t" vPosX " " vPosY "`r`n"
CoordMode, Mouse, Screen
;MouseMove, % vPosX, % vPosY
vTickCount3 := A_TickCount
Loop, % vNum
{
pBitmap := Gdip_BitmapFromScreen("0|0|" A_ScreenWidth "|" A_ScreenHeight)
;note: coordinates are XYRB not XYWH
Gdip_ImageSearch(pBitmap, pBitmapNeedle, vOutputList, 0, 0, A_ScreenWidth, A_ScreenHeight)
}
vTickCount4 := A_TickCount
oTemp := StrSplit(vOutputList, ",")
vPosX := oTemp.1, vPosY := oTemp.2, oTemp := ""
vOutput .= (vTickCount4-vTickCount3) "`t" vPosX " " vPosY "`r`n"
oTemp := ""
CoordMode, Mouse, Screen
;MouseMove, % vPosX, % vPosY
vTickCount5 := A_TickCount
pBitmap := Gdip_BitmapFromScreen("0|0|" A_ScreenWidth "|" A_ScreenHeight)
Loop, % vNum
{
;note: coordinates are XYRB not XYWH
Gdip_ImageSearch(pBitmap, pBitmapNeedle, vOutputList, 0, 0, A_ScreenWidth, A_ScreenHeight)
}
vTickCount6 := A_TickCount
oTemp := StrSplit(vOutputList, ",")
vPosX := oTemp.1, vPosY := oTemp.2, oTemp := ""
vOutput .= (vTickCount6-vTickCount5) "`t" vPosX " " vPosY "`r`n"
oTemp := ""
CoordMode, Mouse, Screen
;MouseMove, % vPosX, % vPosY
Gdip_DeleteBrush(pBrush)
Gdip_DeleteGraphics(G)
DeleteObject(hBitmapNeedle)
Gdip_DisposeImage(pBitmap)
Gdip_DisposeImage(pBitmapNeedle)
Gdip_Shutdown(pToken)
Clipboard := vOutput
MsgBox, % vOutput
return
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
Re: How ImageSearch Works (Difference with PixelSearch?)
Ah, OK, good to know! That sounds like a good use.
Who is online
Users browsing this forum: Descolada, Google [Bot] and 133 guests