How same sikuli script can work with different resolutions of Android Phones

Asked by jitengoel

Hi,

Need some expert advice.

I have recorded a script using Sikuli and AVD (Eclipse) on one resolution & device size. I want to use the same script on other AVD with different resolution and device size without any changes in script.

Script is getting failed with following error:
------------------------------------------------------------------------------------------
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)

org.sikuli.script.FindFailed: FindFailed: can not find 1386574456658.png on the screen.
 Line 21, in file C:\Users\gur19733\AppData\Local\Temp\sikuli-tmp5666562617732725317.py

----------------------------------------

Though original script work well as soon as i switch to AVD where i have recorded this.

Please suggest.

Regards
Jiten

Question information

Language:
English Edit question
Status:
Answered
For:
SikuliX Edit question
Assignee:
RaiMan Edit question
Last query:
Last reply:
Revision history for this message
RaiMan (raimund-hocke) said :
#1

As long as on another device the captured image is rendered (visible on screen) with the same width and height in pixels, the script should work.

But if the rendering process on the other device displays the image in another resolution, then usually the width and height in pixels is different and the image will no longer found by Sikuli.

*** Background: Currently the image search is based on sliding the image probe (your captured image) over the base image (the search region - I guess in your case the whole screen) pixel by pixel and calculating a match score between 0 and 1 based on the comparison of the pixels of the 2 rectangles.
So searching an image of 30x30 in a region of 300x300 internally results in 271 * 271 comparisons of 2 pixel areas of 30x30.

*** Current solution:
without any special provisions: You need a different image set for every different resolution.

If you know, how the images are rendered in the different resolution, you might try to automatically setup a new image set using some graphics package like ImageMagick.

Next year I will implement some standard features into version 1.2, that might help in these situations.

Revision history for this message
HAL-9000 (coldlogic) said :
#2

If you are scripting to target Android emulators there are a couple things to remember:

Display Scaling:
Screen Size, Scale, and Monitor DPI all appear in making Android emulator. Hence two emulators can have the same screen size, yet appear totally different on the computer monitor. However, so long as Monitor DPI and Scaling values are the same, the icons etc. should appear the same on the computer monitor no matter the 'screen size' of the Emulator.

Scaling to Whole Integers:
Scaling is important in Android emulators. You always want the Scale to div a whole integer into the screen size. 1 is obviously perfect, but 0.5 is always perfect as well (every X,Y of monitor resolution always can always div 2). So, if you're hypothetical emulator is 320x640, with a scaling factor of 0.5 the on-screen res of that emulator will be 640x1280 - note the numbers guarantee the pixels will be addressed to real monitor pixels perfectly.

If the Scale factor cannot divide as a whole integer, the emulator display aliases the pixels, which makes the graphics different, and breaks Sikuli. It also places unnecessary clock cycles on the host machine aliasing all those pixels.

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

@HAL 9000
thanks for this perfect explanation and advice

Revision history for this message
jitengoel (jitengoel) said :
#4

Hi Raimund & HAL-9000,

Thanks for your expert advice. It was really helpful and i am working on my script now to see if it can work as per some of your suggestions & tips.

Regards
Jite

Can you help with this problem?

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

To post a message you must log in.