sikuli-driver team mailing list archive
-
sikuli-driver team
-
Mailing list archive
-
Message #31439
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, indeed a bit tricky:
I had to use the triangular head of the arrows, to get a consistent behaviour.
I used an external preview tool to get the exact shots (using magnification).
... and the 2 right arrows are slightly different (as you can see with the scores).
The script can be downloaded here (unzip), to get the images as well:
https://dl.dropboxusercontent.com/u/42895525/arrows.sikuli.zip
it contains the relevant part of the shot you gave me showing the part, that should be selected as search region.
To run it, the arrow bar must be visible on the screen.
The possible result highlights are inactivated.
Of course I could not test the type, might be that a short wait(0.5)
might be needed after it.
this is the bare script:
# for doc and test purpose the sample screenshot
# with the recommended selectRegion() area
"original.png"
# 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 = selectRegion("select arrow bar")
reg.highlight(2)
# for test only: a sample find for each arrow type
for a in arrows:
reg.find(a)
# reg.highlight(-1)
# 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 received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.