← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #691302]: [HowTo] handling findFailed

 

Question #691302 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/691302

RaiMan posted a new comment:
The solution masuo suggested in comment #3 is the best one.
It gives the chance to evaluate the matches with little effort.

To use findBest() only makes sense, if you have more than one image and
want to find the one with the highest score (e.g. a button, that might
have different states).

If you want to work without handling FindFailed, you have to use
exists().

So in your case, supposing the resulting matches do not matter:

if rightRegion.exists(Pattern("1592064085453.png").similar(0.98)) or rightRegion.exists(Pattern("1592064049381.png").similar(0.98)):
    print "on screen"
else:
    print "is not there"

if the matches matter:

match1 = rightRegion.exists(Pattern("1592064085453.png").similar(0.98))
match2 = rightRegion.exists(Pattern("1592064049381.png").similar(0.98))
if match1 and match2:
    print "on screen both"
elif match1:
    print "on screen match1"
elif match2:
    print "on screen match2"
else:
    print "is not there"

be aware:
all methods that are mentioned in this discussion do the same internally: search for an image with the highest score.
They differ only in parameters, results and how they handle FindFailed.

So if you have very similar images, than you have to use Pattern().similar()  to distinguish.
... but the base always is to use images, that concentrate on the distinguishing key factors with as little background as possible.

-- 
You received this question notification because your team Sikuli Drivers
is an answer contact for Sikuli.