Image test works on SikuliIDE but not with Java lib

Asked by akbar

Took a screenshot of an image on a browser(lets say Chrome) and the match preview showed a score of 0.7 and a call to exists or find in IDE was passing. Using the same screenshot i ran similar steps using the same browser + Java lib and it failed. I tested the same scenario with all browsers and it passed all the time in IDE and failed all the time with Java lib. It passed only when i created a pattern and set similarity to 0.3. Why is this difference between IDE(sikuli script) and Java lib?

Example:- "Google Images" image on Google Images site(http://www.google.com/imghp?hl=en&tab=wi). Problem with setting the similarity to 0.3 is that the test will pass even if tested with Google search site(www.google.com) as well. But in reality they are two different images.

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

If an image match shows a score of 0.7, this is a hint, that your sample screenshot is too bad (mostly too much background).

You should learn how to make screenshots, that end up with a similarity score above 0.85. The optimum is above 0.95.

Below 0.85 there is a great chance, to get false positives.

So try to narrow your shots to the area containing the really significant pixels.

On the other hand it is always a contribution to reliability, robustness and speed, to narrow the search region as much as possible.

One more thing: There are many aspects, that might lead to the situation, that an image is found on the current system or in the current environment but not on other systems or in other environments. Looking as a human, you might find no differences, but on the pixel level are differences indeed (changes in background, different rendering, ...). In these cases you might need different image sets for different environments, if the above approach does not help.

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

It does not make any difference, wether you run the script in the IDE or on the command line, because the same internals are used in both cases. So there must be other differences.

Revision history for this message
akbar (mohammed-akbar-ali) said :
#3

Thanks RaiMan.
I do understand the differences in between browsers, but the screenshot was taken on a Chrome browser and the same image was used in IDE and Java. Since IDE allows only a rectangle screenshot how do we get higher score when the images are like the one on the google.com site.

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

Ok, I tested on the Google start page.

Even an image, that contains the whole web page content (but nothing of the surrounding browser window frame or bars or whatever), I always get a similarity score of 1.0

So I guess your image contains part of the browser specific surrounding window stuff. That is not recommended.

So if you want you can send me the image you are using to my mail at https://launchpad.net/~raimund-hocke and I can have a look at it and test with Chrome.

If you use images of application specific window parts like button bars, menus, frames, ... their appearance in many cases depends on wether they have focus or not - and that might be a difference between running in IDE and running from command line:
- in IDE, since it makes its window invisible before running the script, Chrome might still have the focus from actions before
- from command line, the java process gets focus and comes to foreground steeling the focus from Chrome

Revision history for this message
akbar (mohammed-akbar-ali) said :
#5

Google start page image is also fine but what i used is just a small screenshot of the image on "Google Images" page. I have emailed the image to your mail <email address hidden>

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

BTW: really bad idea to post my real mail address here.
Please contact Launchpad admin, to get this comment deleted.

Revision history for this message
akbar (mohammed-akbar-ali) said :
#8

sorry raimund, i thought that was your public email id related sikuli support. how do i contact the admin?

Revision history for this message
RaiMan (raimund-hocke) said :
#9
Revision history for this message
akbar (mohammed-akbar-ali) said :
#10

Thanks RaiMan, that solved my question.