how to get coordinates in two image files

Asked by Chris

hi
There're two image files A and B, i want to find whether B contains A(this can be done by Finder) and get the location in B.
Now, the problem is how to get the location (A in B)?
for example, A picture shows 1 button, B picture shows 3 buttons which is the same with the button in A,
and i want to get location of the button in B picture, how to do this?

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

supposing Jython scripting (IDE)

f = Finder(imageB)
f.find(imageA)
if f.hasNext():
    print "found B in A at ( %d, %d )"%(f.next().x, f.next().y)
else:
    print "B not in A"

if B is more than once in A, it is not predictable, what B will be found.

to get all appearances in arbitrary order:
f = Finder(imageB)
f.findAll(imageA)
if f.hasNext():
    while f.hasNext():
        print "found B in A at ( %d, %d )"%(f.next().x, f.next().y)
else:
    print "B not in A"

the coordinates are relative to the top left corner of A being (0, 0)

Revision history for this message
Chris (christopher-lv) said :
#2

Thanks Raimain, that solved my problem:)