find and findAll don't return the same score

Asked by obiwan-92

Hello,

---------------------------------------------------------------------
# This is my code
cs = Pattern("img.png").similar(0.44)

e = exists(cs)
print "e:", e

f = find(cs)
print "f:", f

lfa = findAll(cs)
for fa in lfa:
    print "fa:", fa
---------------------------------------------------------------------
This is the result :
e: M[862,823 65x10]@S(0)[0,0 1920x1200] S:0,79 Center:894,828
f: M[862,823 65x10]@S(0)[0,0 1920x1200] S:0,79 Center:894,828
fa: M[152,849 65x10]@S(0)[0,0 1920x1200] S:0,45 Center:184,854
fa: M[1146,344 65x10]@S(0)[0,0 1920x1200] S:0,45 Center:1178,349
fa: M[177,344 65x10]@S(0)[0,0 1920x1200] S:0,45 Center:209,349
fa: M[242,30 65x10]@S(0)[0,0 1920x1200] S:0,45 Center:274,35

---------------------------------------------------------------------
This is my question :
You can see that the score of similarity for the match object return from the functions find and exists are 0.79.
But the score of similarity from the function findAll is 0.45
When I click on the image in the IDE, I find 4 images found with a score of 0.45 but none image with a score of 0.79.
I deduce that the IDE use the findAll function to preview the correspondance.

Is there any option to have the same score with all this functions or is it a bug ?

Thanks.

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
RaiMan (raimund-hocke) said :
#1

you seem to use version 1.0.0

I cannot reproduce this behavior in my Mac environment (with the current develop version1.0.1).

It would help if you could send me a zip with a screenshot and the respective image
(silently to my mail at https://launchpad.net/~raimund-hocke)

I will revise the Preview generally for 1.0.1

Revision history for this message
obiwan-92 (obiwan-92) said :
#2

Thanks for yours answer.

I have send you an email with the images.
Yes I use the mature version 1.0.0 of Sikuli.
I coulndn't find any release of 1.0.1, so, no, I don't use it and I don't know if you have already corrected the problem.
But I will take a look in the code.

Please, keep me inform.

Regards.

Revision history for this message
obiwan-92 (obiwan-92) said :
#3

Hi

as already mentioned: I am currently on the way, to revise the Preview feature and will surely find any bugs or other quirks in this section.

To reliably find details on such an image, you need very good visual probes, which means as little background as possible and concentrating on the key aspects.
I have reduced the probe (img.png) to an optimal shape and with the attached script I can visit all connections from top left to bottom right.
as you might see, this works with the standard similarity of 0.7.
It is never (nearly ;-) a good idea, to reduce similarity to get more matches, especially in your case.

I plan to add an image optimizer to the IDE Preview. Currently you have to optimize the image with some picture tool.

hope it helps.
--
RaiMan (raimund-hocke)

------------------------------------------------------------------------------------
Hi,

Yes it's help, I' wil wait for your modification in the IDE preview feature. Is it targeted for the 1.0.1 or the 1.1 ?

But I still do not understand why the findAll doen't return the same score than the find or exists function.
I have take a look in the code and you call the same finder class.
I didn't find any change who explain the difference in the score.

Surely I have to look deeper.

Regards.
--
obiwan-92 (obiwan-92)

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

nice idea ;-)

Revision history for this message
obiwan-92 (obiwan-92) said :
#5

-- IDE preview feature.
not with the 1.0.1

-- Surely I have to look deeper.
You are welcome with any tips what can be improved or fixed. In this case the reason might be the usage of a Pattern with findAll(), because my version with just an image worked as expected.
--
RaiMan (raimund-hocke)

------------------------------------------------------------------------------------
Hi
Copy that.
But I found the difference between the two scores dangerous anyway.
For example the code

if exists(img):
    for i in findAll(img):
        hover(i)

can be generated a findFailed exception, if exists found an image with a higher score than 0.7, but the findAll found the best result with a similarity score lower (like in my first example: 0.45 ).

I will try to find a workaround. I will post it as sonn as I can.

Thanks for your great works.
Regards

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

accepted as bug

Revision history for this message
rob (reg82) said :
#7

when you say "Currently you have to optimize the image with some picture tool." what exactly do you mean?

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

@ Robert
Sikuli's current capture tool does not allow to reshape captured images to get rid of unwanted details at the edges.

The optimal image has as little background as possible around the key aspects of the image, especially in cases where you want to find the image in different background situations. People having "poor" images in these scenarios tend to reduce the minimum similarity to avoid FindFails. But this on the other hand raises the risk to get false positives.

One should always try to capture images, that are found with a similarity at least above 0.8 and even better above 0.9.

So currently the easiest way to get images optimized is to rework the images in an external picture tool, to get rid of unwanted pixels at the edges.

I am working on a new fullscreen Preview window with release 1.1 that will allow these optimizations

Revision history for this message
obiwan-92 (obiwan-92) said :
#9