Search code examples
javasikuli

What's the difference between similarity and score?


I know that Pattern has a data member which is similarity and Match has a data member which is score. Based on my comprehension, I think that score is not the same as similarity. Similarity means what you want to get and score means what you actually get. Am I right?


Solution

  • Yes, you are right. Method "similar" is a setter while "getScore" is a getter.

    With Pattern.similar(minSimilarity) you set minimum value of similarity to be used in a find operation.

    http://doc.sikuli.org/pattern.html#Pattern.similar

    With Match.getScore() you get the similarity score the image or pattern was found.

    http://doc.sikuli.org/match.html

    p = Pattern("1405586806706.png").similar(0.7)
    match = find(p)
    print match.getScore() # might print something like 0.77653471
    

    I use Jython Sikuli, not Java, but I it should be the same:

    http://doc.sikuli.org/javadoc/org/sikuli/script/Match.html#getScore()

    http://doc.sikuli.org/javadoc/org/sikuli/script/Pattern.html#similar(float)