sikuli does'nt recognize images stably

Asked by miryam

I use sikuli in my java project to click on images,
 I use this version :
<dependency>
 <groupId>com.sikulix</groupId>
 <artifactId>sikulixapi</artifactId>
<version>2.0.6-SNAPSHOT</version>
</dependency>
 I use SNAPSHOT because I use mac PC with advances Processor that can use only SNAPSHOT version,
 but, this version is seems like Unstable version - it sometimes ecognize the images and sometimes not, when I use this sikuli dependency in 2.0.4 version it works well,
 but in my PC I cannot use this version

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
RaiMan (raimund-hocke) said :
#1

Please be more specific about the problems you have.

What Java version?

Revision history for this message
miryam (cahen) said :
#2

java version:

openjdk version "11.0.19" 2023-04-18

OpenJDK Runtime Environment Homebrew (build 11.0.19+0)

OpenJDK 64-Bit Server VM Homebrew (build 11.0.19+0, mixed mode).

when I use this sikuli dependency in 2.0.4 version on a Windows computer it works well,
but on a Mac computer in 2.0.6-SNAPSHOT version sometimes it recognizes images and sometimes it doesn't. (same picture)

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

Images taken on one system might make problems on other systems due to different image rendering (either generally or by differing settings).

You might either use images taken on the actual system (at least for the ones making problems) or lower the similarity (Pattern.similar). Be aware: a lower similarity increases the risk for false positives.

Image contents that may lead to problems
- text (font differences, antialiasing, ...)
- edge rendering
- gui elements

You might check by visually comparing images from different systems on the pixel level.

You might use the SikuliX IDE Preview feature to see the different similarity scores on different systems.

Revision history for this message
miryam (cahen) said :
#4

I took new pictures on the other computer with the different OS and still have the same problem I described above

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

How (which tool) do you take images?

Send me samples with mail - see https://github.com/RaiMan

Do you act in browser windows?

Revision history for this message
miryam (cahen) said :
#6

I take pictures by using command+shift+4
I don't run in browser windows
How can I send you a sample by mail?
Maybe you could make an appointment with me to help me?

thanks

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

Supposing you have a RetinaDisplay, then shift-command-4 creates pictures having 4 pixels per "real pixel" at 144 dpi.

Since SikuliX (due to the used Java AWT Robot) gets the screen content at 72dpi, these images cannot be found.

You either have to:
 - convert the images to half-width/half-height using Mac tools before use
 - or use Pattern(img).resize(0.5) instead of the image itself
 - or create the images using the Sikulix IDE

a tested example:
switchApp("safari")
wait(1)
img = "mac01.png" # taken with shift-command-4 (452x244 at 144dpi)
m = exists(img, 0)
print m # None (not found)

img = Pattern(img).resize(0.5)
m = exists(img, 0)
print m # M[548,574 226x122]IN(0) %93,07 ...

img = "mac02-1.png" # reduced to half-size with Mac Preview
m = exists(img, 0)
print m # M[548,574 226x122]IN(0) %92,90 ...

img = "img.png" # taken with IDE's snapshot
# different sizes due to manual snapshot actions
m = exists(img, 0)
print m # M[556,579 220x112]IN(0) %100,00

As you can see, the IDE's snapshot creates the best images.

Can you help with this problem?

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

To post a message you must log in.