how to find and check an image

Asked by Loren Lai

Hello everybody,

I face another issue again. :-(

I use the find (image) command in sikuli to identify an image. After that I would like to check if it is available, e.g.

click (navi)
sleep(1)
myImage = find (myImage)
sleep(1)
popup (myImage) #does not work -> error msg
if exists (myImage):
    popup ('found myImage')
else:
    popup('not found')

I always got 'not found' .... but I'm sure that it has found myImage ... I think something is wrong with if exists (myImage) ???

Could you help ? :-)

Thank you.

Cheers

Loren

Question information

Language:
English Edit question
Status:
Answered
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
obiwan-92 (obiwan-92) said :
#1

Hello.

First replace popup(myImage) by popup(str(myImage)).

Then :
click (navi)
sleep(1)
try:
    myImage = find(myImage)
    hover(myImage)
    popup('Image found at ' + str(myImage))
except:
    popup('not found')
should be better.

Regards.

Revision history for this message
Eugene S (shragovich) said :
#2

Hi,

I recommend, each time you are not sure whether your image was located or not, use highlight(x) method. It will give you a 100% indication of the object on the screen and will provide you with some extra details.

For example, this is what you'll see in the log:

[log] highlight M[983,233 21x19]@S(0)[0,0 1280x1024] S:1.00 Center:993,242 for 1.0 secs

Here you have the exact location and similarity value.

So try something like that:
find(image.png).highlight(1)

Eugene

Can you help with this problem?

Provide an answer of your own, or ask Loren Lai for more information if necessary.

To post a message you must log in.