assert exists() not accurate?

Asked by Shawn Robertson

I am trying to assert a picture however sometime it passes and sometime it fails. its almost like assert exists() doesn't like the image.

the image is just a screen shot of 3 blocks of numbers. I have a screen shot of what the 3 sets of numbers should be and then i put:

         if not exists("image.png"): exit(1)
         else: exit(0)

and then to test that, i go delete a piece of data from my program that causes the numbers to be different

i run the assertion and it exits with code 0 as if the assertion saw the proper numbers which are obviously different.

I also tried with just assert exists(image.png) and it still passes doesnt fail

its almost like assert exists() says "i see 3 blocks and thats ok for me but i don't care if the numbers are actually different"

sometimes it will fail if i use completely different numbers that cause the blocks to get larger or longer which is not what i want.

I want to assert values on the screen..

how can i fine tune this more to make it more accurate?

I have already tried the items below to narrow the search region:

with Region(find("image.png")):

as well as using the IDE command for set region which just shows a screen shot instead of some code

is it possible to do what i want to do?

thanks so much

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
j
Solved:
Last query:
Last reply:
Revision history for this message
Best j (j-the-k) said :
#1

Most likely you have to increase the similarity of your image.
If you click on the image in the IDE, the Pattern Settings Panel is opened.
On the second Tab, you see a search preview of your image on the screen.
If you slide the similarity slider to a higher value, only the more similar positions on the screen are counted as match.
Especially text and numbers need a high similarity for an exact match, so try to set the similarity of your Image to 95 or even 99.

Revision history for this message
Shawn Robertson (shawn-robertson) said :
#2

Thanks j, that solved my question.