Is there a way to get the highest match score of a failed Region.exists() call?

Asked by skeets

Trying to find out if we can get the highest match score of a failed Region.exists() call. I know that method returns None if a match is not found but would be nice to know "how close" we got to finding the image. Thanks!

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
RaiMan (raimund-hocke) said :
#1

Does not make sense, since a failed find does not guarantee, that the image was there at all. The score only says, that something to some extent similar image was found.
With "good images", the score should always be 0.9+ or even 0.95+.
read: http://sikulix-2014.readthedocs.io/en/latest/basicinfo.html#sikulix-how-does-it-find-images-on-the-screen
to understand what "good images" are.

Revision history for this message
Alex Lunyov (lunyov-av) said :
#2

You could use method getScore() for a match result in case it is not None.

So, the following code will show you a digit between 0 and 1, where 0 corresponds to "no match" result and 1 to exactly match result:

res = some_reg.exists(some_img)
try:
     print res.getScore()
except AttributeError:
     print 0.

Revision history for this message
skeets (skeets-malloy) said :
#3

Well to us it sort of makes sense but i yeah I also understand why it doesn't make sense.

We check everything at .99 so that we are not finding any false positives and really don't want to go lower than that. So for a failed match we print out what the expected image is that we are trying to find and then a screen shot of what the region was at that time of the failure. Many times we manually see that our image appears to be there but our score is "0". So that is really not true as I'm sure Sikuli may have found the image up to .98 for example... Well be nice to see that .98 was the score so that we know that Sikuli almost found a match instead of thinking that Sikuli didn't find anything even close to a match.

I guess that's all. It's really more for debugging our scripts. Understand though that failed match means failed match and Sikuli didn't find what we wanted it to find within the tolerance given...

Revision history for this message
RaiMan (raimund-hocke) said :
#4

@skeets
Thanks for the detailed explanation, which is based on a good understanding of the SikuliX internals.

I will make your idea a request bug and check what is possible.

A possibility might be to add a Region.getLastScore(), which would be available independently from the existence of a match object.

... but I doubt that it is possible to implement it in 1.1.x (the access to a score in case of find failed is buried deep down in native C++ code, which I do not want to touch anymore). But in version 2 it is surely possible, where all is Java only.

Can you help with this problem?

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

To post a message you must log in.