find is background color blind :(

Asked by kunert0345

Sikuli can not find the correct Image because the only difference between the other images are the background color.

I have tried it already with Settings.MinSimilarity = 0.99

has anyone an idea ?

Question information

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

Try to make the shots with as little background as possible towards the edges.

To understand the magic behind (especially why in that case similarity of 0.99 make things even worth) please read:
http://sikulix-2014.readthedocs.org/en/latest/basicinfo.html#sikulix-how-does-it-find-images-on-the-screen

BTW: Using Settings.MinSimilarity = 0.99 may lead to problems with other images. It is better to set the wanted similarity per image by using Pattern().

Revision history for this message
kunert0345 (windowsme) said :
#2

"Try to make the shots with as little background as possible towards the edges."
Unfortunately, this does not solve my problem :-/
because it is only a button on a website and the only difference is the background color.
like this:

####
#:-)#
####

0000
0:-)0
0000

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

possible to see some samples?

you may send it to (rmhdevelop<--at-->me<--dot-->com)

Revision history for this message
kunert0345 (windowsme) said :
#4

send ;-)

Revision history for this message
kunert0345 (windowsme) said :
#5

No one has an idea ?!

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

sorry for the delay.
I already checked: at the script level there is indeed no difference between the gray and the yellowish button detected.
I have to check a little bit deeper in the Java stuff.
will do it today and com back with an advice for your situation.

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

In fact the 2 different images (yellowish and grey) differ in the returned score, but only after the third decimal place.
The values are also different depending on what image you use

Furthermore exists/find return other scores than findAll does.

I have to go deeper into that (but it is really a borderline case (Grenzfall ;-), but nevertheless it should work)

Since any usage of exists/find however does not work, this is a solution for your special case:

top = "top.png" # image of the header ("Aktionen")
yellow = "yellow.png" # yellowish button
grey = "grey.png" # grey button
mTop = find(top)
area = mTop.below(450)
area.highlight(2)
for reg in list(area.findAllByColumn(yellow)):
  reg = reg.grow(5)
  ms = list(reg.findAll(grey))
  if len(ms) > 0:
    print "grey" if ms[0].getScore() > 0.9999 else "yellow"

a zipped version of the .sikuli can be downloaded from here:
https://onedrive.live.com/redir?resid=A97EFAF6F659D9EE!1404&authkey=!AAPOjzrSgUSzye0&ithint=file%2czip

Interesting: in contrary to the general recommendation, to capture as little background as possible, in this case their should be some background around the button symbols, but inside the button area.

Revision history for this message
kunert0345 (windowsme) said :
#8

Danke RaiMan :-)

Hätte nicht gedacht das die Lösung so aufwendig wird.
Aber ich freue mich total das ich jetzt mit meinem Script weiter arbeiten kann
(Ist so eine Idioten Arbeit bei der ich händisch Dateien über ein Verbugtes Webinterface löschen soll)

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

Na ja aufwändig is etwas übertrieben.
Wenn man die Essenz in eine Funktion reinpackt, dann ist das ein wieder verwendbarer 3-4 Zeiler ;-)

Freut mich, dass es Dir hilft.

Diese Inkonsistenz werde ich sicher erst in Version 2 beheben (in 1.1.0 wäre es eine Operation am offenen Herzen ;-)