Image match successful on mac fails on windows

Asked by Allen Sparks on 2018-03-08

I have this odd problem where I am using sikuli to match images and click on them in a test suite. On my development machine (MacBook pro) everything works as expected both on the retina display and an external monitor. However, on my coworker's development machine the same tests fail to find 90% of the images.

I setup a debug session and captured the screen size like so:
        Screen screen = new Screen();
        Rectangle size = screen.getBounds();

Both monitors returned vastly different resolutions, so we corrected that to where we were both running 1440x900 and still my machine passes, his machine fails.

the call is pretty simple, literally waiting for the target image:

 try {
            screen.wait(target, time);
        } catch (FindFailed e) {

I thought at first I was dealing with a multi-screen issue, so I forced chromedriver to open at 0,0 so we could control which monitor it is being displayed on, still no luck. seriously at a loss here.

Question information

English Edit question
Sikuli Edit question
No assignee Edit question
Solved by:
Allen Sparks
Last query:
Last reply:
Allen Sparks (asparks) said : #1

I should note I did take the screen grabs from the monitor, not the retina display so that they are in 72 dpi rather than macbooks 144dpi to try and avoid further confusion. This also did not solve the problem.

RaiMan (raimund-hocke) said : #2

If you are using at least Java 8 and SikuliX 1.1.1 or 1.1.2 SikuliX capture and search on Retina displays works, since internally everything is handled with normal dpi automatically.

The problem with images working on a Mac and not on Windows usually has to do with different rendering and/or image content differences.

Monitor size in pixels does not matter, as long as the images on the target system are the same size in pixels (though they might look smaller or larger depending on the monitor size).

Take care that the captured images concentrate on the key aspects in the middle part and have as little background as possible towards the edges.

Compare captures from a Mac and from Windows with an ImageViewer enlarging until you can see the pixels. You might notice differences (e.g. aliasing of edges, ...).

If the differences cannot be minimized, you need a different image set for Windows.

Allen Sparks (asparks) said : #3

Thanks RaiMan I will compare and see if I can tighten up the images and worst case I will make separate folders for the two OS's

Mike Bedwell (bedwell2012) said : #4

Not to step on any toes, but I've been developing a piece of software that must work on all three (windows/linux/osx). One of the things that has helped me to trouble shoot this is use the IDE to preview match success on the systems giving you trouble. I've ran across more than one instance where images were matching fine, but due to other handling factors in my own code, it appeared that matches were failing. The IDE will give you an easy way to verify that it truly is a match fail and not a region issue (I finally started dynamically calculating search regions, in my initial code I made too many assumptions). Of course, if you've already tried that, apologies for the extra time taken here :)

Allen Sparks (asparks) said : #5

could you expand on that Mike? I am not sure I am following what you mean by preview match success?

Mike Bedwell (bedwell2012) said : #6

Sure. If you open the IDE, and add one of your images to the script there (using 'insert image'), you can click on the image thumbnail that results to open the Pattern Settings dialog. That interface has three tabs across the top. The middle one (Matching Preview) will show you everyplace on a screen capture that your image will match, and at what level of quality. For what it's worth, I don't use the IDE myself as i'm writing against the java api, but I use the IDE to manage, capture, and preview all of my image samples just for that functionality.