← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #214233]: not exists doesn't do anything

 

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

RaiMan posted a new comment:
thanks for the confirmation and documentation.

I simply put my comments from the original bug 1078806 here too.
--------------------------------------------------------------------------------------------

Using "not exists()" in this form (searching the whole screen) is always
risky, since you might get false positives, that look like the exists()
is not working.

To make this robust, you need a shot, that gets a score (when found) of 0.95 and more.
Next you should restrict the search region to an area as small as possible, so you get something like this:

m = reg.exists(Pattern("HEWLETTPACKA.png").similar(0.95))
if m: reg.getLastMatch().highlight(2); exit()

run this until the region reg and the image are optimized.

reg can be evaluated relative to something else, that can be found with
a score of >0.95.

one more thing:
It seems, that you are using 2 different shots for the same visual content (HEWLETTPACKA and HEWLETTPACKA-1), this should be avoided in any case:
img = Pattern("HEWLETTPACKA.png").similar(0.95) # the optimized shot see above

and then
if not reg.exists(img):

and later
if reg.exists(img): break

and finally
doubleClick(reg.getLastMatch()) # use what already was found before

BTW:
"breakpoints" especially on windows can easily be implemented using input().

----------------------------------------------

In general: the lower the minimum similarity requested for a search, the higher the probability for false positives.
The consequence for robust scripts:
- "good" screenshots (as little background as possible, concentrate on the key visual aspects)
- ask for high min similarity (> 0.9)
- restrict the search region as much as possible (which on top makes your scripts faster)

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