← Back to team overview

sikuli-driver team mailing list archive

[Question #817730]: error searching Pattern multiple times with exists()

 

New question #817730 on SikuliX:
https://answers.launchpad.net/sikuli/+question/817730

Can Pattern objects be reused for multiple searches?
I see nothing in the docs that seems to suggest the contrary.

I am asking beacause running this code:

myImg = "img.png"
myPat = Pattern(myImg).similar(0.8)

[loop]
  if myRegion.exists(myPat,1):
    click(myPat)

I sometimes (let's say once every 1000 searches) get this kind of errors:

[error] script [ p12b ] stopped with error in line 365
[error] FindFailed ( img.png: (73x50) seen at (253, 923) with 0,98 in R[0,0 1920x1080]@S(0) )
[error] --- Traceback --- error source first
line: module ( function ) statement
365: main (  <module> )     click(myPat)
[error] --- Traceback --- end --------------

Strange, because exists() should not throw FindFailed.

With this kind of code, by instancing a new Pattern at every search, I don't get those errors:

[loop]
  s = Pattern(myImg).similar(0.8)
  if myRegion.exists(s,1):
    click(s)


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