Compare the current screen with a saved screenshot

Asked by Rahul

Hi iam trying to automate a UI where I need to compare a screenshot saved in the Image folder with the current screen. Can someone help me out with the sikuli code when Iam using java in eclipse?

Question information

Language:
English Edit question
Status:
Answered
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:

This question was reopened

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

have a look at class Finder and the docs:
http://sikulix-2014.readthedocs.io/en/latest/finder.html#finder

Revision history for this message
Rahul (rahul+92) said :
#2

HI RaiMan, thanks for the quick response,

I tried using finder and it did really solve my problem

Revision history for this message
Rahul (rahul+92) said :
#3

I have 2 screen shots of 2 windows which have a lot of check boxes , I tried using the finder function for comparing them with a couple of check boxes checked in one screenshot and these check boxes left unchecked in the other; but the result was a match. To how much precision will the finder function find match for me? is there any other function which lets me compare screen to the level of a check box in the screen(or a small text box in the screen)?
I need to check if the two screens are exactly the same to the precision of a pixel(if possible)

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

to solve this, you have to check with an image of the checked and the unchecked situation against the checked and unchecked situation in the screenshot.

use match.getScore() to get the score value of each case.

then use these values (it is ok, to round to 2 decimals) and Pattern().similar() in the find ops.

depending on the concrete situation (scores), it might be necessary to check again with the opposite after a match.

In SikuliX version 1.1.1 a score >0.99 means exact match (depending on the size of the search image, some pixels might be different though (usually around edges)).
So due to the usage of the underlying OpenCV feature matchTemplate(), a precision of a pixel cannot be achieved: a match score only signals a very, very, very, ... high probability that the image matches the nearer the score gets to 1.000000000000...

Can you help with this problem?

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

To post a message you must log in.