zora
New Member
Posts: 22
|
Post by zora on Feb 20, 2016 19:40:20 GMT
Hi I need your help.. I have done with small script but I found issues with Image Recognition, i have couple of images very similar only small numbers change and Ankulua not able to diferentiate, it consider them all same.. please help to get accurate Image Recognition.. here are the images: There are somemore and I use below commands waitClick("1vs1.png") click("1vs1.png") Please help!!
|
|
|
Post by AnkuLua on Feb 21, 2016 0:50:47 GMT
Hi I need your help.. I have done with small script but I found issues with Image Recognition, i have couple of images very similar only small numbers change and Ankulua not able to diferentiate, it consider them all same.. please help to get accurate Image Recognition.. here are the images: There are somemore and I use below commands waitClick("1vs1.png") click("1vs1.png") Please help!! Try using function below. It return the most matching number in a table function existsMultiMax(region, target) local oldROI = Settings:getROI(); local maxScore = 0 local maxIndex = 0 if (region ~= nil) then Settings:setROI(region) end for i, t in ipairs(target) do if (exists(t, 0)) then -- check once local score = getLastMatch():getScore() if (score > maxScore) then maxScore = score maxIndex = i end end end if (oldROI ~= nil) then Settings:setROI(oldROI) else Settings:setROI() end
if (maxScore == 0) then return -1 end return maxIndex end
In your example vs = {"1vs1.png", "1vs2.png", "2vs2.png", "2vs3.png"} choice = existsMultiMax(nil, vs) -- change nil to region if needed Welcome to share the script. Give away AnkuLua pro promotion codes now. ankulua.boards.net/thread/56/give-away-version-promotion-codes
|
|
zora
New Member
Posts: 22
|
Post by zora on Feb 21, 2016 8:21:28 GMT
Hi Sorry I use these image in IF Statement if exists("1x2.png")
Please check my below code:
-- ========== Settings ================ Settings:setCompareDimension(true, 355) Settings:setScriptDimension(true, 355) -- 1st:73 3rd:198 5th:317 7th 437 ... 289 width : -- ========== main program =========== newpos=1 pos=1 auto = Pattern("nightmare.png"):targetOffset(0, -30) stats30 = Pattern("30stats.png"):targetOffset(0, 68) stats15 = Pattern("15stats.png"):targetOffset(0, 68)
--Change Formation Function
function ChangeForm(npos) local retpos=1; waitClick("formbutton.png") waitClick("ray.png")
if (retpos==1) then click(Location(324, 73)) waitClick("formokbutton.png") return retpos; elseif (retpos==3) then click(Location(324, 198)) waitClick("formokbutton.png") return retpos; elseif (retpos==5) then click(Location(324, 317)) waitClick("formokbutton.png") return retpos; elseif (retpos==7) then click(Location(324, 198)) waitClick("formokbutton.png") return retpos; end end -- End of Change Formation Function
-- NW Fight Main Start click("advtab.png") wait(3); existsClick("advstart.png") i = 1 while i ~= 150 do waitClick("advtab.png") existsClick("nwx.png") existsClick("claim.png") existsClick("claimx.png") existsClick(stats30) existsClick(stats15)
--Check Enemy Formation if exists("1x2.png") and pos~=1 then pos=ChangeForm(1); elseif exists("2x3.png") and pos~=1 then pos=ChangeForm(1); elseif exists("3x4.png") and pos~=3 then pos=ChangeForm(3); elseif exists("4x5.png") and pos~=3 then pos=ChangeForm(3); elseif exists("5x6.png") and pos~=5 then pos=ChangeForm(5); elseif exists("6x7.png") and pos~=5 then pos=ChangeForm(5); elseif exists("7x8.png") and pos~=7 then pos=ChangeForm(7); elseif exists("8x8.png") and pos~=7 then pos=ChangeForm(7); elseif exists("2x2.png") and pos~=1 then pos=ChangeForm(1); elseif exists("3x3.png") and pos~=1 then pos=ChangeForm(1); elseif exists("4x4.png") and pos~=3 then pos=ChangeForm(3); elseif exists("5x5.png") and pos~=3 then pos=ChangeForm(3); elseif exists("6x6.png") and pos~=3 then pos=ChangeForm(3); elseif exists("7x7.png") and pos~=5 then pos=ChangeForm(5); end waitClick("advtab.png") waitClick(auto); i=i+1; end
--waitclick(auto)
-- END of NW FIGHT MAIN
|
|
|
Post by AnkuLua on Feb 21, 2016 8:37:29 GMT
Don't know exactly what you want to do. Guess that you have many similar images, 1x2.png, 2x3.png and etc. You want to choose the best match and do some action accordingly. Here is a snippet for your reference.
imageTable = {"1x2.png", "2x3.png", "3x4.png", "4x5.png", "5x6.png", "6x7.png", "7x8.png", "8x8.png", "2x2.png", "3x3.png", "4x4.png", "5x5.png", "6x6.png"} choice = existsMultiMax(nil, imageTable) --Check Enemy Formation if imageTable[choice]=="1x2.png" and pos~=1 then pos=ChangeForm(1); elseif imageTable[choice]=="2x3.png" and pos~=1 then pos=ChangeForm(1); elseif imageTable[choice]=="3x4.png" and pos~=3 then pos=ChangeForm(3); elseif imageTable[choice]=="4x5.png" and pos~=3 then pos=ChangeForm(3); elseif imageTable[choice]=="5x6.png" and pos~=5 then pos=ChangeForm(5); elseif imageTable[choice]=="6x7.png" and pos~=5 then pos=ChangeForm(5); elseif imageTable[choice]=="7x8.png" and pos~=7 then pos=ChangeForm(7); elseif imageTable[choice]=="8x8.png" and pos~=7 then pos=ChangeForm(7); elseif imageTable[choice]=="2x2.png" and pos~=1 then pos=ChangeForm(1); elseif imageTable[choice]=="3x3.png" and pos~=1 then pos=ChangeForm(1); elseif imageTable[choice]=="4x4.png" and pos~=3 then pos=ChangeForm(3); elseif imageTable[choice]=="5x5.png" and pos~=3 then pos=ChangeForm(3); elseif imageTable[choice]=="6x6.png" and pos~=3 then pos=ChangeForm(3); elseif imageTable[choice]=="7x7.png" and pos~=5 then pos=ChangeForm(5); end
|
|
zora
New Member
Posts: 22
|
Post by zora on Feb 21, 2016 18:50:39 GMT
oh thanks very much it works fantastic but the issue it is very slow, is there a way to fasten ?
|
|
zora
New Member
Posts: 22
|
Post by zora on Feb 21, 2016 19:39:44 GMT
For your information below is my code:
-- ========== Settings ================ Settings:setCompareDimension(true, 355) Settings:setScriptDimension(true, 355) -- 1st:73 3rd:198 5th:317 7th 437 ... 289 width : -- ========== main program =========== newpos=1 pos=1 auto = Pattern("nightmare.png"):targetOffset(0, 30) stats30 = Pattern("30stats.png"):targetOffset(0, -68) stats15 = Pattern("15stats.png"):targetOffset(0, -68)
-- Accurate Image Detection Function
function existsMultiMax(region, target) local oldROI = Settings:getROI(); local maxScore = 0 local maxIndex = 0 if (region ~= nil) then Settings:setROI(region) end for i, t in ipairs(target) do if (exists(t, 0)) then -- check once local score = getLastMatch():getScore() if (score > maxScore) then maxScore = score maxIndex = i end end end if (oldROI ~= nil) then Settings:setROI(oldROI) else Settings:setROI() end
if (maxScore == 0) then return -1 end return maxIndex end
--Change Formation Function
function ChangeForm(npos) local retpos=npos; waitClick("formtab.png") waitClick("formbutton.png") waitClick("ray.png") wait(3)
if (retpos==1) then click(Location(324, 73)) waitClick("formokbutton.png") return retpos; elseif (retpos==3) then click(Location(324, 198)) waitClick("formokbutton.png") return retpos; elseif (retpos==5) then click(Location(324, 317)) waitClick("formokbutton.png") return retpos; elseif (retpos==7) then click(Location(324, 437)) waitClick("formokbutton.png") return retpos; end end -- End of Change Formation Function
-- NW Fight Main Start click("advtab.png") wait(3); existsClick("advstart.png") i = 1 while i ~= 150 do waitClick("advtab.png") existsClick("nwx.png") existsClick("claim.png") existsClick("claimx.png") existsClick(stats30) existsClick(stats15) imageTable = {"1x2.png", "2x3.png", "3x4.png", "4x5.png", "5x6.png", "6x7.png", "7x8.png", "8x8.png", "2x2.png", "3x3.png", "4x4.png", "5x5.png", "6x6.png"} choice = existsMultiMax(nil, imageTable) --Check Enemy Formation --Check Enemy Formation if imageTable[choice]=="1x2.png" then pos=ChangeForm(1); elseif imageTable[choice]=="2x3.png" then pos=ChangeForm(1); elseif imageTable[choice]=="3x4.png" then pos=ChangeForm(3); elseif imageTable[choice]=="4x5.png" then pos=ChangeForm(3); elseif imageTable[choice]=="5x6.png" then pos=ChangeForm(5); elseif imageTable[choice]=="6x7.png" then pos=ChangeForm(5); elseif imageTable[choice]=="7x8.png" then pos=ChangeForm(7); elseif imageTable[choice]=="8x8.png" then pos=ChangeForm(7); elseif imageTable[choice]=="2x2.png" then pos=ChangeForm(1); elseif imageTable[choice]=="3x3.png" then pos=ChangeForm(1); elseif imageTable[choice]=="4x4.png" then pos=ChangeForm(3); elseif imageTable[choice]=="5x5.png" then pos=ChangeForm(3); elseif imageTable[choice]=="6x6.png" then pos=ChangeForm(3); elseif imageTable[choice]=="7x7.png" then pos=ChangeForm(5); end
wait(3) waitClick("advtab.png") waitClick(auto); i=i+1; end
|
|
|
Post by AnkuLua on Feb 22, 2016 10:40:06 GMT
oh thanks very much it works fantastic but the issue it is very slow, is there a way to fasten ? Since you compare many things, no wonder it's slow. Try to replace existsMultiMax() with this one. It only captures the screenshot for once and searches the screenshot with all target images. function existsMultiMax(region, target) local oldROI = Settings:getROI(); local maxScore = 0 local maxIndex = 0 if (region ~= nil) then Settings:setROI(region) end for i, t in ipairs(target) do if (i == 1) then usePreviousSnap(false) else usePreviousSnap(true) end if (exists(t, 0)) then -- check once local score = getLastMatch():getScore() if (score > maxScore) then maxScore = score maxIndex = i end end end if (oldROI ~= nil) then Settings:setROI(oldROI) else Settings:setROI() end
usePreviousSnap(true) if (maxScore == 0) then return -1 end return maxIndex end
|
|
zora
New Member
Posts: 22
|
Post by zora on Feb 23, 2016 14:10:26 GMT
Thanks for your support, but unfortunately that affect other images on different page which is not recognized. What I am thinking Can we call function existsMultiMax once in loop round only and get result then let it be in If statement?
Example
imageTable = {"1x2.png", "2x3.png", "3x4.png", "4x5.png", "5x6.png", "6x7.png", "7x8.png", "8x8.png", "2x2.png", "3x3.png", "4x4.png", "5x5.png", "6x6.png"}
choice = existsMultiMax(nil, imageTable)
result = 1x2.png or index 1 in the array of imagetable
if result of existsMultiMax comparison =="1x2.png" then pos=ChangeForm(1); elseif if result of existsMultiMax comparison =="1x2.png" then
|
|
|
Post by AnkuLua on Feb 23, 2016 14:13:48 GMT
Thanks for your support, but unfortunately that affect other images on different page which is not recognized. What I am thinking Can we call function existsMultiMax once in loop round only and get result then let it be in If statement? Example imageTable = {"1x2.png", "2x3.png", "3x4.png", "4x5.png", "5x6.png", "6x7.png", "7x8.png", "8x8.png", "2x2.png", "3x3.png", "4x4.png", "5x5.png", "6x6.png"} choice = existsMultiMax(nil, imageTable) result = 1x2.png or index 1 in the array of imagetable if result of existsMultiMax comparison =="1x2.png" then pos=ChangeForm(1); elseif if result of existsMultiMax comparison =="1x2.png" then In fact, the first answer works just the same as what you said.
|
|
zora
New Member
Posts: 22
|
Post by zora on Feb 23, 2016 14:40:06 GMT
The first answer is calling the function on every if statement right? I need it to be called once and get result then let it be in if statement..
|
|
|
Post by AnkuLua on Feb 23, 2016 15:48:58 GMT
The first answer is calling the function on every if statement right? I need it to be called once and get result then let it be in if statement.. No. It just call image recognition once in existsMultiMax(). imageTable[choice]=="1x2.png" doesn't do image recognition.
|
|
zora
New Member
Posts: 22
|
Post by zora on Mar 4, 2016 13:27:23 GMT
Thanks for your support admin, it helps me alot.. Please suggest me way to fasten the process, as i was implement java application before the similar code was running very fast in sec, But i am experiencing slow progress here, I am using high config phone running andorid 5.0 note 3.
|
|
|
Post by AnkuLua on Mar 4, 2016 13:43:30 GMT
Thanks for your support admin, it helps me alot.. Please suggest me way to fasten the process, as i was implement java application before the similar code was running very fast in sec, But i am experiencing slow progress here, I am using high config phone running andorid 5.0 note 3. Use region to speed up the process.
|
|
zora
New Member
Posts: 22
|
Post by zora on Mar 4, 2016 20:48:42 GMT
please help me to use region.. below is my code:
-- ========== Settings ================ Settings:setCompareDimension(true, 355) Settings:setScriptDimension(true, 355)
-- ========== main program =========== newpos=0 pos=0 auto = Pattern("nightmare.png"):targetOffset(0, 30) stats30 = Pattern("30stats.png"):targetOffset(0, -68) stats15 = Pattern("15stats.png"):targetOffset(0, -68)
--Change Formation Function
function ChangeForm(npos) local retpos=npos; waitClick("formtab.png") wait(2) waitClick("form.png") waitClick("ray.png") wait(2)
if (retpos==1) then click(Location(324, 73)) waitClick("formokbutton.png") return retpos; elseif (retpos==3) then click(Location(324, 198)) waitClick("formokbutton.png") return retpos; elseif (retpos==5) then click(Location(324, 317)) waitClick("formokbutton.png") return retpos; elseif (retpos==7) then click(Location(324, 437)) waitClick("formokbutton.png") return retpos; end end -- End of Change Formation Function
-- Accurate Image Detection Function
function existsMultiMax(target) local maxScore = 0 local maxIndex = 0 for i, t in ipairs(target) do if (i == 1) then usePreviousSnap(false) else usePreviousSnap(true) end if (exists(t, 0)) then -- check once local score = getLastMatch():getScore() if (score > maxScore) then maxScore = score maxIndex = i end end end
usePreviousSnap(false) if (maxScore == 0) then return -1 end return maxIndex end
-- NW Fight Main Start
imageTable = {"1x2.png", "2x3.png", "3x4.png", "4x5.png", "5x6.png", "6x7.png", "7x8.png", "8x8.png", "2x2.png", "3x3.png", "4x4.png", "5x5.png", "6x6.png"} attackTable = {"attack15.png", "attack3.png"}
i = 1 while i ~= 150 do waitClick("advtab.png") wait(2) if exists("nightmare.png") then
choice = existsMultiMax(imageTable) --Check Enemy Formation --Check Enemy Formation
if imageTable[choice]=="1x2.png" and pos~=1 then pos=ChangeForm(1); elseif imageTable[choice]=="2x3.png" and pos~=1 then pos=ChangeForm(1); elseif imageTable[choice]=="3x4.png" and pos~=3 then pos=ChangeForm(3); elseif imageTable[choice]=="4x5.png" and pos~=3 then pos=ChangeForm(3); elseif imageTable[choice]=="5x6.png" and pos~=5 then pos=ChangeForm(5); elseif imageTable[choice]=="6x7.png" and pos~=5 then pos=ChangeForm(5); elseif imageTable[choice]=="7x8.png" and pos~=7 then pos=ChangeForm(7); elseif imageTable[choice]=="8x8.png" and pos~=7 then pos=ChangeForm(7); elseif imageTable[choice]=="2x2.png" and pos~=1 then pos=ChangeForm(1); elseif imageTable[choice]=="3x3.png" and pos~=1 then pos=ChangeForm(1); elseif imageTable[choice]=="4x4.png" and pos~=3 then pos=ChangeForm(3); elseif imageTable[choice]=="5x5.png" and pos~=3 then pos=ChangeForm(3); elseif imageTable[choice]=="6x6.png" and pos~=3 then pos=ChangeForm(3); elseif imageTable[choice]=="7x7.png" and pos~=5 then pos=ChangeForm(5); end wait(3) if exists("advtab.png") then click("advtab.png") else wait(8) waitClick("advtab.png") end wait(2) waitClick(auto); i=i+1; existsClick("nwx.png") else existsClick("nwx.png") existsClick("claim.png") existsClick("claimx.png") wait(2) existsClick("attack15.png") existsClick(stats30) existsClick(stats15) existsClick("claim.png") existsClick("claimx.png") end end
|
|
|
Post by AnkuLua on Mar 5, 2016 4:58:54 GMT
|
|