HowTo use Similar?

Asked by Jeff_Vallis

1.1.1(2015-11-26_01:00nightly)/Mac10.12.3/Java8(64)1.8.0_25-b17

trying to use similar i pattern matching and failed
So I did a search and found an example which I changed to include an image on screen :
( example - http://doc.sikuli.org/match.html )

the Example with my image in : -

m = find("1487256669914.png".similar(0.5).targetOffset(100,0))
print m # message area: Match[10,0 30x22] score=1.00, target=(105,11)

Result
[error] script [ Crap ] stopped with error in line 13
[error] AttributeError ( 'str' object has no attribute 'similar' )

This the same error message that I am getting from my exists test
    if exists("1487245533829.png".similar(0.95)):
[error] ...... stopped with error in line 289
[error] AttributeError ( 'str' object has no attribute 'similar' )

Question information

Language:
English Edit question
Status:
Answered
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:

This question was originally filed as bug #1665372.

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

invalid use of similar ;-)
see answer to question.

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

correct use:
m = find(Pattern("someImage").similar(0.5).targetOffset(x, y))

BTW: working with wanted similarities below 0.7 might lead to false positives.
If you think you need it, then your shot might not be optimal (too much background).
see:
http://sikulix-2014.readthedocs.io/en/latest/basicinfo.html#sikulix-how-does-it-find-images-on-the-screen

Can you help with this problem?

Provide an answer of your own, or ask Jeff_Vallis for more information if necessary.

To post a message you must log in.