← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #177229]: Match all images of the same size

 

Question #177229 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/177229

    Status: Open => Answered

RaiMan proposed the following answer:
"match" might be the wrong wording, since in the sense of Sikuli, a
match needs an image that can be searched and found with some similarity
score.

What you need are regions, which can be calculated from some given
regions (or matches) by doing some calculations based on the geometry of
your assembly.

You first have to calculate position, width and hight of your matrix
somehow (e.g. from the app window):

# margins inside window
bt = 70 # top margin
blr = 20 # left / right
bb = 20 # bottom

aw = App("some app window").window()

# position, dimension of matrix
mx = aw.x + blr
my = aw.y + bt
mw = aw.w - 2*blr
mh = aw.h - bt - bb
matrix = Region(mx, my, mw, mh)

# position, dimension of each picture
pw = int(mw/3)
ph = int(mh/4)

# a 2-dim list as region container
pics = [][]
px = mx
py = my

for r in range(4): # the rows
    for c in range(3): # the columns
        pics[r][c] = Region(px, py, pw, ph)
        px += pw
    py += ph

# now pics contains the regions of the images
# usage:
img_1_4 = pics[0][3] # row 1, pos 4

# alternatively calculate on the fly
img_1_4 = Region(px + 3*pw, py, pw, ph)

hope it helps

-- 
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.