← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #707280]: sikuli does'nt recognize images stably

 

Question #707280 on SikuliX changed:
https://answers.launchpad.net/sikuli/+question/707280

    Status: Needs information => Answered

RaiMan proposed the following answer:
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.

-- 
You received this question notification because your team Sikuli Drivers
is an answer contact for SikuliX.