sikuli-driver team mailing list archive
-
sikuli-driver team
-
Mailing list archive
-
Message #11758
Re: [Question #203266]: search multiple images at same time
Question #203266 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/203266
Status: Open => Answered
RaiMan proposed the following answer:
--- cannot be decimals. Is there a way to round those numbers up or down?
these kind of questions can easily be solved using Google: "Python round up down" comes back with over 3 Million entries.
integer = int(x/y) # cuts the decimals
integer = int(round(x/y)) # up/down at 0.5
--- The problem is that I need to speed this up significantly.
Your problem is, that every if, that does NOT find, costs you 3 seconds (the standard waiting time).
Since each find operation with smaller regions should cost less than 0.5 seconds, the first step to speed up is using
if exists(some_image, 0):
which comes back after one search, no matter if found or not, hence each if will max take 0.5 seconds (the smaller the search region, the faster).
You can speed this up further, if the searches can be grouped into logical groups, that exclude each other (if from one group one is found, other groups need not be searched, ...)
group1 = false
group2 = false
# searching group 1
if exists(group1_img1, 0):
group1 = true
# more code
if exists(group1_img2, 0):
group1 = true
# more code
# .... more if's
if not group1:
if exists(group2_img1, 0):
group2 = true
# more code
........
--- using observe
observe might further help, since it can be detached to subtasks with background=True, which would parallelize the searches.
But it is rather complex to coordinate the observes and react coordinated when something is found (e.g. using the mouse to click in your case).
More complexity is added, if, as in your case, the search region changes or other aspects of the search.
And you have to switch to use regions instead of using the setROI (which
I generally do not recommend, because you might forget to reset/change
the ROI again and these are hard to find script bugs).
region1 = Region(x,y,w,h)
if region1.exists(some_image, 0):
region1.morphTo(Region(newX, newY, newW, newH)
....
--- BTW: type(Key.ALT)
should do nothing, because the modifier keys cannot be type()'d.
use instead:
keyDown(Key.Alt); keyUp()
--
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.