sikuli-driver team mailing list archive
-
sikuli-driver team
-
Mailing list archive
-
Message #31453
Re: [Question #264487]: Help with making some Sikuli image recognition?
Question #264487 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/264487
RaiMan proposed the following answer:
ok, for production you might reduce it to something like that:
# the arrows
aL = "aleft.png"
aR = "aright.png"
aU = "aup.png"
aD = "adown.png"
# what should be typed in case
arrows = {aL : Key.LEFT, aR : Key.RIGHT, aU : Key.UP, aD : Key.DOWN}
# get the search region
reg = Region(x, y, w, h) # insert the real coordinates you might have got from the selectRegion()
# or use any other suitable method to define the region.
# the concrete solution
reg.setCols(5) # segment the region horizontally into 5 segments
while True: # loop until finished
# loop through the segments
for i in range(5):
col = reg.getCol(i)
# col.highlight(1)
# loop through the arrow types
for a in arrows:
# check the arrow type in segment
if col.exists(Pattern(a).similar(0.8), 0):
print i, a, col.getLastMatch().getScore()
type(arrows[a]) # type the associated key
break # leave the inner loop
if not popAsk("repeat?"):
exit()
You might of course use other means, to trigger the next loop (some
image appeared or vanished, many options ;-)
the FindFailed surely comes from this:
# for test only: a sample find for each arrow type
for a in arrows:
reg.find(a)
because at crash, the arrow bar did not show a left arrow at all
--
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.