How to compare 2 images using Sikuli Java API?

Asked by Jaspreet

Hi,

I am trying to automate scripts for cross-browser testing and exploring Sikuli Java API to compare the captured screenshots with the expected UI screenshots. I am struggling to get this done using Sikuli and get the difference as results. I am using the following code :

Pattern baseImagePattern = new Pattern(imagePath1);
Pattern capturedImagePattern = new Pattern(imagePath2);

Screen screen=new Screen();
Match pass = screen.exists(capturedImagePattern);

System.out.println("Pass = ");
System.out.println(pass);

if (screen.exists(capturedImagePattern) != null) {
     System.out.println("true");
}
else{
         System.out.println("false");
}

The 2 images matches, returns 'true' and 'M[11,91 1049x691]@S(S(0)[0,0 1440x900]) S:0.95 Target:535,436'
I want to know what does 'M[11,91 1049x691]@S(S(0)[0,0 1440x900]) S:0.95 Target:535,436' mean?

Please help!!!

Regards
Jaspreet

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
Eugene S (shragovich) said :
#1

Hi,

What you get is the Match object.
'M[11,91 1049x691]@S(S(0)[0,0 1440x900]) S:0.95 Target:535,436'

Where:
M = Match
[11,91 1049x691] = object's size and location on the screen
S(0)[0,0 1440x900] = Screen and screen resolution. 0 your main screen.
S:0.95 = Similarity score. In this case, a 95% match

Cheers,
Eugene

Can you help with this problem?

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

To post a message you must log in.