← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #694607]: Pattern.resize() issue driving me nuts!

 

Question #694607 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/694607

    Status: Expired => Answered

RaiMan changed the question status:
Here is a tested example, how I succeeded, to evaluate the resize factor
to apply to all images in scripts run against an environment, where the
GUI elements are enlarged.

I am using macOS 11.1 on a Retina display with the standard resolution of 2048x1152.
When I activate a scaling option in the SystemPrefs, an image captured in the standard is still found without problems.

The attached example uses the scaling option from the app menu (in this case Safari) View -> ActualSize/ZoomIn/ZoomOut.
In the example I display a web page in Safari, capturing an image in the ActualSize state and then use the ZoomIn.
When zoomed in (enlarged) the image is no longer found.
I then use a loop and Pattern().resize(), to find the image again by stepping about 1 pixel up for the larger value of width and height.

After having found the reference image, I use the evaluated resize
factor, to find other images by using Pattern().resize(factor).

My tests gave the following output:

— test.py in state ActualSize
imgRaiMan: time=0.365, score=99.99988
imgSmiley 100.00000
imgSikuliX 100.00000
imgSikuliX 99.99995

— eval.py one time CMD + from ActualSize
imgRaiMan: time=10.250, n=27, factor=1.146, score=99.63880
imgSmiley score=95.28467
imgSikuliX score=92.74814
imgRaimund score=92.10581

— eval.py two times CMD + from ActualSize
imgRaiMan: time=17.860, n=51, factor=1.258, score=99.72572
imgSmiley score=93.89349
imgSikuliX score=90.91188
imgRaimund score=94.77862

— eval.py three times CMD + from ActualSize
imgRaiMan: time=27.328, n=79, factor=1.377, score=99.60801
imgSmiley score=80.45675
imgSikuliX score=66.09237
imgRaimund not found with score > 60

Some comments:
- the score stays rather stable for the first graphics-only image
- the smiley seems to be handled differently (greater reduction of score)
- for images containing text the score-reduction is significantly (the more text the greater)
- above a enlargement of 30% this approach is is not really helpful

The approach used in evalResize.py surely should be tested in other scenarios.
Internally the basic resize feature of Java for BufferedImage objects is used.

To run the scripts (mandatory 2.0.4) in the IDE:
- unzip the stuff somewhere
- In the IDE open dialog go to the folder and select/open test.py/evalResize.py

As you might be aware: the images are shared between all scripts in the
same folder.

Automatic naming of images in the IDE can be achieved so:
- in a new line write imgName =
- let the cursor after the =
- use the capture button/short-cut
… and the image will be captured, inserted and named imgName.png
Now in the rest of the script you can use the variable imgName instead of „imgName.png“.

https://www.dropbox.com/s/hpn1lcxcz9v8ek2/testResize.zip

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