Finding one of several images in predefined region

Asked by Adrian C on 2017-01-11

Hi, I'm trying to define a region that can have one one several images. For example, the image could be img1, img2, img3 etc., and I need to identify which image it is, in a reasonable timeframe (a few seconds preferably). What's the most efficient way of doing this? I've tried exists() but it seems too slow (I'm running it from the IDE, perhaps that's the issue? It won't work by running the sikuli script from the terminal unfortunately.

Any help would be greatly appreciated, thanks

Question information

English Edit question
Sikuli Edit question
No assignee Edit question
Solved by:
Last query:
Last reply:
Best RaiMan (raimund-hocke) said : #1

exists(img, 0)

which comes back after one search and does not wait for the image to appear.

So you can check for some images one after the other in the same region.

Be aware: the smaller the search region the faster the search.

Mike (maestro+++) said : #2

Can you clarify: you say you are trying to define a region but then say you want to identify which image is present. So do you know exactly where these images will appear? Do all they all appear in the same location? Same size? Can you pick out parts of the images that will uniquely identify the images without having to see the whole images? Are you currently searching with a region defined rather than the whole screen?

RaiMan (raimund-hocke) said : #4


This is not Sikuli - correct:

reg = Region(x, y, w, h) # or any other construct, to get a valid region object
if reg.exists(img1,0): #execute commands
elif reg.exists(img2,0): #execute commands
elif reg.exists(imgN,0): #execute commands

Adrian C (adrianc2) said : #5

Thanks RaiMan, that solved my question.