|
Post by zipper on Oct 4, 2019 14:33:18 GMT
What is the proper way to search for a given set of images in a region and click on the image that have the highest priority set earlier in script?
Im looking for a way to search and identify best image in one screenshot only. Earlier i did a new snap for each image search and thats not efficient even though it works but slow.
|
|
|
Post by AnkuLua on Oct 4, 2019 15:45:27 GMT
Try this
function existsMultiMax(target, region) local maxScore = 0 local maxIndex = 0 local match snapshot() for i, t in ipairs(target) do if (region:exists(t, 0)) then -- check once local score = getLastMatch():getScore() if (score > maxScore) then maxScore = score maxIndex = i match = getLastMatch() end end end
usePreviousSnap(false) if (maxScore == 0) then return -1 end return maxIndex, match end
local index, match = existsMultiMax({"A.png", "B.png", "C.png"}, Region(10, 20, 100, 200))
|
|
|
Post by zipper on Oct 6, 2019 21:05:39 GMT
local index, match = existsMultiMax({"A.png", "B.png", "C.png"}, Region(10, 20, 100, 200))
Thankyou very much, think this is exactly what i was looking for. May i ask why this line is presented the way it is with index, match = ? Dont see any reference to index except possibly i in the for statement. Will spend tomorrow trying this out. Thanks again.
|
|
|
Post by zipper on Oct 28, 2019 18:08:43 GMT
I got this working just fine, have it in a script doing its job. For next project i would like to examine one snapshot and act on which filename is detected, only one image of about 10 of the ones specified will be present and i cant figure out how to identify which one is identifed so i can have script act on the current situation like: Target if score > 8 If target == "image3.png" then do_something Else do_something_else end
I suspect this is simple but cant figure out how to do it.
|
|
|
Post by zipper on Oct 28, 2019 23:32:57 GMT
Never mind, think i solved the problem by assigning a id to the image files in the table. Will rewrite the script and exited to see if there is a speed increase or not.
|
|