|
Post by KryTonX on Mar 9, 2017 20:13:29 GMT
Good evening I started using AnkuLua today and it is awesome I love it. Now I started todo a bot for Monster Warlord, since the other Monster Warlord script here is pretty outdated and has not too many functions. I wanted to OCR the Stamina/Energy of the user, so the bot can act accordingly. My Region: The grey highlight is the region:highlight() My Numbers: I have done all of those with "MWSnap" as recommended. As a result, I get all kind of weird results, depending on the similarity settings I use. I have tried a lot of similarity settings ranging from 0.7-1.0. For the higher similaritys I get no result whatsoever (no number found), for the lower ones I get really wrong results with usually even more numbers than there are (2 digs turn into 4 etc.) and with 0.82 I get "0" as a result most of the time. My current code, which is used for the OCR part: Settings:setCompareDimension(true, 720) Settings:setScriptDimension(true, 720) local dir = scriptPath() setImagePath(dir.."/MWBot_Images")
rEnergyCurrent = Region(325,110,50,27)
Settings:set("MinSimilarity", 0.82) rEnergyCurrent:highlight("",3) iEnergyCurrent = numberOCR(rEnergyCurrent,"Number_") print("Current Energy:"..iEnergyCurrent) Settings:set("MinSimilarity", 0.7)
Can somebody spot an error I am still new to this and lua in general, so I would be thankful if somebody could help me out! Greetings and have a nice day, KryTon
|
|
|
Post by AnkuLua on Mar 10, 2017 0:10:04 GMT
Your number images are broken. Please recrop the images.
|
|
|
Post by KryTonX on Mar 10, 2017 15:15:59 GMT
What exactly is "broken" with the numbers. I need to make them rather small because of the " / " that seperates the numbers. Since if I make the number pictures too big, I will get wrong results since a part of the "/" is in the bottom part of the number. Any recommendation what part of the number to use or what to do to make it work? I have redone the pictures several times and it does not seem like I am getting too close to the result. With one "number set" I got semi-good results, then I tried to retake the ones the script confuses, but it does not seem to work better. Does the numberOCR() function need a picture of the full number or is it enough if it is only a part of the number, but it can ONLY be one number with that part? Thanks for your help
|
|
|
Post by Mercobots on Mar 10, 2017 16:13:22 GMT
hi i'm not an expert with OCR but you cut too much your numbers take a look and compare your image with mine even me i can't understand your number "4"
best regards
|
|
|
Post by KryTonX on Mar 10, 2017 17:08:58 GMT
Okay I got it to work, what I did is use the save() function and cropped out the numbers with GIMP, so they are pixel perfect They are also grey, which I do not know why, but save() screenshots already have a filter applied (which is probably used for comparison), not that it makes too much of a difference if the filter is applied two times (correct me if I am wrong) Thanks for your help! I made the numbers a bit bigger while also trying to not get any pixel (shadows) from other numbers in them.
|
|
|
Post by Mercobots on Mar 10, 2017 23:56:03 GMT
as i said before i'm not the best help regarding OCR, but there are some details you need work around (the way i see) - use a program to crop and save directly the image ankulua.boards.net/thread/5/script-development-tools ,i use duckcapture
- never try compare or match an edited image, in your case a resized image
- if i'm not wrong, ankulua/sikuli converts all images in gray scale before he compares
- take look at this picture
if you have anything in the way (red square), in your case "/", dont try to crop, but look closer all the numbers are the same, you can crop any of them the result will be the same (see green squares)
if i'm wrong please someone correct me
|
|
|
Post by KryTonX on Mar 11, 2017 0:07:53 GMT
Figured out as much so far Got it all working now, still thanks for you help and efford. I have to say your first point is not the only way (In your case duckcapture or as in the thread MWSnap). What I do now is I use the save() function and then use GIMP to make an image of the number/button/region I need, this way I use exactly the same input as the script does. The pictures are already "greyed" but "greying" it a second time does not matter. Also I figured that once you have your number images and you get a pixel or two from the outline of the "/" inside of the "number" while doing OCR, it should still work thanks to the comparing with similarity rather than pure identity as long as there is no part of the "/" in the original number image used for comparison. So after managing to read Stamina and Energy, I now got Arena,TB,Epic Boss and a really basic Quest part done Thanks for you guys help
|
|