''Extract''Coordinate of Image

Asked by Marc

Hi!

Sorry for bad English....

I haven't code since a while, I'm a bit lost :

I want to extract the coordinate x and y of multiple images to compare their place in space, I found this :

p = Pattern(Image).targetOffset(x,y)
m = find(p)
print m. getTarget()

It returns :
L(335,609)@S(0)[0,0 1920x1080]

How to get 335 & 609 and assign them to variables

Thanks !

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
masuo
Solved:
Last query:
Last reply:
Revision history for this message
Marc (marcothedwarf) said :
#1

Ok, so I found this :

find(Image).getX()

It's simple I feel so stupid ><

BUT it's not the center of the Image, how I can get it ?

Revision history for this message
masuo (masuo-ohara) said :
#2

You can use getX() and getTarget() together.

p = Pattern(Image).targetOffset(x,y)
m = find(p)
print m.getTarget()
mx = m.getTarget().getX()
my = m.getTarget().getY()
print mx,my

Revision history for this message
Marc (marcothedwarf) said :
#3

Nice thanks !

Now I have another problem, Skuli crashes.... :s

I have like 30 images, I want to print ALL x positions, but the program don't supports it, what can I do ?

Revision history for this message
Best masuo (masuo-ohara) said :
#4

[example:]

imagelist=["image1.png","image2.png"]
for image in imagelist:
    m = find(image).highlight(2)
    print m.getTarget()
    print m.getTarget().getX()

Revision history for this message
Marc (marcothedwarf) said :
#5

Thanks a lot

Something happens now, I get :

[error] FindFailed ( can not find P(MineraiDroit.png) S: 0.8 in R[0,0 1920x1080]@S(0) )
[error] --- Traceback --- error source first line: module ( function ) statement 60: main ( RechercheDroite ) for x in findAll(MineraiDroit):

my fonction :

def RechercheDroite():
    if exists(MineraiDroit):
        for x in findAll(MineraiDroit):
            click(x)

Why did I get this error, it happens sometimes, I absolutely don't understand why...

Revision history for this message
masuo (masuo-ohara) said :
#6

#5 is another question?
if so, close this qestion, and ask a new question.

Revision history for this message
Marc (marcothedwarf) said :
#7

Thanks masuo, that solved my question.