sikuli-driver team mailing list archive
-
sikuli-driver team
-
Mailing list archive
-
Message #30933
Re: [Question #263333]: searching for multiple images in multiple regions
Question #263333 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/263333
Status: Open => Answered
RaiMan proposed the following answer:
what version of Sikuli?
does not really look like real code, more like handwritten here.
... at least the indentations looks odd
exists("imageholder.png",) and
Region(region 1st 1) and
Region(4)
are not processable Python code and should give errors.
So in the IDE select the relevant code part and paste it here.
generally you should define your regions and patterns outside the while loop, as long as they are constant during looping.
This saves some time and resources.
reg1_1 = Region(... whatever ...)
reg1_2 = ...
...
reg2_1 = ...
...
reg2_4 = ...
img1 = Pattern("image1.png").exact()
img2 = ...
...
img8 = ...
You already use exists(image, 0), that does not wait, but after one search returns if found or not (fastest version).
Another way to speed up the searching, is to make the search regions as small as possible. The smaller the region the faster the search and the smaller the size difference between search region and image, the faster.
You already use search regions with your if/elif chains, so there is only some space for improvement by making these regions as small as possible.
so your loop would look like this finally:
while exists("imageholder.png",0):
click(x) # whatever this might do
# you do not check here, wether the click does what you expect (see comment)
if reg1_1.exists(img1, 0):
click(some location) # not clear why that must be absolute values
elif reg1_2.exists(img2, 0):
click(some other location) # not clear why that must be absolute values
...
comment:
since you click here, but do not wait for some image, to appear (to verify, that the click did what it should), the following img1 - 8 might not be ready yet, so you run a loop that searches, but does nothing (might cost you up to 3 -5 seconds).
So before starting the while loop, the search regions should be there
and one or more of the targets should be visible.
Are you using the latest version (http://sikulix.com)?
--
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.