same image different colour

Asked by Maniraj

Hai,

I am using same image with different colour - it needs to failed but it is getting pass it should not be.

how to overcome this without using Exact.

 Note -- (i am using similarity 0.9) and I am trying find image in screenshot not in screen.

Help me to get resolve this.

Question information

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

using something like this ?

f = Finder(screenshot)
f.find(image)
if f.hasNext():
   print "found:", f.next()
else:
   print "not found"

using version 1.1.1 or later?

Revision history for this message
Maniraj (aathimaniraj) said :
#2

yes using later 1.1.2,

i am using like this, (Both are same) i think so

 String imagePath = "/Users/aathi/Desktop/websitestab/temp/"+imageName;
    Thread.sleep(2000);
    BufferedImage regionsetimage = ScreenCapture(driver,imageName);
    Finder window = new Finder(regionsetimage);
    Pattern testImage = new Pattern(imagePath);
    window.find(testImage.similar((float) 0.9));
    Match found = null;
    if (window.hasNext())
    {
      found = window.next();
      System.out.println(imageName + " Image found");
    }
    else
    {
      System.out.println(imageName + " Image Not found");
    }
  }

Thanks

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

ok, you should inspect the score, to make your decision:

      found = window.next();
      double score = found.getScore();
      System.out.println(String.format("found: %s (%.15f)", imageName, score));

Revision history for this message
Maniraj (aathimaniraj) said :
#4

with above mentioned comment #3

i get score more than 0.99 but the image is same with diff colour.

In my case it needs to get fail but it is not happening.

help me out with better solution i am using java selenium. for code structure Refer Comment #2

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

Both images return different scores > 0.99, so it is possible to decide, which one was found.

Revision history for this message
Maniraj (aathimaniraj) said :
#6

i can't able to understand what your telling in comment#5 can you explain me in detail

Both images return different scores > 0.99, so it is possible to decide, which one was found - i am using capture image as Expected image compare that image with actual image in this both image means what u referring..

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

comment #5 refers to your comment #4 which in turn refers to comment #3 !!!

all taken together:

found = window.next();
double score = found.getScore();
if (score < 0.9978563) // would mean fail

You have to find out, what the 0.9978563-value in your case must be in what situation.

If the different colors are background colors towards the edges, then make your images smaller, to concentrate on non-background.

see:
http://sikulix-2014.readthedocs.io/en/latest/basicinfo.html#sikulix-how-does-it-find-images-on-the-screen
which applies to your situation too.

You still do not fully understand, how SikuliX find feature works.

Revision history for this message
Maniraj (aathimaniraj) said :
#8

Thanks RaiMan, that solved my question.