Re: [Sikuli-driver] [Question #691302]: [HowTo] handling findFailed

2020-07-16 Thread RaiMan
Question #691302 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/691302

RaiMan posted a new comment:
The solution masuo suggested in comment #3 is the best one.
It gives the chance to evaluate the matches with little effort.

To use findBest() only makes sense, if you have more than one image and
want to find the one with the highest score (e.g. a button, that might
have different states).

If you want to work without handling FindFailed, you have to use
exists().

So in your case, supposing the resulting matches do not matter:

if rightRegion.exists(Pattern("1592064085453.png").similar(0.98)) or 
rightRegion.exists(Pattern("1592064049381.png").similar(0.98)):
print "on screen"
else:
print "is not there"

if the matches matter:

match1 = rightRegion.exists(Pattern("1592064085453.png").similar(0.98))
match2 = rightRegion.exists(Pattern("1592064049381.png").similar(0.98))
if match1 and match2:
print "on screen both"
elif match1:
print "on screen match1"
elif match2:
print "on screen match2"
else:
print "is not there"

be aware:
all methods that are mentioned in this discussion do the same internally: 
search for an image with the highest score.
They differ only in parameters, results and how they handle FindFailed.

So if you have very similar images, than you have to use Pattern().similar()  
to distinguish.
... but the base always is to use images, that concentrate on the 
distinguishing key factors with as little background as possible.

-- 
You received this question notification because your team Sikuli Drivers
is an answer contact for Sikuli.

___
Mailing list: https://launchpad.net/~sikuli-driver
Post to : sikuli-driver@lists.launchpad.net
Unsubscribe : https://launchpad.net/~sikuli-driver
More help   : https://help.launchpad.net/ListHelp


Re: [Sikuli-driver] [Question #691302]: [HowTo] handling findFailed

2020-07-16 Thread RaiMan
Question #691302 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/691302

RaiMan posted a new comment:
The solution masuo suggested in comment #3 is the best one.
It gives the chance to evaluate the matches with little effort.

To use findBest() only makes sense, if you have more than one image and
want to find the one with the highest score (e.g. a button, that might
have different states).

If you want to work without handling FindFailed, you have to use
exists().

So in your case, supposing the resulting matches do not matter:

if rightRegion.exists(Pattern("1592064085453.png").similar(0.98)) or 
rightRegion.exists(Pattern("1592064049381.png").similar(0.98)):
print "on screen"
else:
print "is not there"

if the matches matter:

match1 = rightRegion.findBest(Pattern("1592064085453.png").similar(0.98))
match2 = rightRegion.findBest(Pattern("1592064049381.png").similar(0.98))
if match1 and match2:
print "on screen both"
elif match1:
print "on screen match1"
elif match2:
print "on screen match2"
else:
print "is not there"

-- 
You received this question notification because your team Sikuli Drivers
is an answer contact for Sikuli.

___
Mailing list: https://launchpad.net/~sikuli-driver
Post to : sikuli-driver@lists.launchpad.net
Unsubscribe : https://launchpad.net/~sikuli-driver
More help   : https://help.launchpad.net/ListHelp


Re: [Sikuli-driver] [Question #691302]: [HowTo] handling findFailed

2020-07-15 Thread Javier Gonzales Rodriguez
Question #691302 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/691302

Status: Answered => Solved

Javier Gonzales Rodriguez confirmed that the question is solved:
Thanks masuo, that solved my question.

-- 
You received this question notification because your team Sikuli Drivers
is an answer contact for Sikuli.

___
Mailing list: https://launchpad.net/~sikuli-driver
Post to : sikuli-driver@lists.launchpad.net
Unsubscribe : https://launchpad.net/~sikuli-driver
More help   : https://help.launchpad.net/ListHelp


Re: [Sikuli-driver] [Question #691302]: [HowTo] handling findFailed

2020-06-14 Thread Javier Gonzales Rodriguez
Question #691302 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/691302

Javier Gonzales Rodriguez posted a new comment:
Thanks Masuo, it is working now!

I just did this...

rightRegion = Region(1186,447,173,63)


if rightRegion.findBest(Pattern("1592064085453.png").similar(0.98)) or 
rightRegion.findBest(Pattern("1592064049381.png").similar(0.98)):
print "on screen"
else:
print "is not there"

Thanks again!

Will be great if someone gives an example to handle find().
Am going to keep this open for a little more just in case.

-- 
You received this question notification because your team Sikuli Drivers
is an answer contact for Sikuli.

___
Mailing list: https://launchpad.net/~sikuli-driver
Post to : sikuli-driver@lists.launchpad.net
Unsubscribe : https://launchpad.net/~sikuli-driver
More help   : https://help.launchpad.net/ListHelp


Re: [Sikuli-driver] [Question #691302]: [HowTo] handling findFailed

2020-06-14 Thread masuo
Question #691302 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/691302

Status: Open => Answered

masuo proposed the following answer:
Try similar() and exact().
https://sikulix-2014.readthedocs.io/en/latest/pattern.html?highlight=similar#Pattern.similar

[sample code]
r = Region(0,0,500,500)
anylist = 
r.findAny(Pattern("1592122231908.png").exact(),Pattern("1592122242862.png").exact())
if len(anylist):
print "found"
for m in anylist:
if m.getIndex() == 0:
m.highlight(1,"yellow")
else:
m.highlight(1,"blue")
else:
print "not found"

-- 
You received this question notification because your team Sikuli Drivers
is an answer contact for Sikuli.

___
Mailing list: https://launchpad.net/~sikuli-driver
Post to : sikuli-driver@lists.launchpad.net
Unsubscribe : https://launchpad.net/~sikuli-driver
More help   : https://help.launchpad.net/ListHelp


Re: [Sikuli-driver] [Question #691302]: [HowTo] handling findFailed

2020-06-14 Thread Javier Gonzales Rodriguez
Question #691302 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/691302

Status: Answered => Open

Javier Gonzales Rodriguez is still having a problem:
Hello Mauso,

Thanks for your answer but it didnt work,

findAny, findAll, findBest ... i tested all of them and they choose
similar images but not the correct one.

I definetly need to use find()

-- 
You received this question notification because your team Sikuli Drivers
is an answer contact for Sikuli.

___
Mailing list: https://launchpad.net/~sikuli-driver
Post to : sikuli-driver@lists.launchpad.net
Unsubscribe : https://launchpad.net/~sikuli-driver
More help   : https://help.launchpad.net/ListHelp


Re: [Sikuli-driver] [Question #691302]: [HowTo] handling findFailed

2020-06-13 Thread masuo
Question #691302 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/691302

Status: Open => Answered

masuo proposed the following answer:
findAny() is usefull for your case.
https://sikulix-2014.readthedocs.io/en/latest/region.html#Region.findAny

-- 
You received this question notification because your team Sikuli Drivers
is an answer contact for Sikuli.

___
Mailing list: https://launchpad.net/~sikuli-driver
Post to : sikuli-driver@lists.launchpad.net
Unsubscribe : https://launchpad.net/~sikuli-driver
More help   : https://help.launchpad.net/ListHelp


Re: [Sikuli-driver] [Question #691302]: [HowTo] handling findFailed

2020-06-13 Thread Javier Gonzales Rodriguez
Question #691302 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/691302

Description changed to:
Hello there ...

am using Sikuli for pretty basics task, am not a developer so will be
great if any of you give me a hand to solve my issue.

So let me explain what am trying to do ...

I have 2 images, if any of them are at the region, then do something
"except crashing :( "

I found how to handle it with "exists()" but the problem is that the two
images are very very simular with other images so, sometimes it does
well, sometimes not, the best is using .. find() but it stop the entire
script if does not find anything.

my code is like this...

myRegion = Region(1186,447,173,63)

if myRegion.find(image1.png) or myRegion.find(image2.png):
  print("Found")
else:
 print("not found") 

continue with the script .


I tried to handle it with this...
try:
  myRegion = Region(1186,447,173,63)

  if myRegion.find(image1.png) or myRegion.find(image2.png):
   print("Found")
  else:
  print("not found")
except findFailed:
  pass

But it cotinues crashing

I know that Sikuli is well documented but i couldnt understand how fix
it, so ...

could someone please give me an example how to handle findFailed without stop 
my script?
I know that i can use all these but i dont know how... 
"setFindFailedResponse(SKIP), setThrowException(False), a function to handle 
it, etc."


Note: am using python, Sikuli IDE on Linux Mint 19.03

Thanks, regards!

-- 
You received this question notification because your team Sikuli Drivers
is an answer contact for Sikuli.

___
Mailing list: https://launchpad.net/~sikuli-driver
Post to : sikuli-driver@lists.launchpad.net
Unsubscribe : https://launchpad.net/~sikuli-driver
More help   : https://help.launchpad.net/ListHelp