How to get the Y, X, H, W of a Match object

Asked by Raymond

So I have a match object, and I need to get the Y and X coordinates, and Height and Width of the object in order to create a new Region object.

I can't seem to find a way to obtain these attributes from the Match. I have checked the documentation and I looked into converting the Match into a Location object and couldn't find a way to get the attributes out of that either.

I'm stumped. I remember there being getY, getX, getH, and getW methods on Match and Region objects before.

Question information

Language:
English Edit question
Status:
Answered
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
RaiMan (raimund-hocke) said :
#1

these methods are still there - but they (still ;-) need the function brackets: getX()

But as a convenience, you might use direct attribute access too:
m = find(somw-image)
x = m.x # or m.getX()
y = m.y # or m.getY()
w = m.width # or m.getW()
h = m.height # or m.getH()

Revision history for this message
Raymond (darkray16) said :
#2

Thank you. By the way, those get methods and their equivalent forms aren't mentioned anywhere in the documentation.. There is a mention of x, y, w, h parameters when you set a Region, but nothing about how to access them.

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

Sorry, for misleading to some extent: (I mixed it up with Java rectangle)
this is correct:
w = m.w # or m.getW()
h = m.h # or m.getH()

It is not in the docs, because these attributes are class/object internal.

It is recommended to use the setter and getter methods, which are defined for a region. These will be available all time independent from internal class design.

Thanks for the doc tip: when converting the doc to the new system, the get... methods for class Region fell from the table ;-) will be repaired soon.

Can you help with this problem?

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

To post a message you must log in.