findAll() makes 10 attempts before giving up?

Asked by Paul Bellamy

I've noticed that when using findAll(), it appears to make multiple attempts (ten to be exact) to find an object before giving up. I'm basing the off of this pair of messages that I see popping up when findAll() is invoked:

[profile] Finder.findAll START
[profile] Finder.findAll END: 23ms

When the image is *not* present inside of the region, that pair of messages repeats 10 times (and time is wasted as it apparently keeps trying in vain to find something that isn't there) Whenever the image *is* present, it only appears to make one attempt before it successfully returns the match object. My script is working fine, but it's significantly slower since I'm performing a bunch of these findAll() operations on images that may or may not be present.

Is this intended behavior? If so, why? Can I make it give up after the first attempt?

The code looks something like this:

for filename in somelist:
 go_on = False
 try:
  bqr = Pattern(filename)
  bqr = bqr.similar(0.95)
  checkzone.findAll(bqr)
  bMatch = checkzone.getLastMatches()
  go_on = True
 except FindFailed:
  pass
 if go_on == True:
  #do more stuff

Thanks!

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
RaiMan
Solved:
Last query:
Last reply:
Revision history for this message
Best RaiMan (raimund-hocke) said :
#1

It seems, that you have set your AutoWaitTimeout for the region checkzone to a higher value (i guess 10 seconds).

If this is your intention you should "copy" region checkzone, reduce the AutoWaitTimeout and use this region only for the findAll()

checkzone_fast = Region(checkzone)
checkzone_fast.setAutoWaitTimeout(0) # only one try per find

for filename in somelist:
 go_on = False
 try:
  bqr = Pattern(filename)
  bqr = bqr.similar(0.95)
  checkzone_fast.findAll(bqr)
  bMatch = checkzone_fast.getLastMatches()

another possibility might be:

for filename in somelist:
 go_on = False
 try:
  bqr = Pattern(filename)
  bqr = bqr.similar(0.95)
  if exists(bqr, 0):
   checkzone.findAll(bqr)
   bMatch = checkzone.getLastMatches()

so the findAll() would only be performed if at least one bqr is there.

-

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

Uuups, I just realized, that your findAll()'s are very fast, so checkzone seems to be a rather small region.

This means, that these ten retries happen within the standard waiting time of 3 seconds.

Nevertheless, my tips should help anyway.

Revision history for this message
Paul Bellamy (pbellamy) said :
#3

Thanks RaiMan, that solved my question.

Revision history for this message
Paul Bellamy (pbellamy) said :
#4

Brilliant! Worked like a charm. Thanks as always, love the product and the support.