sikuli-driver team mailing list archive
-
sikuli-driver team
-
Mailing list archive
-
Message #12986
Re: [Question #207797]: image does not exist but if exists is returning true
Question #207797 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/207797
Status: Open => Answered
RaiMan proposed the following answer:
To track down such a problem, you have to find out, what Sikuli finds.
In your case do this:
if exists("MIPO39WAncho-1.png"):
# see comment
print getLastMatch() # 1. match printout
getLastMatch().highlight(3) # 2. red frame 3 secs and match printout
hover(getLastMatch()) # run in slow motion and get blinking red circles at match
popup("39W Anchor 20110926 scenario exists")
-- comment
These are the 3 most useful debugging options:
A find operation stores its last match in its region (your case the screen), which can be retrieved using getLastMatch()
-- 1. print the match and you get something like this:
Match[56,120 75x74 score=1,00 target=center]
It tells you where it was found and the similarity score
-- 2. shows a read rectangle for n seconds
and prints additional information, something like this
[log] highlight Match[56,120 75x74 score=1,00 target=center] for 2.0 secs
-- 3. move the cursor to the match using hover() ...
and run the script in slow motion, which shows blinking red circles for a moment at the target
Usually you will find, that something similar was found with a score below 0.9.
So raise the min similarity to 0.95 (max 0.99), to get only valid matches.
your case:
if exists(Pattern("MIPO39WAncho-1.png").similar(0.95)):
popup("39W Anchor 20110926 scenario exists")
the similarity can be set in the IDE using the preview pane (click on image thumbnail).
In the preview pane you can also check what is found on the screen with your image, but this is less accurate and reliable and not usable in some situations.
--- BTW: the conditional statement in an if/elif/while need not be in
brackets.
--- One more thing: screen shots can be posted here
- by putting them somewhere in the net (Dropbox, ...) and post the link
- post a bug, which allows attachments
- send me a mail with attachment (-> https://launchpad.net/~raimund-hocke) (at best all together zipped with your .sikuli)
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.