Question #215825 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/215825
Status: Open => Answered
RaiMan proposed the following answer:
--- finds normally but sometimes not
This normally is a problem with the captured image, that is used for searching:
it has too much background, that might be slightly different in the "sometimes
not" situations.
If the image is "bad" in this sense, then it is found normally with a low
similarity near 0.7 and the not found situations give a similarity below of
0.69 and below, which makes it to fail.
Reducing the minimum similarity does not help, because it raises the risk of
false positives.
What to do?
- recapture the image with as little background as possible and concentrate on
the major aspects, that allows Sikuli to find it
- as a general means for speed and stability, restrict the search region to the
smallest possible area, where the image is expected to appear (there are many
questions and some faqs on that)
--- usage of getLastMatch() with target offset
the match of the last search operation (find, click and others) is stored with
the search region (usually the screen region (SCREEN), that is the region used
with a unqualified find() in contrast to reg.find(), where reg is used to
search).
After saying m=getLastMatch() can be used instead of a new find() operation, as
long as you are sure, that the match of the first find is still a valid region
in your workflow (you have to do a new find() operation for example, if the
target changes its position after the you have stored the last match).
In your case, supposing, that the target mine does not move in the given
sequence, this could be a valid script:
x,y= mine_coord(mine) #a def which I pre-define
while not exists(Pattern("mines.png").targetOffset(x,y)):
wait(1)
lastmatch = getLastMatch()
# now we can use lastmatch as a reference for other actions
click (lastmatch) #first time I search for mines.png
click("giveup.png")
click("confirm.png")
click (lastmatch) #2nd time I search for mines.png
click("occupy.png")
--
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.
_______________________________________________
Mailing list: https://launchpad.net/~sikuli-driver
Post to : [email protected]
Unsubscribe : https://launchpad.net/~sikuli-driver
More help : https://help.launchpad.net/ListHelp