waitVanish waits even though the image vanished --- need to adjust similarity

Asked by Peter Kim

Hi, I have a code like following:

 if (v.exists("image.png")):
     v.waitVanish("image.png",60)

If an image is there, I would like to wait until it vanishes or 60 seconds.
However the image disappears rather quickly and waitVanish waits full 60 seconds even though the image has already disappeared.

Is there a better way to do this?

Thanks.

Peter

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
Peter Kim
Solved:
Last query:
Last reply:
Revision history for this message
Peter Kim (pd-kim) said :
#1

When I do:

 Settings.MinSimilarity = 0.9
 if (v.exists("image.png")):
     v.waitVanish("image.png",60)

It works as it should.

Revision history for this message
RaiMan (raimund-hocke) said :
#2

This would do the same:

v.waitVanish(Pattern("image.png").similar(0.9),60)

waitVanish() returns after the first search attempt, if image is not there.

Using exists() before only makes sense if there would be more to do if image exists and/or you need the match afterwards for some reason (v.getLastMatch()).

BTW: when using if exists(), it makes sense, to set the waiting time to 0, to reduce the delay to the time of one search (in your case about 0.3 seconds vs. 3 seconds).

my version in case the exists() is really needed:

img = Pattern(img).similar(0.9)
if (v.exists(img, 0)):
     v.waitVanish(img,60)

Revision history for this message
RaiMan (raimund-hocke) said :
#3

You found an odd situation, that one would not expect, if you are not aware how Sikuli works inside.

waitVanish() and onVanish() should not work with the default minimum similarity of 0.7, since this has the risk, that something is used to wait for, that was not meant by the user.

I made some tests and think, that these 2 methods should use a minimum similarity of 0.9 or even 0.95. This makes sense, since usually the best match (the thing you are looking for or waiting for to vanish) has a match above 0.95.

I will post a request bug.