← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #148439]: exists() finds patterns that are not there

 

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

    Status: Open => Answered

RaiMan proposed the following answer:
if I understand right, what you are doing.

The expected content of the display is 5 after pressing 5, so you should
compare against the appropriate image (or does the display already
contain a 1 - I do not know).

def testCalc(self):
 click("image-of-5-button")
 display = "region-of-calc-display"
 if display.exists(Pattern("image-of-display-displaying-5").similar(0.9)):
  print("It's all good."); return True
 else:
  print("Something is wrong"); return False

The key factor you seem to miss is "minimum similarity" (see the changed
exists() above).

The default similarity is 0.7, which might lead to wrong results. If you
expect something to be really equal, the similarity should be at least
0.9 or more ( in most cases it will be 1.0).

This has to be given to the find() operation using a Pattern object:

exists(Pattern("image-of-display-displaying-5").similar(0.9)

means, that you expect a found image to be equal to your probe, if the
similarity of a match is at least 0.9 (the value you get from the match
using getScore()), otherwise the find fails.

You may have a look at the docs.

-- 
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.