← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #434360]: Find match exit from pool of images using one if condition

 

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

    Status: Open => Answered

RaiMan proposed the following answer:
If the number of possible match images is up to 3 to 5, this is a base
solution, that might be packed into a def(), that accepts a list of
images and returns the index of the found match:

images = (img1, img2, img3)

found = 0
if exists(images[found], 0): found += 1
else if exists(images[found], 0): found += 1
else if exists(images[found], 0): found += 1

if found == 1:
    # do what is needed 
if found == 2:
    # do what is needed 
...

Since the searches are done sequentially, they should be optimized by restricting the search to the smallest possible region.
exists(img, 0) only searches once and comes back immediately (no extra wait time).

If more than 5 possible images are needed, you might delegate the
searches to threads, to run them in parallel.

-- 
You received this question notification because your team Sikuli Drivers
is an answer contact for Sikuli.