← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #256421]: Find/Exists fails with precision, while succeeds without

 

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

Description changed to:
Hi

Since the application I try to automate renders itself in two forms at
my home computer versus at my working computer, I had to find something
like below. Indeed some icons have even different looks, e.g. one has
plus sign whlie the other one has arrows sign so it seems impractical to
match the pictures based on similarity in this case. Proved in practice
it does not work too much.

So I have defined an array of screnshot pictures: fimgContactList  and and index pointing to that array.
Then I use index in the class for the currently running image. For more flexibility I use rather function to get "the currently indexed" picture: get_CurImg


In order to "Calibrate" at tthe beginning, I try to find at which computer we are, i.e. which set of the images we will use, i.e. what the index will be set to (e.g. 0 or 1)

class myClass():
  def __init__(self):
    switchApp("myfavouriteApp")
    self.fimgContactList = ("first.png", "alternativepict.png")
    self.__Kalibruj()

  def get_CurImg(self, fimgX):        
    return fimgX[self.fimgIndex]

  def __Kalibruj(self, fimgKalibracni):
    #for s in range(100, 60, -10):    #Pattern().similar(s) 
    for i in range(len(fimgKalibracni)):
      if exists((fimgKalibracni[i]) ,0):
        self.fimgIndex = i
        return
    return

The above version of Calibration works perfectly.
The main problam I have and I spent literaly hours with it is, whaen I want to be more "robust" in calibration and uncomment the external loop
    for s in range(100, 60, -10): 

and make the find/exists for patern   .similar() instead of  raw image filename
           if exists((Pattern(fimgKalibracni[i])).similar(s/100) ,0):

Then the tests fails, fails, fails, even withou the loop when I for example manually specify 0.7 value or even 0.5 value.
Ridiculous and weird is, when I use the very same screenshot directly in the IDE at the same place without having said arrays, and hardcode the pattern in the editor, it WORKS! Even it finds something like 0.95 accuracy.

If I use it parametrically like I showed, it absurdly ends the program
in case of find with error, or print(exists...) returns None

It seems that converting   any .png  to Pattern(.png).similar(0.7)
creates some bug in sikuli.

I am almost crazy about that. Have no explanation.

The sense of why to do it such a way is, because I am aware of both
versions of calibrating pictures match at 0.7 precision (as I said in
directly used picture), thus the algorithm rather wants to iterate from
0.95 stepdown -0.10  to be able to find a precision where one image
matches and the second one does not to distinguish where we are.

I have strong feeling that the environment behaves differently when specified .similar() via IDE versus via text.
By the way, another issue, the IDE behaves oddly since when I specify .similar() by text, it stays as text, which I welcome, until CTRL+C CTRL+V of the expression which makes it integrated into the Picture icon loosing ability to edit in text. It is annoying but cosmetical.

However the above described problem that the find/exists does not
physically find the match even at .similar(0.5) while finding the match
at default 0.7 is more than weird.

Please help me, do I miss something ?

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